-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[RegisterCoalescer]: Try inflated RC for coalescing reg->subreg #134438
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,16 +118,16 @@ MachineRegisterInfo::constrainRegAttrs(Register Reg, | |
| return true; | ||
| } | ||
|
|
||
| bool | ||
| MachineRegisterInfo::recomputeRegClass(Register Reg) { | ||
| const TargetRegisterClass * | ||
| MachineRegisterInfo::getLargestConstrainedSuperClass(Register Reg) const { | ||
| const TargetInstrInfo *TII = MF->getSubtarget().getInstrInfo(); | ||
| const TargetRegisterClass *OldRC = getRegClass(Reg); | ||
| const TargetRegisterInfo *TRI = getTargetRegisterInfo(); | ||
| const TargetRegisterClass *NewRC = TRI->getLargestLegalSuperClass(OldRC, *MF); | ||
|
|
||
| // Stop early if there is no room to grow. | ||
| if (NewRC == OldRC) | ||
| return false; | ||
| return NewRC; | ||
|
|
||
| // Accumulate constraints from all uses. | ||
| for (MachineOperand &MO : reg_nodbg_operands(Reg)) { | ||
|
|
@@ -136,8 +136,16 @@ MachineRegisterInfo::recomputeRegClass(Register Reg) { | |
| unsigned OpNo = &MO - &MI->getOperand(0); | ||
| NewRC = MI->getRegClassConstraintEffect(OpNo, NewRC, TII, TRI); | ||
| if (!NewRC || NewRC == OldRC) | ||
| return false; | ||
| return OldRC; | ||
| } | ||
| return NewRC; | ||
| } | ||
|
|
||
| bool MachineRegisterInfo::recomputeRegClass(Register Reg) { | ||
| const TargetRegisterClass *OldRC = getRegClass(Reg); | ||
| const TargetRegisterClass *NewRC = getLargestConstrainedSuperClass(Reg); | ||
| if (NewRC == OldRC) | ||
| return false; | ||
|
Comment on lines
+147
to
+148
Contributor
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. Is this return value actually useful anywhere? |
||
| setRegClass(Reg, NewRC); | ||
| return true; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -477,7 +477,9 @@ bool CoalescerPair::setRegisters(const MachineInstr *MI) { | |
| Flipped = true; | ||
| } | ||
|
|
||
| const MachineRegisterInfo &MRI = MI->getMF()->getRegInfo(); | ||
| const MachineFunction *MF = MI->getMF(); | ||
|
|
||
| const MachineRegisterInfo &MRI = MF->getRegInfo(); | ||
|
Comment on lines
+480
to
+482
Contributor
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. Probably should just pass this as an argument to setRegisters |
||
| const TargetRegisterClass *SrcRC = MRI.getRegClass(Src); | ||
|
|
||
| if (Dst.isPhysical()) { | ||
|
|
@@ -515,6 +517,12 @@ bool CoalescerPair::setRegisters(const MachineInstr *MI) { | |
| // SrcReg will be merged with a sub-register of DstReg. | ||
| SrcIdx = DstSub; | ||
| NewRC = TRI.getMatchingSuperRegClass(DstRC, SrcRC, DstSub); | ||
| if (!NewRC) { | ||
| auto SuperSrcRC = MRI.getLargestConstrainedSuperClass(Src); | ||
|
Contributor
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. No auto |
||
| if (SuperSrcRC != SrcRC) { | ||
| NewRC = TRI.getMatchingSuperRegClass(DstRC, SuperSrcRC, DstSub); | ||
| } | ||
| } | ||
| } else if (SrcSub) { | ||
| // DstReg will be merged with a sub-register of SrcReg. | ||
| DstIdx = SrcSub; | ||
|
|
||
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix (or remove) the function name in the comment, line 732.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should remove the function name, this hasn't been necessary in doxygen for a long time.
Also should probably name this computeLargestConstrainedSuperClass? It's not simple get