[llvm] [LV] Vectorize Epilogues for loops with small VF but high IC (PR #108190)

Julian Nagele via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 14 11:14:08 PST 2024


================
@@ -4719,6 +4733,14 @@ VectorizationFactor LoopVectorizationPlanner::selectEpilogueVectorizationFactor(
                "Trip count SCEV must be computable");
         RemainingIterations = SE.getURemExpr(
             TC, SE.getConstant(TCType, MainLoopVF.getKnownMinValue() * IC));
+        const APInt MaxRemainingIterations =
+            SE.getUnsignedRangeMax(RemainingIterations);
+        // Guard against huge trip counts.
+        if (MaxRemainingIterations.getActiveBits() <= 32) {
----------------
juliannagele wrote:

Added `MainLoopVF.getKnownMinValue() * IC - 1` as an upper bound, i.e., only use `RemainingIterations` if it's known to be smaller

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


More information about the llvm-commits mailing list