From: Tom Stellard Date: Thu, 17 May 2012 16:08:21 +0000 (-0400) Subject: radeon/llvm: Move lowering of ABS_i32 to ISel X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9a020092aedc6310d5bfc72b2aa6fc4348fe5c32;p=mesa.git radeon/llvm: Move lowering of ABS_i32 to ISel --- diff --git a/src/gallium/drivers/radeon/AMDGPUISelLowering.cpp b/src/gallium/drivers/radeon/AMDGPUISelLowering.cpp index 9d1042e8164..921daa69dce 100644 --- a/src/gallium/drivers/radeon/AMDGPUISelLowering.cpp +++ b/src/gallium/drivers/radeon/AMDGPUISelLowering.cpp @@ -43,6 +43,8 @@ SDValue AMDGPUTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, switch (IntrinsicID) { default: return Op; + case AMDGPUIntrinsic::AMDIL_abs: + return LowerIntrinsicIABS(Op, DAG); case AMDGPUIntrinsic::AMDIL_max: return DAG.getNode(AMDGPUISD::FMAX, DL, VT, Op.getOperand(1), Op.getOperand(2)); @@ -55,6 +57,19 @@ SDValue AMDGPUTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, } } +///IABS(a) = SMAX(sub(0, a), a) +SDValue AMDGPUTargetLowering::LowerIntrinsicIABS(SDValue Op, + SelectionDAG &DAG) const +{ + + DebugLoc DL = Op.getDebugLoc(); + EVT VT = Op.getValueType(); + SDValue Neg = DAG.getNode(ISD::SUB, DL, VT, DAG.getConstant(0, VT), + Op.getOperand(1)); + + return DAG.getNode(AMDGPUISD::SMAX, DL, VT, Neg, Op.getOperand(1)); +} + 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 b67f30bc976..e4c778787a2 100644 --- a/src/gallium/drivers/radeon/AMDGPUISelLowering.h +++ b/src/gallium/drivers/radeon/AMDGPUISelLowering.h @@ -40,6 +40,7 @@ public: AMDGPUTargetLowering(TargetMachine &TM); virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const; + SDValue LowerIntrinsicIABS(SDValue Op, SelectionDAG &DAG) const; virtual const char* getTargetNodeName(unsigned Opcode) const; }; diff --git a/src/gallium/drivers/radeon/AMDILInstructions.td b/src/gallium/drivers/radeon/AMDILInstructions.td index f03ec6bd900..3ee783696d8 100644 --- a/src/gallium/drivers/radeon/AMDILInstructions.td +++ b/src/gallium/drivers/radeon/AMDILInstructions.td @@ -92,7 +92,6 @@ def ADDri : TwoInOneOut; defm IFFB_LO : UnaryOpMCi32; let mayLoad = 0, mayStore = 0 in { -defm ABS : UnaryIntrinsicInt; defm BITCOUNT : UnaryIntrinsicInt; defm FFB_LO : UnaryIntrinsicInt; defm FFB_HI : UnaryIntrinsicInt; diff --git a/src/gallium/drivers/radeon/R600LowerInstructions.cpp b/src/gallium/drivers/radeon/R600LowerInstructions.cpp index 42c976601e5..2edae320c29 100644 --- a/src/gallium/drivers/radeon/R600LowerInstructions.cpp +++ b/src/gallium/drivers/radeon/R600LowerInstructions.cpp @@ -88,22 +88,6 @@ bool R600LowerInstructionsPass::runOnMachineFunction(MachineFunction &MF) .addOperand(MI.getOperand(1)); break; - case AMDIL::ABS_i32: - { - unsigned neg = MRI->createVirtualRegister( - &AMDIL::R600_TReg32RegClass); - BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDIL::SUB_INT),neg) - .addReg(AMDIL::ZERO) - .addOperand(MI.getOperand(1)); - - BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDIL::MAX_INT)) - .addOperand(MI.getOperand(0)) - .addOperand(MI.getOperand(1)) - .addReg(neg); - - break; - } - /* XXX: We could propagate the ABS flag to all of the uses of Operand0 and * remove the ABS instruction.*/ case AMDIL::FABS_f32: