[LV] Use VScaleForTuning to allow wider epilogue VFs.
authorSander de Smalen <sander.desmalen@arm.com>
Thu, 3 Feb 2022 09:36:03 +0000 (09:36 +0000)
committerSander de Smalen <sander.desmalen@arm.com>
Thu, 3 Feb 2022 15:40:17 +0000 (15:40 +0000)
commiteaee477edafed691dae206cea7c0a42893eb2821
treec699387d834987d21efed1b70a97bd4d1f6df2ec
parentb5787a0c6cc4da47b7d7b218e23f780076ad2f5f
[LV] Use VScaleForTuning to allow wider epilogue VFs.

When the main loop is e.g. VF=vscale x 1 and the epilogue VF cannot
be any smaller, the vectorizer should try to estimate how many lanes are
executed at runtime and allow a suitable fixed-width VF to be chosen. It
can use VScaleForTuning to figure out what a suitable fixed-width VF could
be. For the case where the main loop VF is VF=vscale x 1, and VScaleForTuning=8,
it could still choose an epilogue VF upto VF=4.

This was a bit tricky to test, so this patch also introduces a wrapper
function to get 'VScaleForTuning' by also considering vscale_range.
If min and max are equal, then that will be the vscale we compile for.
It makes little sense to tune for a different width if the code
will not be portable for other widths.

Reviewed By: david-arm

Differential Revision: https://reviews.llvm.org/D118709
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/AArch64/sve-epilog-vect.ll