[llvm] [VirtRegMap] Remove unsupported sub-registers during rewrite (PR #201550)
Igor Wodiany via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 15 05:16:57 PDT 2026
================
@@ -642,6 +642,22 @@ LaneBitmask VirtRegRewriter::liveOutUndefPhiLanesForUndefSubregDef(
LRM->checkInterferenceLanes(BeforeMIUses, MIIndex.getRegSlot(), PhysReg);
LiveOutUndefLanes &= ~InterferingLanes;
+ // LiveOutUndefLanes may contain lanes that are part of the
+ // register (e.g. sub1) but not independently addressable by any
+ // sub-register index valid on this class (e.g. hi16), since
+ // lane masks are numbered globally across classes. Such lanes
+ // do not need to become separate implicit defs, so drop them.
+ const TargetRegisterClass *RC = MRI->getRegClass(LI.reg());
+ LaneBitmask NewLiveOutUndefLanes;
+ for (unsigned Idx = 1, E = TRI->getNumSubRegIndices(); Idx < E; ++Idx) {
----------------
IgWod wrote:
> Is the problem that ~TRI->getSubRegIndexLaneMask(SubReg) introduced the false lane dependency?
Not really. For `sub0` (`0x3`) it returns all lanes that can be live out, in this case `0xfff...fc`, so it doesn't really help with `sub1`. It looks like the root cause is `checkInterferenceLanes` not considering `hi16` part of `sub1`. Once remove the `hi16` is not addressable but it still should be considered for interference. I don't see any generic way to fix before interference quaery in VirtRegMap.
However I think I managed to trace the root cause (with a help of AI) to how lane masks are computed. It seems the code assumes that a reg is always covered by its subregs, but once `hi16` is removed that's no longer a case. I have opened an alternative PR https://github.com/llvm/llvm-project/pull/223653. With that new change `sub0`, `sub1` will all have correct lanes in (`0x3`, `0xC`) even when `hi16` is not addressable. If that works we can abandon this PR.
https://github.com/llvm/llvm-project/pull/201550
More information about the llvm-commits
mailing list