diff options
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r-- | llvm/lib/Target/AMDGPU/SIInstructions.td | 4 | ||||
-rw-r--r-- | llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp | 27 |
2 files changed, 19 insertions, 12 deletions
diff --git a/llvm/lib/Target/AMDGPU/SIInstructions.td b/llvm/lib/Target/AMDGPU/SIInstructions.td index f6c2719dd84..bea61493812 100644 --- a/llvm/lib/Target/AMDGPU/SIInstructions.td +++ b/llvm/lib/Target/AMDGPU/SIInstructions.td @@ -1777,9 +1777,9 @@ let hasSideEffects = 1 in { // replaced with exec mask operations. def SI_MASK_BRANCH : PseudoInstSI < (outs), (ins brtarget:$target, SReg_64:$dst)> { - let isBranch = 1; + let isBranch = 0; let isTerminator = 1; - let isBarrier = 1; + let isBarrier = 0; let SALU = 1; } diff --git a/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp b/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp index 0f9d0917fb7..23043ea0d9d 100644 --- a/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp +++ b/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp @@ -80,7 +80,7 @@ private: bool shouldSkip(MachineBasicBlock *From, MachineBasicBlock *To); - void Skip(MachineInstr &From, MachineOperand &To); + MachineInstr *Skip(MachineInstr &From, MachineOperand &To); bool skipIfDead(MachineInstr &MI, MachineBasicBlock &NextBB); void If(MachineInstr &MI); @@ -182,14 +182,15 @@ bool SILowerControlFlow::shouldSkip(MachineBasicBlock *From, return false; } -void SILowerControlFlow::Skip(MachineInstr &From, MachineOperand &To) { - +MachineInstr *SILowerControlFlow::Skip(MachineInstr &From, MachineOperand &To) { if (!shouldSkip(*From.getParent()->succ_begin(), To.getMBB())) - return; + return nullptr; - DebugLoc DL = From.getDebugLoc(); - BuildMI(*From.getParent(), &From, DL, TII->get(AMDGPU::S_CBRANCH_EXECZ)) + const DebugLoc &DL = From.getDebugLoc(); + MachineInstr *Skip = + BuildMI(*From.getParent(), &From, DL, TII->get(AMDGPU::S_CBRANCH_EXECZ)) .addOperand(To); + return Skip; } bool SILowerControlFlow::skipIfDead(MachineInstr &MI, MachineBasicBlock &NextBB) { @@ -242,10 +243,13 @@ void SILowerControlFlow::If(MachineInstr &MI) { .addReg(AMDGPU::EXEC) .addReg(Reg); - Skip(MI, MI.getOperand(2)); + MachineInstr *SkipInst = Skip(MI, MI.getOperand(2)); + + // Insert before the new branch instruction. + MachineInstr *InsPt = SkipInst ? SkipInst : &MI; // Insert a pseudo terminator to help keep the verifier happy. - BuildMI(MBB, &MI, DL, TII->get(AMDGPU::SI_MASK_BRANCH)) + BuildMI(MBB, InsPt, DL, TII->get(AMDGPU::SI_MASK_BRANCH)) .addOperand(MI.getOperand(2)) .addReg(Reg); @@ -275,10 +279,13 @@ void SILowerControlFlow::Else(MachineInstr &MI) { .addReg(AMDGPU::EXEC) .addReg(Dst); - Skip(MI, MI.getOperand(2)); + MachineInstr *SkipInst = Skip(MI, MI.getOperand(2)); + + // Insert before the new branch instruction. + MachineInstr *InsPt = SkipInst ? SkipInst : &MI; // Insert a pseudo terminator to help keep the verifier happy. - BuildMI(MBB, &MI, DL, TII->get(AMDGPU::SI_MASK_BRANCH)) + BuildMI(MBB, InsPt, DL, TII->get(AMDGPU::SI_MASK_BRANCH)) .addOperand(MI.getOperand(2)) .addReg(Dst); |