From 79dac54427df4c304c2e2d2a1b89e41f1e9a645c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B6r=C3=B6k=20Edwin?= Date: Mon, 18 Jun 2012 21:20:58 +0300 Subject: [PATCH 1/3] radeon/llvm: fix sin/cos codegen on R700 Based on https://bugs.freedesktop.org/show_bug.cgi?id=50317#c4 Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=50316 https://bugs.freedesktop.org/show_bug.cgi?id=50317 --- src/gallium/drivers/radeon/R600Instructions.td | 37 ++++++++++++------------ 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/gallium/drivers/radeon/R600Instructions.td b/src/gallium/drivers/radeon/R600Instructions.td index 794eaef..a040cc3 100644 --- a/src/gallium/drivers/radeon/R600Instructions.td +++ b/src/gallium/drivers/radeon/R600Instructions.td @@ -271,6 +271,10 @@ def load_param : PatFrag<(ops node:$ptr), */ def isR600 : Predicate<"Subtarget.device()" "->getGeneration() == AMDILDeviceInfo::HD4XXX">; +def isR700 : Predicate<"Subtarget.device()" + "->getGeneration() == AMDILDeviceInfo::HD4XXX &&" + "Subtarget.device()->getDeviceFlag()" + ">= OCL_DEVICE_RV710">; def isEG : Predicate<"Subtarget.device()" "->getGeneration() >= AMDILDeviceInfo::HD5XXX && " "Subtarget.device()->getDeviceFlag() != OCL_DEVICE_CAYMAN">; @@ -707,14 +711,12 @@ class RECIPSQRT_IEEE_Common inst> : R600_1OP < >; class SIN_Common inst> : R600_1OP < - inst, "SIN", - [(set R600_Reg32:$dst, (int_AMDIL_sin R600_Reg32:$src))]>{ + inst, "SIN", []>{ let Trig = 1; } class COS_Common inst> : R600_1OP < - inst, "COS", - [(set R600_Reg32:$dst, (int_AMDIL_cos R600_Reg32:$src))]> { + inst, "COS", []> { let Trig = 1; } @@ -778,16 +780,19 @@ let Predicates = [isR600] in { } -/* ----------------- */ -/* R700+ Trig helper */ -/* ----------------- */ - -/* -class TRIG_HELPER_r700 : Pat < - (trig_inst R600_Reg32:$src), - (trig_inst (fmul R600_Reg32:$src, (PI)))) +class TRIG_eg : Pat< + (intr R600_Reg32:$src), + (trig (MUL (MOV_IMM_I32 (i32 ALU_LITERAL_X), CONST.TWO_PI_INV), R600_Reg32:$src)) >; -*/ + +let Predicates = [isR700] in { + /* R700 normalizes inputs to SIN/COS the same as EG */ + def SIN_r700 : SIN_Common<0x6E>; + def COS_r700 : COS_Common<0x6F>; + + def : TRIG_eg ; + def : TRIG_eg ; +} //===----------------------------------------------------------------------===// // Evergreen Only instructions @@ -810,12 +815,6 @@ def RECIP_UINT_eg : RECIP_UINT_Common<0x94>; /* ------------------------------- */ let Predicates = [isEGorCayman] in { - -class TRIG_eg : Pat< - (intr R600_Reg32:$src), - (trig (MUL (MOV_IMM_I32 (i32 ALU_LITERAL_X), CONST.TWO_PI_INV), R600_Reg32:$src)) ->; - def MULADD_eg : MULADD_Common<0x14>; def ASHR_eg : ASHR_Common<0x15>; def LSHR_eg : LSHR_Common<0x16>; -- 1.7.10