]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Recognize stepped series in expand_vec_perm_const.
authorRobin Dapp <rdapp@ventanamicro.com>
Fri, 8 Dec 2023 11:50:01 +0000 (12:50 +0100)
committerRobin Dapp <rdapp@ventanamicro.com>
Mon, 11 Dec 2023 09:42:16 +0000 (10:42 +0100)
commitd9dd06ad51b7479f09acb88adf404664a1e18b2a
tree5620254d320b49e1e6445eb960a71b1b6e22fceb
parent0af729c69fa977dd2901f698f1ffbaa34a0ebbcf
RISC-V: Recognize stepped series in expand_vec_perm_const.

We currently try to recognize various forms of stepped (const_vector)
sequence variants in expand_const_vector.  Because of complications with
canonicalization and encoding it is easier to identify such patterns
in expand_vec_perm_const_1 already where perm.series_p () is available.

This patch introduces shuffle_series as new permutation pattern and
tries to recognize series like [base0 base1 base1 + step ...].  If such
a series is found the series is expanded by expand_vec_series and a
gather is emitted.

On top the patch fixes the step recognition in expand_const_vector
for stepped series where such a series would end up before.

This fixes several execution failures when running code compiled for a
scalable vector size of 128 on a target with vlen = 256 or higher.
The problem was only noticed there because the encoding for a reversed
[2 2]-element vector ("3 2 1 0") is { [1 2], [0 2], [1 4] }.

Some testcases that failed were:
vect-alias-check-18.c
vect-alias-check-1.F90
pr64365.c

On a 128-bit target, only the first two elements are used.  The
third element causing the complications only comes into effect at
vlen = 256.

With this patch the testsuite results are similar with vlen = 128,
vlen = 256 as well as vlen = 512 (apart from the fixed-vlmax tests of
course).

gcc/ChangeLog:

PR target/112853

* config/riscv/riscv-v.cc (expand_const_vector):  Fix step
calculation.
(modulo_sel_indices): Also perform modulo for variable-length
constants.
(shuffle_series): Recognize series permutations.
(expand_vec_perm_const_1): Add shuffle_series.
gcc/config/riscv/riscv-v.cc