Skip to content

Commit 377996e

Browse files
committed
Fix clobbering value for reg += fi case
1 parent 7897822 commit 377996e

File tree

3 files changed

+97
-92
lines changed

3 files changed

+97
-92
lines changed

llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,12 +2447,17 @@ bool SIRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator MI,
24472447

24482448
// Do an in-place scale of the wave offset to the lane offset.
24492449
if (FrameReg && !ST.enableFlatScratch()) {
2450+
// FIXME: In the common case where the add does not also read its result
2451+
// (i.e. this isn't a reg += fi), it's not finding the dest reg as
2452+
// available.
2453+
Register TmpReg = RS->scavengeRegisterBackwards(
2454+
AMDGPU::SReg_32_XM0RegClass, MI, false, 0);
24502455
BuildMI(*MBB, *MI, DL, TII->get(AMDGPU::S_LSHR_B32))
2451-
.addDef(DstOp.getReg(), RegState::Renamable)
2456+
.addDef(TmpReg, RegState::Renamable)
24522457
.addReg(FrameReg)
24532458
.addImm(ST.getWavefrontSizeLog2())
24542459
.setOperandDead(3); // Set SCC dead
2455-
MaterializedReg = DstOp.getReg();
2460+
MaterializedReg = TmpReg;
24562461
}
24572462

24582463
// If we can't fold the other operand, do another increment.

0 commit comments

Comments
 (0)