AMDGPU: Fix trying to skip from a block with no successors

Found while reducing bug 28550

llvm-svn: 275509
This commit is contained in:
Matt Arsenault 2016-07-15 00:58:13 +00:00
parent 83ab049af2
commit fa5a86a403
2 changed files with 41 additions and 2 deletions

View File

@ -158,6 +158,8 @@ static bool opcodeEmitsNoInsts(unsigned Opc) {
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(MachineInstr &MI, MachineBasicBlock &NextBB)
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::insertSkipBlock(
++MBBI;
MF->insert(MBBI, SkipBB);
MBB.addSuccessor(SkipBB);
return SkipBB;
}

View File

@ -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 }