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

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 18 02:08:42 PST 2024


================
@@ -4677,7 +4683,11 @@ VectorizationFactor LoopVectorizationPlanner::selectEpilogueVectorizationFactor(
     return Result;
   }
 
-  if (!CM.isEpilogueVectorizationProfitable(MainLoopVF)) {
+  unsigned Multiplier = IC;
+  if (MainLoopVF.isScalable())
+    Multiplier = getVScaleForTuning(OrigLoop, TTI).value_or(1);
----------------
david-arm wrote:

I think this change looks incorrect. Previously in `isEpilogueVectorizationProfitable` we did:

```
  unsigned Multiplier = 1;
  if (VF.isScalable())
    Multiplier = getVScaleForTuning(TheLoop, TTI).value_or(1);
  if ((Multiplier * VF.getKnownMinValue()) >= EpilogueVectorizationMinVF)
    return true;
```

i.e. for fixed-width VFs `Multiplier = 1`, whereas after this change `Multiplier = IC`. This is either biasing against or in favour of fixed-width VFs, which doesn't seem right. I think in order to match the previous behaviour the code should be:

```
  unsigned Multiplier = 1;
  if (MainLoopVF.isScalable())
    Multiplier = getVScaleForTuning(OrigLoop, TTI).
```

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


More information about the llvm-commits mailing list