[llvm-branch-commits] [llvm-branch] r167124 - in /llvm/branches/R600/lib/Target/AMDGPU: SIISelLowering.cpp SILowerFlowControl.cpp
Tom Stellard
thomas.stellard at amd.com
Wed Oct 31 08:26:11 PDT 2012
Author: tstellar
Date: Wed Oct 31 10:26:11 2012
New Revision: 167124
URL: http://llvm.org/viewvc/llvm-project?rev=167124&view=rev
Log:
SI: Alternative handling of EXEC register for control flow
This version handles the EXEC register being modified in the if/else blocks,
e.g. for pixel discard.
Patch by: Michel Dänzer
Reviewed-by: Tom Stellard <thomas.stellar at amd.com>
Reviewed-by: Christian König <christian.koenig at amd.com>
Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
Modified:
llvm/branches/R600/lib/Target/AMDGPU/SIISelLowering.cpp
llvm/branches/R600/lib/Target/AMDGPU/SILowerFlowControl.cpp
Modified: llvm/branches/R600/lib/Target/AMDGPU/SIISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/R600/lib/Target/AMDGPU/SIISelLowering.cpp?rev=167124&r1=167123&r2=167124&view=diff
==============================================================================
--- llvm/branches/R600/lib/Target/AMDGPU/SIISelLowering.cpp (original)
+++ llvm/branches/R600/lib/Target/AMDGPU/SIISelLowering.cpp Wed Oct 31 10:26:11 2012
@@ -228,26 +228,6 @@
.addReg(AMDGPU::SREG_LIT_0)
.addOperand(MI->getOperand(0));
- // If the exec mask is non-zero, skip the next two instructions
- BuildMI(BB, I, BB.findDebugLoc(I), TII->get(AMDGPU::S_CBRANCH_EXECNZ))
- .addImm(3)
- .addReg(AMDGPU::EXEC);
-
- // Exec mask is zero: Export to NULL target...
- BuildMI(BB, I, BB.findDebugLoc(I), TII->get(AMDGPU::EXP))
- .addImm(0)
- .addImm(0x09) // V_008DFC_SQ_EXP_NULL
- .addImm(0)
- .addImm(1)
- .addImm(1)
- .addReg(AMDGPU::SREG_LIT_0)
- .addReg(AMDGPU::SREG_LIT_0)
- .addReg(AMDGPU::SREG_LIT_0)
- .addReg(AMDGPU::SREG_LIT_0);
-
- // ... and terminate wavefront
- BuildMI(BB, I, BB.findDebugLoc(I), TII->get(AMDGPU::S_ENDPGM));
-
MI->eraseFromParent();
}
Modified: llvm/branches/R600/lib/Target/AMDGPU/SILowerFlowControl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/R600/lib/Target/AMDGPU/SILowerFlowControl.cpp?rev=167124&r1=167123&r2=167124&view=diff
==============================================================================
--- llvm/branches/R600/lib/Target/AMDGPU/SILowerFlowControl.cpp (original)
+++ llvm/branches/R600/lib/Target/AMDGPU/SILowerFlowControl.cpp Wed Oct 31 10:26:11 2012
@@ -50,6 +50,7 @@
#include "AMDGPU.h"
#include "SIInstrInfo.h"
+#include "SIMachineFunctionInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
@@ -117,20 +118,48 @@
AMDGPU::EXEC)
.addOperand(MI.getOperand(0)) // VCC
.addReg(AMDGPU::EXEC);
+ BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDGPU::S_XOR_B64),
+ PredicateStack.back())
+ .addReg(PredicateStack.back())
+ .addReg(AMDGPU::EXEC);
MI.eraseFromParent();
break;
case AMDGPU::ELSE:
- BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDGPU::S_NOT_B64),
- AMDGPU::EXEC)
+ BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDGPU::S_MOV_B64),
+ UnusedRegisters.back())
.addReg(AMDGPU::EXEC);
- BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDGPU::S_AND_B64),
+ BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDGPU::S_MOV_B64),
AMDGPU::EXEC)
- .addReg(PredicateStack.back())
- .addReg(AMDGPU::EXEC);
+ .addReg(PredicateStack.back());
+ BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDGPU::S_MOV_B64),
+ PredicateStack.back())
+ .addReg(UnusedRegisters.back());
MI.eraseFromParent();
break;
case AMDGPU::ENDIF:
popExecMask(MBB, I);
+ if (MF.getInfo<SIMachineFunctionInfo>()->ShaderType == ShaderType::PIXEL &&
+ PredicateStack.empty()) {
+ // If the exec mask is non-zero, skip the next two instructions
+ BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDGPU::S_CBRANCH_EXECNZ))
+ .addImm(3)
+ .addReg(AMDGPU::EXEC);
+
+ // Exec mask is zero: Export to NULL target...
+ BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDGPU::EXP))
+ .addImm(0)
+ .addImm(0x09) // V_008DFC_SQ_EXP_NULL
+ .addImm(0)
+ .addImm(1)
+ .addImm(1)
+ .addReg(AMDGPU::SREG_LIT_0)
+ .addReg(AMDGPU::SREG_LIT_0)
+ .addReg(AMDGPU::SREG_LIT_0)
+ .addReg(AMDGPU::SREG_LIT_0);
+
+ // ... and terminate wavefront
+ BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDGPU::S_ENDPGM));
+ }
MI.eraseFromParent();
break;
}
@@ -156,7 +185,8 @@
unsigned StackReg = PredicateStack.back();
PredicateStack.pop_back();
UnusedRegisters.push_back(StackReg);
- BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDGPU::S_MOV_B64),
+ BuildMI(MBB, I, MBB.findDebugLoc(I), TII->get(AMDGPU::S_OR_B64),
AMDGPU::EXEC)
+ .addReg(AMDGPU::EXEC)
.addReg(StackReg);
}
More information about the llvm-branch-commits
mailing list