Skip to content

Commit beec732

Browse files
perlfumemfrob
authored andcommitted
[AMDGPU] Only remove branches in SIInstrInfo::removeBranch
Without this change _term instructions can be removed during critical edge splitting. Reviewed By: foad Differential Revision: https://reviews.llvm.org/D111126
1 parent 1b56480 commit beec732

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

llvm/lib/Target/AMDGPU/SIInstrInfo.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,9 +2460,12 @@ unsigned SIInstrInfo::removeBranch(MachineBasicBlock &MBB,
24602460
unsigned RemovedSize = 0;
24612461
while (I != MBB.end()) {
24622462
MachineBasicBlock::iterator Next = std::next(I);
2463-
RemovedSize += getInstSizeInBytes(*I);
2464-
I->eraseFromParent();
2465-
++Count;
2463+
// Skip over artificial terminators when removing instructions.
2464+
if (I->isBranch() || I->isReturn()) {
2465+
RemovedSize += getInstSizeInBytes(*I);
2466+
I->eraseFromParent();
2467+
++Count;
2468+
}
24662469
I = Next;
24672470
}
24682471

llvm/test/CodeGen/AMDGPU/artificial-terminators.mir

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ body: |
3838
; CHECK-NEXT: {{ $}}
3939
; CHECK-NEXT: [[V_CMP_LT_I32_e64_:%[0-9]+]]:sreg_32 = V_CMP_LT_I32_e64 [[V_ADD_U32_e64_3]], [[S_MOV_B32_1]], implicit $exec
4040
; CHECK-NEXT: [[S_XOR_B32_:%[0-9]+]]:sreg_32 = S_XOR_B32 $exec_lo, [[V_CMP_LT_I32_e64_]], implicit-def $scc
41+
; CHECK-NEXT: $exec_lo = S_MOV_B32_term [[S_XOR_B32_]]
4142
; CHECK-NEXT: S_CBRANCH_EXECNZ %bb.2, implicit $exec
4243
; CHECK-NEXT: {{ $}}
4344
; CHECK-NEXT: bb.5:

0 commit comments

Comments
 (0)