]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Disable Zba optimization pattern if XTheadMemIdx is enabled
authorChristoph Müllner <christoph.muellner@vrull.eu>
Tue, 23 Jul 2024 12:48:02 +0000 (14:48 +0200)
committerChristoph Müllner <christoph.muellner@vrull.eu>
Wed, 24 Jul 2024 07:26:27 +0000 (09:26 +0200)
commit9817d29cd66762893782a52b2c304c5083bc0023
tree106ccfeff874121694fdd01a55d82d61c4da5c66
parent9d312ba54428d70f0703c8774a6fe6a4755930e7
RISC-V: Disable Zba optimization pattern if XTheadMemIdx is enabled

It is possible that the Zba optimization pattern zero_extendsidi2_bitmanip
matches for a XTheadMemIdx INSN with the effect of emitting an invalid
instruction as reported in PR116035.

The pattern above is used to emit a zext.w instruction to zero-extend
SI mode registers to DI mode.  A similar functionality can be achieved
by XTheadBb's th.extu instruction.  And indeed, we have the equivalent
pattern in thead.md (zero_extendsidi2_th_extu).  However, that pattern
depends on !TARGET_XTHEADMEMIDX.  To compensate for that, there are
specific patterns that ensure that zero-extension instruction can still
be emitted (th_memidx_bb_zero_extendsidi2 and friends).

While we could implement something similar (th_memidx_zba_zero_extendsidi2)
it would only make sense, if there existed real HW that does implement Zba
and XTheadMemIdx, but not XTheadBb.  Unless such a machine exists, let's
simply disable zero_extendsidi2_bitmanip if XTheadMemIdx is available.

PR target/116035

gcc/ChangeLog:

* config/riscv/bitmanip.md: Disable zero_extendsidi2_bitmanip
for XTheadMemIdx.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/pr116035-1.c: New test.
* gcc.target/riscv/pr116035-2.c: New test.

Reported-by: Patrick O'Neill <patrick@rivosinc.com>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
gcc/config/riscv/bitmanip.md
gcc/testsuite/gcc.target/riscv/pr116035-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/pr116035-2.c [new file with mode: 0644]