Use single-iteration epilogues when peeling for gaps
authorRichard Sandiford <richard.sandiford@linaro.org>
Sat, 13 Jan 2018 18:00:41 +0000 (18:00 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Sat, 13 Jan 2018 18:00:41 +0000 (18:00 +0000)
commitd1d20a49a788bdb82f09ada6377d932ceac07934
treeda9369ee0298c56a7f3c618a641a99026cd3d33c
parent4aa157e8d2aec2e4f9e97dcee86068135e0dcb2f
Use single-iteration epilogues when peeling for gaps

This patch adds support for fully-masking loops that require peeling
for gaps.  It peels exactly one scalar iteration and uses the masked
loop to handle the rest.  Previously we would fall back on using a
standard unmasked loop instead.

2018-01-13  Richard Sandiford  <richard.sandiford@linaro.org>
    Alan Hayward  <alan.hayward@arm.com>
    David Sherwood  <david.sherwood@arm.com>

gcc/
* tree-vect-loop-manip.c (vect_gen_scalar_loop_niters): Replace
vfm1 with a bound_epilog parameter.
(vect_do_peeling): Update calls accordingly, and move the prologue
call earlier in the function.  Treat the base bound_epilog as 0 for
fully-masked loops and retain vf - 1 for other loops.  Add 1 to
this base when peeling for gaps.
* tree-vect-loop.c (vect_analyze_loop_2): Allow peeling for gaps
with fully-masked loops.
(vect_estimate_min_profitable_iters): Handle the single peeled
iteration in that case.

gcc/testsuite/
* gcc.target/aarch64/sve/struct_vect_18.c: Check the number
of branches.
* gcc.target/aarch64/sve/struct_vect_19.c: Likewise.
* gcc.target/aarch64/sve/struct_vect_20.c: New test.
* gcc.target/aarch64/sve/struct_vect_20_run.c: Likewise.
* gcc.target/aarch64/sve/struct_vect_21.c: Likewise.
* gcc.target/aarch64/sve/struct_vect_21_run.c: Likewise.
* gcc.target/aarch64/sve/struct_vect_22.c: Likewise.
* gcc.target/aarch64/sve/struct_vect_22_run.c: Likewise.
* gcc.target/aarch64/sve/struct_vect_23.c: Likewise.
* gcc.target/aarch64/sve/struct_vect_23_run.c: Likewise.

Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>
From-SVN: r256635
14 files changed:
gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/aarch64/sve/struct_vect_18.c
gcc/testsuite/gcc.target/aarch64/sve/struct_vect_19.c
gcc/testsuite/gcc.target/aarch64/sve/struct_vect_20.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/struct_vect_20_run.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/struct_vect_21.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/struct_vect_21_run.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/struct_vect_22.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/struct_vect_22_run.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/struct_vect_23.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/struct_vect_23_run.c [new file with mode: 0644]
gcc/tree-vect-loop-manip.c
gcc/tree-vect-loop.c