[llvm] 7699949 - CodeGen: Check subrange liveness directly when trimming split edges (#228055)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 1 06:56:43 PDT 2026


Author: Matt Arsenault
Date: 2026-10-01T15:56:35+02:00
New Revision: 76999494a553fc0aa6b06f99c77461cf134ee8d1

URL: https://github.com/llvm/llvm-project/commit/76999494a553fc0aa6b06f99c77461cf134ee8d1
DIFF: https://github.com/llvm/llvm-project/commit/76999494a553fc0aa6b06f99c77461cf134ee8d1.diff

LOG: CodeGen: Check subrange liveness directly when trimming split edges (#228055)

SplitCriticalEdge trims the stale extension of a live range into the newly created 
block. The subrange guard used overlaps(StartIndex, EndIndex), which only 
happens to be equivalent to the containment removeSegment requires. 
StartIndex is an index created for the new block, and EndIndex is the block end
index the live-out segments already end at, so no pre-existing segment endpoint
falls between them.

Check liveAt(PrevIndex) instead, mirroring the same condition on the main range.

Co-authored-by: Claude Opus 5 <noreply at anthropic.com>

Added: 
    

Modified: 
    llvm/lib/CodeGen/MachineBasicBlock.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index 006a9fcb02bf4..4cd6afed26405 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -1385,8 +1385,10 @@ MachineBasicBlock *MachineBasicBlock::SplitCriticalEdge(
         }
       } else if (!isLiveOut && !isLastMBB) {
         LI.removeSegment(StartIndex, EndIndex);
+        // The main range is live across NMBB, but an individual lane need not
+        // be.
         for (auto &SR : LI.subranges()) {
-          if (SR.overlaps(StartIndex, EndIndex))
+          if (SR.liveAt(PrevIndex))
             SR.removeSegment(StartIndex, EndIndex);
         }
       }


        


More information about the llvm-commits mailing list