[llvm] [VPlan] Materialize constant vector trip counts before final opts. (PR #142309)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 27 14:57:16 PDT 2025


================
@@ -10320,6 +10321,25 @@ bool LoopVectorizePass::processLoop(Loop *L) {
         InnerLoopVectorizer LB(L, PSE, LI, DT, TLI, TTI, AC, ORE, VF.Width,
                                VF.MinProfitableTripCount, IC, &CM, BFI, PSI,
                                Checks, BestPlan);
+
+        // Materialize vector trip counts for constants early if it can simply
+        // be computed as (Original TC / VF * UF) * VF * UF.
----------------
fhahn wrote:

> Can this be a VPlanTransform, perhaps part of optimizeForVFAndUF()? In any case worth outlining.

Yep, moved to a separate transform; for now it must be separate and run here, as more work will be needed to make it work with epilogue vectorization.

> Should requiresScalarEpilogue be known to VPlan, as a step towards modeling the epilog in VPlan along with the main loop?

We can check if middle.block unconditionally branches to scalar.ph. Updated, thanks

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


More information about the llvm-commits mailing list