[llvm] AMDGPU: Update live intervals in convertToThreeAddress (PR #104610)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 06:05:39 PDT 2024
================
@@ -3947,14 +3947,32 @@ MachineInstr *SIInstrInfo::convertToThreeAddress(MachineInstr &MI,
(ST.getConstantBusLimit(Opc) > 1 || !Src0->isReg() ||
!RI.isSGPRReg(MBB.getParent()->getRegInfo(), Src0->getReg()))) {
MachineInstr *DefMI;
- const auto killDef = [&]() -> void {
+ const auto killDef = [&](SlotIndex NewIdx) -> void {
const MachineRegisterInfo &MRI = MBB.getParent()->getRegInfo();
// The only user is the instruction which will be killed.
Register DefReg = DefMI->getOperand(0).getReg();
+
+ if (LIS) {
+ LiveInterval &DefLI = LIS->getInterval(DefReg);
+ LiveRange::Segment *OldSeg = DefLI.getSegmentContaining(NewIdx);
+
+ if (OldSeg->end == NewIdx.getRegSlot()) {
+ DefLI.removeSegment(OldSeg->start, NewIdx.getRegSlot(), true);
+
+ for (auto &SR : DefLI.subranges()) {
+ LiveRange::Segment *OldSegSR = SR.getSegmentContaining(NewIdx);
+ SR.removeSegment(OldSegSR->start, NewIdx.getRegSlot(), true);
+ }
+
+ DefLI.removeEmptySubRanges();
+ }
+ }
+
if (!MRI.hasOneNonDBGUse(DefReg))
return;
// We cannot just remove the DefMI here, calling pass will crash.
DefMI->setDesc(get(AMDGPU::IMPLICIT_DEF));
+ DefMI->getOperand(0).setIsDead(true);
for (unsigned I = DefMI->getNumOperands() - 1; I != 0; --I)
DefMI->removeOperand(I);
----------------
arsenm wrote:
The operand this should be removing is exec, so no. In principle there could be other implicit use operands, but they add a lot of complexity for no reason so I would hope movs with implicit operands would have been rejected as fold candidates
https://github.com/llvm/llvm-project/pull/104610
More information about the llvm-commits
mailing list