Skip to content

Commit 826845f

Browse files
authored
[AMDGPU] Skip debug instructions in SIShrinkInstructions::matchSwap (#160123)
1 parent e6540d2 commit 826845f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,10 +712,13 @@ MachineInstr *SIShrinkInstructions::matchSwap(MachineInstr &MovT) const {
712712
bool KilledT = false;
713713
for (auto Iter = std::next(MovT.getIterator()),
714714
E = MovT.getParent()->instr_end();
715-
Iter != E && Count < SearchLimit && !KilledT; ++Iter, ++Count) {
715+
Iter != E && Count < SearchLimit && !KilledT; ++Iter) {
716716

717717
MachineInstr *MovY = &*Iter;
718718
KilledT = MovY->killsRegister(T, TRI);
719+
if (MovY->isDebugInstr())
720+
continue;
721+
++Count;
719722

720723
if ((MovY->getOpcode() != AMDGPU::V_MOV_B32_e32 &&
721724
MovY->getOpcode() != AMDGPU::V_MOV_B16_t16_e32 &&
@@ -733,6 +736,8 @@ MachineInstr *SIShrinkInstructions::matchSwap(MachineInstr &MovT) const {
733736
MachineInstr *MovX = nullptr;
734737
for (auto IY = MovY->getIterator(), I = std::next(MovT.getIterator());
735738
I != IY; ++I) {
739+
if (I->isDebugInstr())
740+
continue;
736741
if (instReadsReg(&*I, X, Xsub) || instModifiesReg(&*I, Y, Ysub) ||
737742
instModifiesReg(&*I, T, Tsub) ||
738743
(MovX && instModifiesReg(&*I, X, Xsub))) {

llvm/test/CodeGen/AMDGPU/v_swap_b32.mir

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# RUN: llc -simplify-mir -mtriple=amdgcn -mcpu=gfx900 -run-pass=si-shrink-instructions -verify-machineinstrs %s -o - | FileCheck -check-prefix=GCN %s
2+
# RUN: llc -simplify-mir -mtriple=amdgcn -mcpu=gfx900 -run-pass=si-shrink-instructions -verify-machineinstrs %s -o - -debugify-and-strip-all-safe | FileCheck -check-prefix=GCN %s
23
# RUN: llc -simplify-mir -mtriple=amdgcn -mcpu=gfx900 -passes=si-shrink-instructions -verify-machineinstrs %s -o - | FileCheck -check-prefix=GCN %s
34

45
# GCN-LABEL: name: swap_phys_condensed

0 commit comments

Comments
 (0)