]> git.ipfire.org Git - thirdparty/gcc.git/commit
vect: Handle grouped accesses via gather/scatter.
authorRobin Dapp <rdapp@ventanamicro.com>
Fri, 5 Sep 2025 14:19:18 +0000 (16:19 +0200)
committerRobin Dapp <rdapp@ventanamicro.com>
Mon, 13 Oct 2025 09:57:30 +0000 (11:57 +0200)
commit85ab3a22ed11c948aa0c4885f1e710f94ef5cd0f
tree22fc7f8c9d160f6522b27f7ce9dc9d670e7bcc51
parent33b1a5d588971079e06a72d86e90b345e6e1cb25
vect: Handle grouped accesses via gather/scatter.

This patch adds gather/scatter handling for grouped access.  The idea is
to e.g. replace an access (for uint8_t elements) like
  arr[0]
  arr[1]
  arr[2]
  arr[3]
  arr[0 + step]
  arr[1 + step]
  ...
by gather loads of uint32_t
  arr[0..3]
  arr[0 + step * 1..3 + step * 1]
  arr[0 + step * 2..3 + step * 2]
  ...
where the offset vector is a simple series with step STEP.
If supported, such a gather can be implemented as a strided load.

If we have a masked access the transformation is not performed.
Masking could still be done after converting the data back to the
original vectype but it does not seem worth it for now.

PR target/118019

gcc/ChangeLog:

* internal-fn.cc (get_supported_else_vals): Exit at invalid
index.
(internal_strided_fn_supported_p): New funtion.
* internal-fn.h (internal_strided_fn_supported_p): Declare.
* tree-vect-stmts.cc (vector_vector_composition_type):
Add vector_only argument.
(vect_use_grouped_gather): New function.
(vect_get_store_rhs): Adjust docs of
vector_vector_composition_type.
(get_load_store_type): Try grouped gather.
(vectorizable_store): Use punned vectype.
(vectorizable_load): Ditto.
* tree-vectorizer.h (struct vect_load_store_data): Add punned
vectype.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr118019-2.c: New test.
gcc/internal-fn.cc
gcc/internal-fn.h
gcc/testsuite/gcc.target/riscv/rvv/autovec/pr118019-2.c [new file with mode: 0644]
gcc/tree-vect-stmts.cc
gcc/tree-vectorizer.h