From: Tom Stellard Date: Thu, 17 May 2012 17:36:12 +0000 (-0400) Subject: radeon/llvm: Lower lrp intrinsic during ISel X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c6c8a05c509b30600d2ccb4be635f05cd71c68a4;p=mesa.git radeon/llvm: Lower lrp intrinsic during ISel --- diff --git a/src/gallium/drivers/radeon/AMDGPUISelLowering.cpp b/src/gallium/drivers/radeon/AMDGPUISelLowering.cpp index 53f04c57de1..0417273d971 100644 --- a/src/gallium/drivers/radeon/AMDGPUISelLowering.cpp +++ b/src/gallium/drivers/radeon/AMDGPUISelLowering.cpp @@ -45,6 +45,8 @@ SDValue AMDGPUTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, default: return Op; case AMDGPUIntrinsic::AMDIL_abs: return LowerIntrinsicIABS(Op, DAG); + case AMDGPUIntrinsic::AMDGPU_lrp: + return LowerIntrinsicLRP(Op, DAG); case AMDGPUIntrinsic::AMDIL_mad: return DAG.getNode(AMDILISD::MAD, DL, VT, Op.getOperand(1), Op.getOperand(2), Op.getOperand(3)); @@ -73,6 +75,22 @@ SDValue AMDGPUTargetLowering::LowerIntrinsicIABS(SDValue Op, return DAG.getNode(AMDGPUISD::SMAX, DL, VT, Neg, Op.getOperand(1)); } +/// Linear Interpolation +/// LRP(a, b, c) = muladd(a, b, (1 - a) * c) +SDValue AMDGPUTargetLowering::LowerIntrinsicLRP(SDValue Op, + SelectionDAG &DAG) const +{ + DebugLoc DL = Op.getDebugLoc(); + EVT VT = Op.getValueType(); + SDValue OneSubA = DAG.getNode(ISD::FSUB, DL, VT, DAG.getConstant(1, VT), + Op.getOperand(1)); + SDValue OneSubAC = DAG.getNode(ISD::FMUL, DL, VT, OneSubA, + Op.getOperand(3)); + return DAG.getNode(AMDILISD::MAD, DL, VT, Op.getOperand(1), + Op.getOperand(2), + OneSubAC); +} + void AMDGPUTargetLowering::addLiveIn(MachineInstr * MI, MachineFunction * MF, MachineRegisterInfo & MRI, const TargetInstrInfo * TII, unsigned reg) const diff --git a/src/gallium/drivers/radeon/AMDGPUISelLowering.h b/src/gallium/drivers/radeon/AMDGPUISelLowering.h index e4c778787a2..3e5e81bfef5 100644 --- a/src/gallium/drivers/radeon/AMDGPUISelLowering.h +++ b/src/gallium/drivers/radeon/AMDGPUISelLowering.h @@ -41,6 +41,7 @@ public: virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const; SDValue LowerIntrinsicIABS(SDValue Op, SelectionDAG &DAG) const; + SDValue LowerIntrinsicLRP(SDValue Op, SelectionDAG &DAG) const; virtual const char* getTargetNodeName(unsigned Opcode) const; }; diff --git a/src/gallium/drivers/radeon/R600Instructions.td b/src/gallium/drivers/radeon/R600Instructions.td index df2d56bbde0..459010c7833 100644 --- a/src/gallium/drivers/radeon/R600Instructions.td +++ b/src/gallium/drivers/radeon/R600Instructions.td @@ -672,11 +672,6 @@ class DIV_Common : Pat< (MUL R600_Reg32:$src0, (recip_ieee R600_Reg32:$src1)) >; -class LRP_Common : Pat < - (int_AMDGPU_lrp R600_Reg32:$src0, R600_Reg32:$src1, R600_Reg32:$src2), - (muladd R600_Reg32:$src0, R600_Reg32:$src1, (MUL (SUB_f32 ONE, R600_Reg32:$src0), R600_Reg32:$src2)) ->; - class SSG_Common : Pat < (int_AMDGPU_ssg R600_Reg32:$src), (cndgt R600_Reg32:$src, (f32 ONE), (cndge R600_Reg32:$src, (f32 ZERO), (f32 NEG_ONE))) @@ -725,7 +720,6 @@ let Gen = AMDGPUGen.R600 in { } // End AMDGPUGen.R600 def DIV_r600 : DIV_Common; - def LRP_r600 : LRP_Common; def POW_r600 : POW_Common; def SSG_r600 : SSG_Common; def TGSI_LIT_Z_r600 : TGSI_LIT_Z_Common; @@ -904,7 +898,6 @@ let Gen = AMDGPUGen.EG_CAYMAN in { } // End AMDGPUGen.EG_CAYMAN def DIV_eg : DIV_Common; - def LRP_eg : LRP_Common; def POW_eg : POW_Common; def SSG_eg : SSG_Common; def TGSI_LIT_Z_eg : TGSI_LIT_Z_Common;