As Tamar suggested, v2 reuses the offset check of
vect_truncate_gather_scatter_offset for grouped gathers (patch 2), so the
count is also bounded by max_loop_iterations and the multiply goes through
wi::mul.

That bound does not hold when peeling for alignment is done by masking:
the active lanes move up by the skipped iterations, and
vect_truncate_gather_scatter_offset already miscompiles the tests in
patch 1 (since GCC 11).  Patch 1 fixes that first.

OK for trunk?

Dominic P (2):
  vect: Account for peeling by masking in strided gather offsets
  vect: Do not let grouped gather offsets wrap

 .../gcc.dg/vect/vect-strided-neg-step-1.c     | 82 ++++++++++++++++++
 .../aarch64/sve/strided_grouped_1.c           |  8 ++
 .../aarch64/sve/strided_grouped_1_run.c       |  4 +
 .../gcc.target/aarch64/sve/strided_load_9.c   | 16 ++++
 .../gcc.target/aarch64/sve/strided_store_8.c  | 16 ++++
 gcc/tree-vect-stmts.cc                        | 83 +++++++++++--------
 6 files changed, 175 insertions(+), 34 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/vect/vect-strided-neg-step-1.c
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/strided_grouped_1.c
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/strided_grouped_1_run.c
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/strided_load_9.c
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/strided_store_8.c

-- 
2.55.0

Reply via email to