[llvm] RegAllocGreedy: Check if copied lanes are live in trySplitAroundHintReg (PR #160424)

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 2 04:18:44 PDT 2025


================
@@ -1406,8 +1406,28 @@ bool RAGreedy::trySplitAroundHintReg(MCPhysReg Hint,
       continue;
 
     // Check if VirtReg interferes with OtherReg after this COPY instruction.
-    if (!IsDef && VirtReg.liveAt(LIS->getInstructionIndex(Instr).getRegSlot()))
-      continue;
+    if (Opnd.readsReg()) {
+      SlotIndex Index = LIS->getInstructionIndex(Instr).getRegSlot();
+
+      if (SubReg) {
+        LaneBitmask Mask = TRI->getSubRegIndexLaneMask(SubReg);
+        if (IsDef)
+          Mask = ~Mask;
+
+        if (any_of(VirtReg.subranges(), [=](const LiveInterval::SubRange &S) {
+              if ((S.LaneMask & Mask).any()) {
+                if (S.liveAt(Index))
+                  return true;
+              }
+              return false;
----------------
qcolombet wrote:

Nit
```
return (S.LaneMask & Mask).any() && S.liveAt(Index);
```

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


More information about the llvm-commits mailing list