]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Allow unaligned accesses in cpymemsi expansion
authorChristoph Müllner <christoph.muellner@vrull.eu>
Wed, 1 May 2024 16:50:38 +0000 (18:50 +0200)
committerChristoph Müllner <christoph.muellner@vrull.eu>
Wed, 15 May 2024 11:01:45 +0000 (13:01 +0200)
commit04cd8ccaec90405ccf7471252c0e06ba7f5437dc
treefe9aa87be1536132a28197a3e9f15ae5e61c4869
parent00029408387e9cc64e135324c22d15cd5a70e946
RISC-V: Allow unaligned accesses in cpymemsi expansion

The RISC-V cpymemsi expansion is called, whenever the by-pieces
infrastructure will not take care of the builtin expansion.
The code emitted by the by-pieces infrastructure may emits code,
that includes unaligned accesses if riscv_slow_unaligned_access_p
is false.

The RISC-V cpymemsi expansion is handled via riscv_expand_block_move().
The current implementation of this function does not check
riscv_slow_unaligned_access_p and never emits unaligned accesses.

Since by-pieces emits unaligned accesses, it is reasonable to implement
the same behaviour in the cpymemsi expansion. And that's what this patch
is doing.

The patch checks riscv_slow_unaligned_access_p at the entry and sets
the allowed alignment accordingly. This alignment is then propagated
down to the routines that emit the actual instructions.

The changes introduced by this patch can be seen in the adjustments
of the cpymem tests.

gcc/ChangeLog:

* config/riscv/riscv-string.cc (riscv_block_move_straight): Add
parameter align.
(riscv_adjust_block_mem): Replace parameter length by align.
(riscv_block_move_loop): Add parameter align.
(riscv_expand_block_move_scalar): Set alignment properly if the
target has fast unaligned access.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/cpymem-32-ooo.c: Adjust for unaligned access.
* gcc.target/riscv/cpymem-64-ooo.c: Likewise.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
gcc/config/riscv/riscv-string.cc
gcc/testsuite/gcc.target/riscv/cpymem-32-ooo.c
gcc/testsuite/gcc.target/riscv/cpymem-64-ooo.c