[llvm] RenameIndependentSubregs: try to only implicit def used subregs (PR #167486)

Carl Ritson via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 18 16:49:26 PST 2025


================
@@ -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);
+    LaneBitmask UsedMask = LaneBitmask::getNone();
+    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) {
----------------
perlfu wrote:

I agree it would be nice to handle, but potentially more complex/risky for unknown gain.
I will look at it is as a follow up.
I have added a comment to that effect.

https://github.com/llvm/llvm-project/pull/167486


More information about the llvm-commits mailing list