[llvm] r275509 - AMDGPU: Fix trying to skip from a block with no successors
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 14 17:58:13 PDT 2016
Author: arsenm
Date: Thu Jul 14 19:58:13 2016
New Revision: 275509
URL: http://llvm.org/viewvc/llvm-project?rev=275509&view=rev
Log:
AMDGPU: Fix trying to skip from a block with no successors
Found while reducing bug 28550
Modified:
llvm/trunk/lib/Target/AMDGPU/SILowerControlFlow.cpp
llvm/trunk/test/CodeGen/AMDGPU/skip-if-dead.ll
Modified: llvm/trunk/lib/Target/AMDGPU/SILowerControlFlow.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SILowerControlFlow.cpp?rev=275509&r1=275508&r2=275509&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SILowerControlFlow.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/SILowerControlFlow.cpp Thu Jul 14 19:58:13 2016
@@ -158,6 +158,8 @@ static bool opcodeEmitsNoInsts(unsigned
bool SILowerControlFlow::shouldSkip(MachineBasicBlock *From,
MachineBasicBlock *To) {
+ if (From->succ_empty())
+ return false;
unsigned NumInstr = 0;
MachineFunction *MF = From->getParent();
@@ -217,7 +219,7 @@ bool SILowerControlFlow::skipIfDead(Mach
return false;
MachineBasicBlock *SkipBB = insertSkipBlock(MBB, MI.getIterator());
- SkipBB->addSuccessor(&NextBB);
+ MBB.addSuccessor(SkipBB);
const DebugLoc &DL = MI.getDebugLoc();
@@ -493,7 +495,6 @@ MachineBasicBlock *SILowerControlFlow::i
++MBBI;
MF->insert(MBBI, SkipBB);
- MBB.addSuccessor(SkipBB);
return SkipBB;
}
Modified: llvm/trunk/test/CodeGen/AMDGPU/skip-if-dead.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/skip-if-dead.ll?rev=275509&r1=275508&r2=275509&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/skip-if-dead.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/skip-if-dead.ll Thu Jul 14 19:58:13 2016
@@ -298,6 +298,44 @@ end:
ret void
}
+; CHECK-LABEL: {{^}}no_skip_no_successors:
+; CHECK: v_cmp_nle_f32
+; CHECK: s_and_b64 vcc, exec,
+; CHECK: s_cbranch_vccz [[SKIPKILL:BB[0-9]+_[0-9]+]]
+
+; CHECK: ; BB#3: ; %bb6
+; CHECK: s_mov_b64 exec, 0
+
+; CHECK: [[SKIPKILL]]:
+; CHECK: v_cmp_nge_f32
+; CHECK: s_and_b64 vcc, exec, vcc
+; CHECK: s_cbranch_vccz [[UNREACHABLE:BB[0-9]+_[0-9]+]]
+
+; CHECK: [[UNREACHABLE]]:
+; CHECK-NEXT: .Lfunc_end{{[0-9]+}}
+define amdgpu_ps void @no_skip_no_successors(float inreg %arg, float inreg %arg1) #0 {
+bb:
+ %tmp = fcmp ult float %arg1, 0.000000e+00
+ %tmp2 = fcmp ult float %arg, 0x3FCF5C2900000000
+ br i1 %tmp, label %bb6, label %bb3
+
+bb3: ; preds = %bb
+ br i1 %tmp2, label %bb5, label %bb4
+
+bb4: ; preds = %bb3
+ br i1 true, label %bb5, label %bb7
+
+bb5: ; preds = %bb4, %bb3
+ unreachable
+
+bb6: ; preds = %bb
+ call void @llvm.AMDGPU.kill(float -1.000000e+00)
+ unreachable
+
+bb7: ; preds = %bb4
+ ret void
+}
+
declare void @llvm.AMDGPU.kill(float) #0
attributes #0 = { nounwind }
More information about the llvm-commits
mailing list