]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Cover sign-extensions in lshr<GPR:mode>3_zero_extend_4
authorChristoph Müllner <christoph.muellner@vrull.eu>
Tue, 7 May 2024 20:23:26 +0000 (22:23 +0200)
committerChristoph Müllner <christoph.muellner@vrull.eu>
Wed, 8 May 2024 14:09:36 +0000 (16:09 +0200)
commit3ee30d7981987b86bd6a9a2675e26fadec48e5cd
tree5f8aad3390f74b4f82bf72e0efe16e5beba85704
parent3b9c760072c7792cbae6f38894756d2b96c2fd8c
RISC-V: Cover sign-extensions in lshr<GPR:mode>3_zero_extend_4

The lshr<GPR:mode>3_zero_extend_4 pattern targets bit extraction
with zero-extension. This pattern represents the canonical form
of zero-extensions of a logical right shift.

The same optimization can be applied to sign-extensions.
Given the two optimizations are so similar, this patch converts
the existing one to also cover the sign-extension case as well.

gcc/ChangeLog:

* config/riscv/iterators.md (ashiftrt): New code attribute
'extract_shift' and adding extractions to optab.
* config/riscv/riscv.md (*lshr<GPR:mode>3_zero_extend_4): Rename to...
(*<any_extract:optab><GPR:mode>3):...this and add support for
sign-extensions.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/extend-shift-helpers.h: Add helpers for
sign-extension.
* gcc.target/riscv/sign-extend-rshift-32.c: New test.
* gcc.target/riscv/sign-extend-rshift-64.c: New test.
* gcc.target/riscv/sign-extend-rshift.c: New test.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
gcc/config/riscv/iterators.md
gcc/config/riscv/riscv.md
gcc/testsuite/gcc.target/riscv/extend-shift-helpers.h
gcc/testsuite/gcc.target/riscv/sign-extend-rshift-32.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/sign-extend-rshift-64.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/sign-extend-rshift.c [new file with mode: 0644]