]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Generic vec_extract via subreg.
authorRobin Dapp <rdapp@ventanamicro.com>
Thu, 13 Nov 2025 08:23:40 +0000 (09:23 +0100)
committerRobin Dapp <rdapp@oss.qualcomm.com>
Fri, 19 Dec 2025 18:41:54 +0000 (19:41 +0100)
commit92edf176fff176381646db7abe8bfd2dfbb83cb6
treec842d04557b81086a58680e028a7a2461f62edcc
parentf5ddd4ba0ba1b00838e36966fbaf771c581b99ef
RISC-V: Generic vec_extract via subreg.

We are missing several vec_extract chances because the current autovec
patterns are not comprehensive.  In particular we don't extract from
pseudo-VLA modes that are actually VLS modes (just VLA modes in name).

Rather than add even more mode combinations to vec_extract, this patch
uses a dynamic approach in legitimize_move.  At that point we can just check
if the mode sizes make sense and then emit the same code as before.

This is not the ideal solution as the middle-end and the vectorizer in
particular queries the vec_extract optab for support and won't emit
certain code sequences if it's not present (e.g. in VMAT_STRIDED_SLP
or when trying intermediate-sized vectors in a chain).
For simple BIT_FIELD_REFs it works, though.

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_vector_subreg_extract): New
function that checks for and performs "vector extracts".
(legitimize_move): Call new function.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/subreg-extract.c: New test.
gcc/config/riscv/riscv-v.cc
gcc/testsuite/gcc.target/riscv/rvv/autovec/subreg-extract.c [new file with mode: 0644]