[llvm] LV]: consider scalable VF during deciding dead epilogue. (PR #156724)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 17 01:20:12 PST 2025


================
@@ -4425,11 +4430,19 @@ VectorizationFactor LoopVectorizationPlanner::selectEpilogueVectorizationFactor(
 
     // If NextVF is greater than the number of remaining iterations, the
     // epilogue loop would be dead. Skip such factors.
-    if (RemainingIterations && !NextVF.Width.isScalable()) {
-      if (SE.isKnownPredicate(
-              CmpInst::ICMP_UGT,
-              SE.getConstant(TCType, NextVF.Width.getFixedValue()),
-              RemainingIterations))
+    // TODO: We should also consider comparing against scalable RemIter when
+    // SCEV be able to evaluate non-canonical vscale-based expressions.
+    if (!ScalableRemIter) {
+      // Handle the case where NextVF and RemainingIterations are in different
+      // numerical spaces.
+      if (NextVF.Width.isScalable()) {
----------------
david-arm wrote:

nit: You might be able to simplify this and reduce the level of nesting by doing something like:

```
  ElementCount EC = NextVF.Width;
  if (NextVF.Width.isScalable())
    EC = ElementCount::getFixed(estimateElementCount(NextVF.Width, CM.getVScaleForTuning()));
  if (SkipVF(SE.getElementCount(TCType, EC), RemainingIterations))
    continue;
```

although feel free to ignore this if you prefer your version!

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


More information about the llvm-commits mailing list