[llvm] [VPlan] Use MaxRuntimeStep in materializeVectorTC to simplify middle br. (PR #193067)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 21 04:02:09 PDT 2026


================
@@ -5186,6 +5185,16 @@ void VPlanTransforms::materializeVectorTripCount(VPlan &Plan,
   }
   VPBuilder Builder(VectorPHVPBB, InsertPt);
 
+  // For scalable steps, if TC is a constant and is divisible by the maximum
+  // possible runtime step, then TC % Step == 0 for all valid vscale values
+  // and the vector trip count equals TC directly.
+  const APInt *TCVal;
+  if (!RequiresScalarEpilogue && match(TC, m_APInt(TCVal)) && MaxRuntimeStep &&
----------------
david-arm wrote:

What about when `TC` is itself scalable? Can we cover more cases by doing `SE.getURemExpr(SE.getExpr(TC), SE.getElementCount(VF * IC))->isZero()`? cc @paulwalker-arm

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


More information about the llvm-commits mailing list