aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2016-08-10 19:11:42 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2016-08-10 19:11:42 +0000
commit57431c9680c8cde0f6cf0e85bed8507b307b080f (patch)
tree5886987b418c5df95368608f2a1f8ddc03240e07 /llvm/lib/Target
parentb920e9987df2fa99dffa973c66c364b3675e2412 (diff)
downloadllvm-57431c9680c8cde0f6cf0e85bed8507b307b080f.zip
llvm-57431c9680c8cde0f6cf0e85bed8507b307b080f.tar.gz
llvm-57431c9680c8cde0f6cf0e85bed8507b307b080f.tar.bz2
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')
-rw-r--r--llvm/lib/Target/AMDGPU/SIInstructions.td4
-rw-r--r--llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp27
2 files changed, 19 insertions, 12 deletions
diff --git a/llvm/lib/Target/AMDGPU/SIInstructions.td b/llvm/lib/Target/AMDGPU/SIInstructions.td
index f6c2719..bea6149 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 0f9d091..23043ea 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);