[Mesa-dev] [PATCH 4/9] radeon/llvm: improve ABS_i32 lowering
Vadim Girlin
vadimgirlin at gmail.com
Tue May 15 02:41:29 PDT 2012
We can save one instruction by lowering it to:
SUB_INT tmp, 0, src
MAX_INT dst, src, tmp
Signed-off-by: Vadim Girlin <vadimgirlin at gmail.com>
---
src/gallium/drivers/radeon/R600LowerInstructions.cpp | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/src/gallium/drivers/radeon/R600LowerInstructions.cpp b/src/gallium/drivers/radeon/R600LowerInstructions.cpp
index 41bf365..42c9766 100644
--- a/src/gallium/drivers/radeon/R600LowerInstructions.cpp
+++ b/src/gallium/drivers/radeon/R600LowerInstructions.cpp
@@ -90,24 +90,16 @@ bool R600LowerInstructionsPass::runOnMachineFunction(MachineFunction &MF)
case AMDIL::ABS_i32:
{
- unsigned setgt = MRI->createVirtualRegister(
+ unsigned neg = MRI->createVirtualRegister(
&AMDIL::R600_TReg32RegClass);
- BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDIL::SETGE_INT),
- setgt)
+ BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDIL::SUB_INT),neg)
.addReg(AMDIL::ZERO)
.addOperand(MI.getOperand(1));
- unsigned add_int = MRI->createVirtualRegister(
- &AMDIL::R600_TReg32RegClass);
- BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDIL::ADD_INT),
- add_int)
- .addReg(setgt)
- .addOperand(MI.getOperand(1));
-
- BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDIL::XOR_INT))
+ BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDIL::MAX_INT))
.addOperand(MI.getOperand(0))
- .addReg(setgt)
- .addReg(add_int);
+ .addOperand(MI.getOperand(1))
+ .addReg(neg);
break;
}
--
1.7.10.1
More information about the mesa-dev
mailing list