diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2021-08-04 16:52:09 +0100 |
---|---|---|
committer | Richard Sandiford <richard.sandiford@arm.com> | 2021-08-04 16:52:09 +0100 |
commit | 5a1017dc305c49c59129d45536630d02dbc01c45 (patch) | |
tree | bafd9d80404fa85093744e1e3eef10137a575d47 | |
parent | 315a1c3756cbc751c4af0ce0da2157a88d7c3b09 (diff) | |
download | gcc-5a1017dc305c49c59129d45536630d02dbc01c45.zip gcc-5a1017dc305c49c59129d45536630d02dbc01c45.tar.gz gcc-5a1017dc305c49c59129d45536630d02dbc01c45.tar.bz2 |
vect: Tweak comparisons with existing epilogue loops
This patch uses a more accurate scalar iteration estimate when
comparing the epilogue of a constant-iteration loop with a candidate
replacement epilogue.
In the testcase, the patch prevents a 1-to-3-element SVE epilogue
from seeming better than a 64-bit Advanced SIMD epilogue.
gcc/
* tree-vect-loop.c (vect_better_loop_vinfo_p): Detect cases in
which old_loop_vinfo is an epilogue loop that handles a constant
number of iterations.
gcc/testsuite/
* gcc.target/aarch64/sve/cost_model_12.c: New test.
-rw-r--r-- | gcc/testsuite/gcc.target/aarch64/sve/cost_model_12.c | 19 | ||||
-rw-r--r-- | gcc/tree-vect-loop.c | 10 |
2 files changed, 28 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/cost_model_12.c b/gcc/testsuite/gcc.target/aarch64/sve/cost_model_12.c new file mode 100644 index 0000000..4c5226e --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/cost_model_12.c @@ -0,0 +1,19 @@ +/* { dg-options "-O3 -mtune=neoverse-512tvb" } */ + +void +f (float x[restrict 10][1024], + float y[restrict 10][1024], float z) +{ + for (int i = 0; i < 10; ++i) + { +#pragma GCC unroll 10 + for (int j = 0; j < 10; ++j) + x[j][i] = y[j][i] * z; + } +} + +/* We should unroll the outer loop, with 2x 16-byte vectors and 1x + 8-byte vectors. */ +/* { dg-final { scan-assembler-not {\tptrue\t} } } */ +/* { dg-final { scan-assembler {\tv[0-9]+\.4s,} } } */ +/* { dg-final { scan-assembler {\tv[0-9]+\.2s,} } } */ diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 48a54b0..1e21fe6 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -2772,7 +2772,15 @@ vect_better_loop_vinfo_p (loop_vec_info new_loop_vinfo, /* Limit the VFs to what is likely to be the maximum number of iterations, to handle cases in which at least one loop_vinfo is fully-masked. */ - HOST_WIDE_INT estimated_max_niter = likely_max_stmt_executions_int (loop); + HOST_WIDE_INT estimated_max_niter; + loop_vec_info main_loop = LOOP_VINFO_ORIG_LOOP_INFO (old_loop_vinfo); + unsigned HOST_WIDE_INT main_vf; + if (main_loop + && LOOP_VINFO_NITERS_KNOWN_P (main_loop) + && LOOP_VINFO_VECT_FACTOR (main_loop).is_constant (&main_vf)) + estimated_max_niter = LOOP_VINFO_INT_NITERS (main_loop) % main_vf; + else + estimated_max_niter = likely_max_stmt_executions_int (loop); if (estimated_max_niter != -1) { if (known_le (estimated_max_niter, new_vf)) |