[llvm] 02429c4 - [LV] Fix strict weak ordering violation in handleUncountableEarlyExits sort (#181462)

via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 14 21:05:44 PST 2026


Author: Brian Cain
Date: 2026-02-14T23:05:39-06:00
New Revision: 02429c46330fca6d057684aa05e1efd813fe0de3

URL: https://github.com/llvm/llvm-project/commit/02429c46330fca6d057684aa05e1efd813fe0de3
DIFF: https://github.com/llvm/llvm-project/commit/02429c46330fca6d057684aa05e1efd813fe0de3.diff

LOG: [LV] Fix strict weak ordering violation in handleUncountableEarlyExits sort (#181462)

The sort comparator used VPDT.dominates() which returns true for
dominates(A, A), violating the irreflexivity requirement of strict weak
ordering. With _GLIBCXX_DEBUG enabled (LLVM_ENABLE_EXPENSIVE_CHECKS=ON),
std::sort validates this property and aborts:

Error: comparison doesn't meet irreflexive requirements, assert(!(a <
a)).

Use properlyDominates() instead, which correctly returns false for equal
inputs while preserving the intended dominance-based ordering.

This fixes a crash introduced by ede1a9626b89 ("[LV] Vectorize early
exit loops with multiple exits.").

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index da3afe7ce6d03..0d713a6dc4e47 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -4080,7 +4080,7 @@ void VPlanTransforms::handleUncountableEarlyExits(VPlan &Plan,
   assert(!Exits.empty() && "must have at least one early exit");
   // Sort exits by dominance to get the correct program order.
   llvm::sort(Exits, [&VPDT](const EarlyExitInfo &A, const EarlyExitInfo &B) {
-    return VPDT.dominates(A.EarlyExitingVPBB, B.EarlyExitingVPBB);
+    return VPDT.properlyDominates(A.EarlyExitingVPBB, B.EarlyExitingVPBB);
   });
 
   // Build the AnyOf condition for the latch terminator using logical OR


        


More information about the llvm-commits mailing list