[PATCH] D22386: 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 15:20:25 PDT 2016
arsenm created this revision.
arsenm added a reviewer: tstellarAMD.
arsenm added a subscriber: llvm-commits.
Herald added subscribers: kzhuravl, arsenm.
Found while reducing bug 28550
https://reviews.llvm.org/D22386
Files:
lib/Target/AMDGPU/SILowerControlFlow.cpp
test/CodeGen/AMDGPU/skip-if-dead.ll
Index: test/CodeGen/AMDGPU/skip-if-dead.ll
===================================================================
--- test/CodeGen/AMDGPU/skip-if-dead.ll
+++ test/CodeGen/AMDGPU/skip-if-dead.ll
@@ -298,6 +298,44 @@
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 }
Index: lib/Target/AMDGPU/SILowerControlFlow.cpp
===================================================================
--- lib/Target/AMDGPU/SILowerControlFlow.cpp
+++ lib/Target/AMDGPU/SILowerControlFlow.cpp
@@ -158,6 +158,8 @@
bool SILowerControlFlow::shouldSkip(MachineBasicBlock *From,
MachineBasicBlock *To) {
+ if (From->succ_empty())
+ return false;
unsigned NumInstr = 0;
MachineFunction *MF = From->getParent();
@@ -217,7 +219,7 @@
return false;
MachineBasicBlock *SkipBB = insertSkipBlock(MBB, MI.getIterator());
- SkipBB->addSuccessor(&NextBB);
+ MBB.addSuccessor(SkipBB);
const DebugLoc &DL = MI.getDebugLoc();
@@ -493,7 +495,6 @@
++MBBI;
MF->insert(MBBI, SkipBB);
- MBB.addSuccessor(SkipBB);
return SkipBB;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22386.64054.patch
Type: text/x-patch
Size: 2270 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160714/deebc1f6/attachment.bin>
More information about the llvm-commits
mailing list