Skip to content

Commit cd40070

Browse files
authored
[RegisterPressure] NFC: Clean up RP handling for instructions with overlapping Def/Use (#109875)
The current RP handling for uses of an MI that overlap with defs is confusing and unnecessary. Moreover, the lane masks do not accurately model the liveness behavior of the subregs. This cleans things up a bit and more accurately models subreg lane liveness by sinking the use handling into subsent Uses loop. The effect of this PR is to replace A. `increaseRegPressure(Reg, LiveAfter, ~LiveAfter & LiveBefore)` with B. `increaseRegPressure(Reg, LiveAfter, LiveBefore)` Note that A (Defs loop) and B (Uses loop) have different definitions of LiveBefore A. `LiveBefore = (LiveAfter & ~DefLanes) | UseLanes` and B. `LiveBefore = LiveAfter | UseLanes` Also note, `increaseRegPressure` will exit if `PrevMask` (`LiveAfter` for both A/B) has any active lanes, thus these calls will only have an effect if `LiveAfter` is 0. A. NewMask = ~LiveAfter & ((LiveAfter & ~DefLanes) | UseLanes) => (1 & UseLanes) => UseLanes = (0 | UseLanes) => (LiveAfter | UseLanes) = NewMask B.
1 parent 55c70f6 commit cd40070

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

llvm/lib/CodeGen/RegisterPressure.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,18 +1060,12 @@ void RegPressureTracker::bumpUpwardPressure(const MachineInstr *MI) {
10601060
LaneBitmask LiveBefore = (LiveAfter & ~DefLanes) | UseLanes;
10611061

10621062
// There may be parts of the register that were dead before the
1063-
// instruction, but became live afterwards. Similarly, some parts
1064-
// may have been killed in this instruction.
1063+
// instruction, but became live afterwards.
10651064
decreaseRegPressure(Reg, LiveAfter, LiveAfter & LiveBefore);
1066-
increaseRegPressure(Reg, LiveAfter, ~LiveAfter & LiveBefore);
10671065
}
1068-
// Generate liveness for uses.
1066+
// Generate liveness for uses. Also handle any uses which overlap with defs.
10691067
for (const RegisterMaskPair &P : RegOpers.Uses) {
10701068
Register Reg = P.RegUnit;
1071-
// If this register was also in a def operand, we've handled it
1072-
// with defs.
1073-
if (getRegLanes(RegOpers.Defs, Reg).any())
1074-
continue;
10751069
LaneBitmask LiveAfter = LiveRegs.contains(Reg);
10761070
LaneBitmask LiveBefore = LiveAfter | P.LaneMask;
10771071
increaseRegPressure(Reg, LiveAfter, LiveBefore);

0 commit comments

Comments
 (0)