[PATCH] D154261: [LV] Consider if scalar epilogue is required in getMaximizedVFForTarget.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 4 13:47:11 PDT 2023


fhahn updated this revision to Diff 537171.
fhahn marked an inline comment as done.
fhahn added a comment.

In D154261#4472242 <https://reviews.llvm.org/D154261#4472242>, @Ayal wrote:

> Ah, ok, that optimization was later outlined by having LVP::execute_plan() do `if (!IsEpilogueVectorization) VPlanTransforms::optimizeForVFAndUF())`.
> (And may explain the observed clean-up behavior observed in https://reviews.llvm.org/D154264#inline-1491906 :-)
>
> The explanation for test @pr56319 may be misleading, though, as it specifically deals with having the epilog loop vectorization consider requiresScalarEpilog:
> ; Test case where the exit condition in the main vector loop can be optimized
> ; to true, but not in the epilogue vector loop. **In the test the interleave
> ; group requires to execute at least one scalar iteration**, meaning the last
> ; vector iteration of the epilogue vector loop cannot be executed.

Agreed, I think the interleave group requiring one scalar iteration is a red herring with respect to the orinal issue. Tried to clarify it in this patch.

> Could a test with trip count of, say, 34, work - be vectorized with main VF=32 and epilog VF=2 w/o requiresScalarEpilog - when last member of the interleave-group is accessed, while with requiresScalarEpilog main VF=32 will continue but epilog vectorization will be abandoned?

With 34, we could simplify the branch in the epilogue vector loop, as the epilogue vector loop would be dead (or shouldn't get generated, as in follow-on patches). I *think* TC = 37 with forced epilogue VF=2 should work (single main loop iteration with VF=32, 2 iterations of the epilogue vector loop (so branch cannot be simplified), final scalar iteration. Updated accoringly


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154261

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Transforms/LoopVectorize/X86/limit-vf-by-tripcount.ll
  llvm/test/Transforms/LoopVectorize/X86/pr56319-vector-exit-cond-optimization-epilogue-vectorization.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154261.537171.patch
Type: text/x-patch
Size: 10122 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230704/3b685d5f/attachment.bin>


More information about the llvm-commits mailing list