[llvm] [PHIElimination] Handle subranges in LiveInterval updates (PR #69429)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 18 05:31:25 PDT 2023


================
@@ -1294,8 +1296,18 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(
         VNInfo *VNI = LI.getVNInfoAt(PrevIndex);
         assert(VNI && "LiveInterval should have VNInfo where it is live.");
         LI.addSegment(LiveInterval::Segment(StartIndex, EndIndex, VNI));
+        // Update subranges with live values
+        for (auto &SR : LI.subranges()) {
+          VNInfo *VNI = SR.getVNInfoAt(PrevIndex);
+          if (VNI)
+            SR.addSegment(LiveInterval::Segment(StartIndex, EndIndex, VNI));
+        }
       } else if (!isLiveOut && !isLastMBB) {
         LI.removeSegment(StartIndex, EndIndex);
+        for (auto &SR : LI.subranges()) {
+          if (SR.overlaps(StartIndex, EndIndex))
+            SR.removeSegment(StartIndex, EndIndex);
----------------
jayfoad wrote:

Not your fault, but it's a shame that you have to do the `overlaps` check first, because you end up looking up the segment corresponding to StartIndex twice, once in `overlaps` and once in `removeSegment`. It would make more sense to me if `removeSegment` handled the non-overlapping case as a no-op.

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


More information about the llvm-commits mailing list