Skip to content

Commit 9088c54

Browse files
committed
Fix clobbering value for reg += fi case
1 parent 9eb7278 commit 9088c54

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
@@ -2283,12 +2283,17 @@ bool SIRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator MI,
22832283

22842284
// Do an in-place scale of the wave offset to the lane offset.
22852285
if (FrameReg && !ST.enableFlatScratch()) {
2286+
// FIXME: In the common case where the add does not also read its result
2287+
// (i.e. this isn't a reg += fi), it's not finding the dest reg as
2288+
// available.
2289+
Register TmpReg = RS->scavengeRegisterBackwards(
2290+
AMDGPU::SReg_32_XM0RegClass, MI, false, 0);
22862291
BuildMI(*MBB, *MI, DL, TII->get(AMDGPU::S_LSHR_B32))
2287-
.addDef(DstOp.getReg(), RegState::Renamable)
2292+
.addDef(TmpReg, RegState::Renamable)
22882293
.addReg(FrameReg)
22892294
.addImm(ST.getWavefrontSizeLog2())
22902295
.setOperandDead(3); // Set SCC dead
2291-
MaterializedReg = DstOp.getReg();
2296+
MaterializedReg = TmpReg;
22922297
}
22932298

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

0 commit comments

Comments
 (0)