-
Notifications
You must be signed in to change notification settings - Fork 15.2k
RenameIndependentSubregs: try to only implicit def used subregs #167486
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
Changes from 1 commit
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 |
|---|---|---|
|
|
@@ -306,6 +306,7 @@ void RenameIndependentSubregs::computeMainRangesFixFlags( | |
| const IntEqClasses &Classes, | ||
| const SmallVectorImpl<SubRangeInfo> &SubRangeInfos, | ||
| const SmallVectorImpl<LiveInterval*> &Intervals) const { | ||
| const TargetRegisterInfo &TRI = *MRI->getTargetRegisterInfo(); | ||
| BumpPtrAllocator &Allocator = LIS->getVNInfoAllocator(); | ||
| const SlotIndexes &Indexes = *LIS->getSlotIndexes(); | ||
| for (size_t I = 0, E = Intervals.size(); I < E; ++I) { | ||
|
|
@@ -314,6 +315,25 @@ void RenameIndependentSubregs::computeMainRangesFixFlags( | |
|
|
||
| LI.removeEmptySubRanges(); | ||
|
|
||
| // Try to establish a single subregister which covers all uses. | ||
| // Note: this is assuming the selected subregister will only be | ||
| // used for fixing up live intervals issues created by this pass. | ||
| LaneBitmask RegMask = MRI->getMaxLaneMaskForVReg(Reg); | ||
perlfu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| LaneBitmask UsedMask = LaneBitmask::getNone(); | ||
perlfu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| for (LiveInterval::SubRange &SR : LI.subranges()) | ||
| UsedMask |= SR.LaneMask; | ||
| SmallVector<unsigned> SubRegIdxs; | ||
| unsigned Flags = 0; | ||
| unsigned SubReg = 0; | ||
| if (TRI.getCoveringSubRegIndexes(MRI->getRegClass(Reg), UsedMask, | ||
| SubRegIdxs) && | ||
| SubRegIdxs.size() == 1) { | ||
|
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 do this even for the multiple subreg case, but can leave for todo
Contributor
Author
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. I agree it would be nice to handle, but potentially more complex/risky for unknown gain. |
||
| SubReg = SubRegIdxs.front(); | ||
| RegMask = UsedMask; | ||
| Flags = RegState::Undef; | ||
| } | ||
| LaneBitmask UnusedMask = RegMask & ~UsedMask; | ||
|
|
||
| // There must be a def (or live-in) before every use. Splitting vregs may | ||
| // violate this principle as the splitted vreg may not have a definition on | ||
| // every path. Fix this by creating IMPLICIT_DEF instruction as necessary. | ||
|
|
@@ -336,19 +356,18 @@ void RenameIndependentSubregs::computeMainRangesFixFlags( | |
| MachineBasicBlock::iterator InsertPos = | ||
| llvm::findPHICopyInsertPoint(PredMBB, &MBB, Reg); | ||
| const MCInstrDesc &MCDesc = TII->get(TargetOpcode::IMPLICIT_DEF); | ||
| MachineInstrBuilder ImpDef = BuildMI(*PredMBB, InsertPos, | ||
| DebugLoc(), MCDesc, Reg); | ||
| MachineInstrBuilder ImpDef = | ||
| BuildMI(*PredMBB, InsertPos, DebugLoc(), MCDesc) | ||
| .addDef(Reg, Flags, SubReg); | ||
| SlotIndex DefIdx = LIS->InsertMachineInstrInMaps(*ImpDef); | ||
| SlotIndex RegDefIdx = DefIdx.getRegSlot(); | ||
| LaneBitmask Mask = MRI->getMaxLaneMaskForVReg(Reg); | ||
| for (LiveInterval::SubRange &SR : LI.subranges()) { | ||
| Mask = Mask & ~SR.LaneMask; | ||
| VNInfo *SRVNI = SR.getNextValue(RegDefIdx, Allocator); | ||
| SR.addSegment(LiveRange::Segment(RegDefIdx, PredEnd, SRVNI)); | ||
| } | ||
|
|
||
| if (!Mask.none()) { | ||
| LiveInterval::SubRange *SR = LI.createSubRange(Allocator, Mask); | ||
| if (!UnusedMask.none()) { | ||
| LiveInterval::SubRange *SR = | ||
| LI.createSubRange(Allocator, UnusedMask); | ||
| SR->createDeadDef(RegDefIdx, Allocator); | ||
| } | ||
| } | ||
|
|
||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.