[PATCH] D142109: [LoopVectorize] Remove runtime check and scalar tail loop when tail-folding.

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 9 09:04:37 PST 2023


sdesmalen added a comment.

In D142109#4106874 <https://reviews.llvm.org/D142109#4106874>, @fhahn wrote:

> Would it be possible to have at least one target-independent patch by passing the style as option>?

I tried to create such a test but it needs to run with scalable vectors, otherwise the code under the check on line 3010 is not exercised. It doesn't seem possible at the moment to test it without having a target (e.g. the cost-model prevents the use of scalable vectors due to Invalid costs, even when using `-force-target-instruction-cost=1`).
That said, I've created a `force-vectorization-style` option and created a new AArch64 test (`tail-folding-styles.ll`) that exercises all the different tail folding styles for the same loop.



================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:1558
+    return FoldTailByMasking &&
+           (TTI.getPreferredTailFoldingStyle() ==
+                TailFoldingStyle::DataAndControlFlow ||
----------------
fhahn wrote:
> Having a helper to check if the style means using ActiveLaneMask would probably help to make some of the code below a bit more compact and clearer.
Yes, makes sense. I've created a helper function for it.


================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:8753
+  if (Style == TailFoldingStyle::DataAndControlFlow ||
+      Style == TailFoldingStyle::DataAndControlFlowWithoutRuntimeCheck) {
     // Create the active lane mask instruction in the vplan preheader.
----------------
fhahn wrote:
> The code for handling ActiveLaneMask now as grown quite a bit. Do you think it would be possible to separate the logic in different functions? Not in this patch ,but as general cleanup?
Fair question, I'll try to create a follow-up patch to clean this up a bit!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142109



More information about the llvm-commits mailing list