[PATCH] D130755: [LoopVectorize] Introduce trip count minimal value threshold to ignore tail-folding for scalable vectors

Paul Walker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 4 04:27:57 PDT 2022


paulwalker-arm added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:192-195
+static cl::opt<unsigned> MinTripCountTailFoldingThreshold(
+    "vectorizer-min-trip-count-tail-folding", cl::init(5), cl::Hidden,
+    cl::desc("Minimal trip count constant value to ignore tail folding "
+             "for scalable vectors."));
----------------
We're late into the LLVM 15 release cycle so here we're trying to fix an LLVM 14 regression without resorting to reversing the decision to use tail folding for all low trip count loops.

I think it'll be better to now do this in a way with the most minimal impact to other targets and so rather than a global command line option can you instead add a TTI hook.  That way we can restrict the change to just AArch64/SVE and if it turns out we can rely on a more accurate cost model in the future and there are no other uses at that time, we can remove the TTI hook.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:5077-5081
+  if (ScalarEpilogueStatus != CM_ScalarEpilogueNotNeededUsePredicate &&
+      ScalarEpilogueStatus != CM_ScalarEpilogueNotAllowedUsePredicate &&
+      TC <= MinTripCountTailFoldingThreshold &&
+      MaxFactors.ScalableVF.isVector())
+    MaxFactors.ScalableVF = ElementCount::getScalable(0);
----------------
This doesn't look like the correct place to decide this.  Within `LoopVectorizePass::processLoop` the code exists to choose `CM_ScalarEpilogueNotAllowedLowTripLoop` for low trip count looks.  I think that's the code we want to change to also consider the new tail folding specific watermark.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130755/new/

https://reviews.llvm.org/D130755



More information about the llvm-commits mailing list