Skip to content

Commit e38f98f

Browse files
authored
[AMDGPU][Scheduler] Fix usage of TII.reMaterialize (NFC) (llvm#150259)
Any non-zero `SubIdx` passed to the method is composed with the rematerialized instruction's first operand's subregister to determine the new register's subregister. In our case we want the new register to have the same subregister as the old one, so we should pass 0.
1 parent 7392131 commit e38f98f

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,14 +1911,12 @@ void PreRARematStage::rematerialize() {
19111911
for (auto &[DefMI, Remat] : Rematerializations) {
19121912
MachineBasicBlock::iterator InsertPos(Remat.UseMI);
19131913
Register Reg = DefMI->getOperand(0).getReg();
1914-
unsigned SubReg = DefMI->getOperand(0).getSubReg();
19151914
unsigned DefRegion = MIRegion.at(DefMI);
19161915

19171916
// Rematerialize DefMI to its use block.
1918-
TII->reMaterialize(*InsertPos->getParent(), InsertPos, Reg, SubReg, *DefMI,
1917+
TII->reMaterialize(*InsertPos->getParent(), InsertPos, Reg, 0, *DefMI,
19191918
*DAG.TRI);
19201919
Remat.RematMI = &*std::prev(InsertPos);
1921-
Remat.RematMI->getOperand(0).setSubReg(SubReg);
19221920
DAG.LIS->InsertMachineInstrInMaps(*Remat.RematMI);
19231921

19241922
// Update region boundaries in regions we sinked from (remove defining MI)
@@ -2064,14 +2062,12 @@ void PreRARematStage::finalizeGCNSchedStage() {
20642062
MachineBasicBlock::iterator InsertPos(DAG.Regions[DefRegion].second);
20652063
MachineBasicBlock *MBB = RegionBB[DefRegion];
20662064
Register Reg = RematMI.getOperand(0).getReg();
2067-
unsigned SubReg = RematMI.getOperand(0).getSubReg();
20682065

20692066
// Re-rematerialize MI at the end of its original region. Note that it may
20702067
// not be rematerialized exactly in the same position as originally within
20712068
// the region, but it should not matter much.
2072-
TII->reMaterialize(*MBB, InsertPos, Reg, SubReg, RematMI, *DAG.TRI);
2069+
TII->reMaterialize(*MBB, InsertPos, Reg, 0, RematMI, *DAG.TRI);
20732070
MachineInstr *NewMI = &*std::prev(InsertPos);
2074-
NewMI->getOperand(0).setSubReg(SubReg);
20752071
DAG.LIS->InsertMachineInstrInMaps(*NewMI);
20762072

20772073
auto UseRegion = MIRegion.find(Remat.UseMI);

0 commit comments

Comments
 (0)