[llvm] [VPlan] Simplify branch-cond with getVectorTripCount (PR #155604)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 8 03:19:32 PDT 2025


================
@@ -1483,14 +1483,15 @@ static bool simplifyBranchConditionForVFAndUF(VPlan &Plan, ElementCount BestVF,
     // Try to simplify the branch condition if TC <= VF * UF when the latch
     // terminator is   BranchOnCount or BranchOnCond where the input is
     // Not(ActiveLaneMask).
-    const SCEV *TripCount =
-        vputils::getSCEVExprForVPValue(Plan.getTripCount(), SE);
-    assert(!isa<SCEVCouldNotCompute>(TripCount) &&
+    const SCEV *VectorTripCount =
+        vputils::getSCEVExprForVPValue(&Plan.getVectorTripCount(), SE);
+    if (isa<SCEVCouldNotCompute>(VectorTripCount))
+      VectorTripCount = vputils::getSCEVExprForVPValue(Plan.getTripCount(), SE);
+    assert(!isa<SCEVCouldNotCompute>(VectorTripCount) &&
----------------
lukel97 wrote:

Does falling back to the scalar trip count do anything? If we remove it does it affect the tests?

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


More information about the llvm-commits mailing list