]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Don't add fractional LMUL types to V_VLS for XTheadVector
authorChristoph Müllner <christoph.muellner@vrull.eu>
Thu, 21 Mar 2024 14:40:49 +0000 (15:40 +0100)
committerChristoph Müllner <christoph.muellner@vrull.eu>
Fri, 22 Mar 2024 06:52:47 +0000 (07:52 +0100)
commitfd5e5dda8d79d62396f56d4fdd628b4bc5f9fa24
treea294757a9081bbabcc32970166fc68eccc082c8c
parentc65046ff2ef0a9a46e59bc0b3369b2d226f6a239
RISC-V: Don't add fractional LMUL types to V_VLS for XTheadVector

The expansion of `memset` (via expand_builtin_memset_args())
uses clear_by_pieces() and store_by_pieces() to avoid calls
to the C runtime. To check if a type can be used for that purpose
the function by_pieces_mode_supported_p() tests if a `mov` and
a `vec_duplicate` INSN can be expaned by the backend.

The `vec_duplicate` expansion takes arguments of type `V_VLS`.
The `mov` expansions take arguments of type `V`, `VB`, `VT`,
`VLS_AVL_IMM`, and `VLS_AVL_REG`. Some of these types (in fact
not types but type iterators) include fractional LMUL types.
E.g. `V_VLS` includes `V`, which includes `VI`, which includes
`RVVMF2QI`.

This results in an attempt to use fractional LMUL-types for
the `memset` expansion resulting in an ICE for XTheadVector,
because that extension cannot handle fractional LMULs.

This patch addresses this issue by splitting the definition
of the `VI` mode itereator into `VI_NOFRAC` (without fractional
LMUL types) and `VI_FRAC` (only fractional LMUL types).
Further, it defines `V_VLS` such, that `VI_FRAC` types are only
included if XTheadVector is not enabled.

The effect is demonstrated by a new test case that shows
that the by-pieces framework now emits `sb` instructions
instead of triggering an ICE.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
PR target/114194

gcc/ChangeLog:

* config/riscv/vector-iterators.md: Split VI into VI_FRAC and VI_NOFRAC.
Only include VI_NOFRAC in V_VLS without TARGET_XTHEADVECTOR.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/xtheadvector/pr114194.c: New test.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
gcc/config/riscv/vector-iterators.md
gcc/testsuite/gcc.target/riscv/rvv/xtheadvector/pr114194.c [new file with mode: 0644]