Carrying on previous work on uncounted loop vectorization enablement,
this patch series extends existing functionality by adding partial
vector support using both mask and length controls.
The main consequence of this work is that, in enabling partial
vectors, we allow for masking for alignment as an alternative to
peeling for alignment, whenever this is supported by the target.
Masking for alignment does not require a known iteration count.
Instead, the vectorizer can align the initial memory access backwards
and use a partial mask to exclude elements preceding the original
starting address. Subsequent vector iterations can then use full
masks or lengths, with loop termination continuing to be governed by
the vectorized early-break conditions.
Much like previous work, much of the changes simply involve careful
gating of all functionality involving adding `niters' checking, given
these are not applicable to uncounted loops. As partial vector code
is already capable of handling early-break exits we can rely on much
of the existing vectorization framework.
The patch series can be roughly divided into four distinct
subsections:
1. Simplification of vectorized loop exit handling. For uncounted
loops, the main exit is semantically indistinguishable from other
early exits. Treating it any differently from other exits adds
unnecessary complexity to the code and makes code maintenance more
difficult. We therefore redirect all exit edges to point to a unique
exit merge block.
2. Make target agnostic changes to the vectorizer. These are general
changes that are largely applicable irrespective of whether targets
use mask- or length-based controls or whether vector size is known at
compile time or a established only at run-time.
3. Add target-specific functionality - Ensure the machinery required
for length-agnostic and avx512 predicate-based masking is in place, as
well as for length-based controls.
4. Add unit tests.
Regression tested on AArch64 and x86.
No performance regressions observed across benchmarks.
Victor Do Nascimento (13):
vect: Redirect early exit edges to main exit destination for uncounted
loops
vect: Preserve the main exit condition for uncounted loops
vect: Find the early-exit merge block for uncounted loops
vect: Support length-based partial vectors for uncounted loops
vect: Disable decrementing IVs for uncounted loops
vect: Handle uncounted loops w/ partial vectors in
`vect_transform_loop'
vect: Extend partial-vector loop controls to uncounted loops
vect: Handle uncounted loops in partial-vector condition generation
vect: Handle uncounted loops in `vect_prepare_for_masked_peels'
vect: Support AVX-512 partial vectors for uncounted loops
vect: Fix AVX-512 partial-vector verification for uncounted loops
vect: Enable use of partial vectors for uncounted loop alignment
vect: Add tests for uncounted loops using partial vectors
.../vect/vect-uncounted-partial-vect-run_1.c | 53 +
.../vect/vect-uncounted-partial-vect-run_2.c | 55 +
.../vect/vect-uncounted-partial-vect_1.c | 36 +
.../vect/vect-uncounted-partial-vect_2.c | 38 +
.../vect/vect-uncounted-partial-vect_3.c | 43 +
.../vect/vect-uncounted-partial-vect_4.c | 39 +
.../vect/vect-uncounted-partial-vect_5.c | 39 +
.../vect/vect-uncounted-partial-vect_6.c | 44 +
gcc/testsuite/gcc.dg/vect/vect-uncounted_8.c | 33 +
gcc/tree-vect-loop-manip.cc | 951 +++++++++++-------
gcc/tree-vect-loop.cc | 82 +-
11 files changed, 1026 insertions(+), 387 deletions(-)
create mode 100644
gcc/testsuite/gcc.dg/vect/vect-uncounted-partial-vect-run_1.c
create mode 100644
gcc/testsuite/gcc.dg/vect/vect-uncounted-partial-vect-run_2.c
create mode 100644 gcc/testsuite/gcc.dg/vect/vect-uncounted-partial-vect_1.c
create mode 100644 gcc/testsuite/gcc.dg/vect/vect-uncounted-partial-vect_2.c
create mode 100644 gcc/testsuite/gcc.dg/vect/vect-uncounted-partial-vect_3.c
create mode 100644 gcc/testsuite/gcc.dg/vect/vect-uncounted-partial-vect_4.c
create mode 100644 gcc/testsuite/gcc.dg/vect/vect-uncounted-partial-vect_5.c
create mode 100644 gcc/testsuite/gcc.dg/vect/vect-uncounted-partial-vect_6.c
create mode 100644 gcc/testsuite/gcc.dg/vect/vect-uncounted_8.c
--
2.43.0