Draft: [LV] Outer-loop vectorization in the default vectorizer codepath #128202
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a draft MR to get feedback if something like this would be considered
a good-enough approach by current maintainers to merge into LLVM. I would split
it into smaller pieces if the general direction is not conflicting with current plans.
It implements outer-loop vectorization outside the VPlan-native path. Minimal
LoopAccessAnalysis support for non-innermost loops was added relying on the
!llvm.loop.parallel_accesses
metadata.Unlike for the VPlan-native path, inner loops with non-invariant trip-counts or
non-uniform inductions are supported, and the quality of the emitted code is better
than that of the current VPlan-native path.
A implementation very close to this one (#124432 required some changes but
also simplified this MR a lot) was successfully tested in combination with
basic LAA MemoryDepChecker support (not part of this MR) for outer loops on the
llvm-test-suite and SPEC (~3000 loops, outer-loop vect. was forced).
As a real-world motivational example, this loop
can be looked at. Performance is more than doubled when outer-loop vectorizing it.
Some code for the VPWidenPHIRecipes is duplicated from #128187.