diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2016-08-10 19:11:42 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2016-08-10 19:11:42 +0000 |
commit | 57431c9680c8cde0f6cf0e85bed8507b307b080f (patch) | |
tree | 5886987b418c5df95368608f2a1f8ddc03240e07 /llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp | |
parent | b920e9987df2fa99dffa973c66c364b3675e2412 (diff) | |
download | bcm5719-llvm-57431c9680c8cde0f6cf0e85bed8507b307b080f.tar.gz bcm5719-llvm-57431c9680c8cde0f6cf0e85bed8507b307b080f.zip |
AMDGPU: Change insertion point of si_mask_branch
Insert before the skip branch if one is created.
This is a somewhat more natural placement relative
to the skip branches, and makes it possible to implement
analyzeBranch for skip blocks.
The test changes are mostly due to a quirk where
the block label is not emitted if there is a terminator
that is not also a branch.
llvm-svn: 278273
Diffstat (limited to 'llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp')
-rw-r--r-- | llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
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); |