-
Notifications
You must be signed in to change notification settings - Fork 13.6k
AMDGPU: Update live intervals in convertToThreeAddress #104610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
arsenm
merged 8 commits into
main
from
users/arsenm/issue98741-twoaddr-insts-live-interval-update
Sep 6, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c71c5dd
AMDGPU: Update live intervals in convertToThreeAddress
arsenm 15573e4
Comments
arsenm a332148
Rename variable
arsenm 270f780
Rename variable
arsenm 1fc765d
Remove less
arsenm 7d7a5e6
Add tracksRegLiveness to every function
arsenm 61b61f2
Hackily use shrinkToUses
arsenm 7a56477
Remove unused index argument
arsenm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4059,17 +4059,37 @@ MachineInstr *SIInstrInfo::convertToThreeAddress(MachineInstr &MI, | |
!RI.isSGPRReg(MBB.getParent()->getRegInfo(), Src0->getReg()))) { | ||
MachineInstr *DefMI; | ||
const auto killDef = [&]() -> void { | ||
const MachineRegisterInfo &MRI = MBB.getParent()->getRegInfo(); | ||
MachineRegisterInfo &MRI = MBB.getParent()->getRegInfo(); | ||
// The only user is the instruction which will be killed. | ||
Register DefReg = DefMI->getOperand(0).getReg(); | ||
if (!MRI.hasOneNonDBGUse(DefReg)) | ||
return; | ||
// We cannot just remove the DefMI here, calling pass will crash. | ||
DefMI->setDesc(get(AMDGPU::IMPLICIT_DEF)); | ||
for (unsigned I = DefMI->getNumOperands() - 1; I != 0; --I) | ||
DefMI->removeOperand(I); | ||
if (LV) | ||
LV->getVarInfo(DefReg).AliveBlocks.clear(); | ||
|
||
if (MRI.hasOneNonDBGUse(DefReg)) { | ||
// 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); | ||
if (LV) | ||
LV->getVarInfo(DefReg).AliveBlocks.clear(); | ||
} | ||
|
||
if (LIS) { | ||
LiveInterval &DefLI = LIS->getInterval(DefReg); | ||
|
||
// We cannot delete the original instruction here, so hack out the use | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a test that demonstrates this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is already covered by several tests (the problematic cases were any of the ones with other uses) |
||
// in the original instruction with a dummy register so we can use | ||
// shrinkToUses to deal with any multi-use edge cases. Other targets do | ||
// not have the complexity of deleting a use to consider here. | ||
Register DummyReg = MRI.cloneVirtualRegister(DefReg); | ||
for (MachineOperand &MIOp : MI.uses()) { | ||
if (MIOp.isReg() && MIOp.getReg() == DefReg) { | ||
MIOp.setIsUndef(true); | ||
MIOp.setReg(DummyReg); | ||
} | ||
} | ||
|
||
LIS->shrinkToUses(&DefLI); | ||
} | ||
}; | ||
|
||
int64_t Imm; | ||
|
@@ -4107,6 +4127,7 @@ MachineInstr *SIInstrInfo::convertToThreeAddress(MachineInstr &MI, | |
.add(*Src2) | ||
.setMIFlags(MI.getFlags()); | ||
updateLiveVariables(LV, MI, *MIB); | ||
|
||
if (LIS) | ||
LIS->ReplaceMachineInstrInMaps(MI, *MIB); | ||
killDef(); | ||
|
@@ -4129,6 +4150,7 @@ MachineInstr *SIInstrInfo::convertToThreeAddress(MachineInstr &MI, | |
.add(*Src2) | ||
.setMIFlags(MI.getFlags()); | ||
updateLiveVariables(LV, MI, *MIB); | ||
|
||
if (LIS) | ||
LIS->ReplaceMachineInstrInMaps(MI, *MIB); | ||
if (DefMI) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.