https://gcc.gnu.org/g:ad0413b832400aa9e81e20070b3ef6b0a9a6d888
commit ad0413b832400aa9e81e20070b3ef6b0a9a6d888 Author: Christoph Müllner <christoph.muell...@vrull.eu> Date: Mon Apr 29 03:06:52 2024 +0200 RISC-V: add tests for overlapping mem ops A recent patch added the field overlap_op_by_pieces to the struct riscv_tune_param, which is used by the TARGET_OVERLAP_OP_BY_PIECES_P() hook. This hook is used by the by-pieces infrastructure to decide if overlapping memory accesses should be emitted. The changes in the expansion can be seen in the adjustments of the cpymem test cases. These tests also reveal a limitation in the RISC-V cpymem expansion that prevents this optimization as only by-pieces cpymem expansions emit overlapping memory accesses. gcc/testsuite/ChangeLog: * gcc.target/riscv/cpymem-32-ooo.c: Adjust for overlapping access. * gcc.target/riscv/cpymem-64-ooo.c: Likewise. Signed-off-by: Christoph Müllner <christoph.muell...@vrull.eu> (cherry picked from commit 5814437b4fcc550697d6e286f49a2f8b108815bf) Diff: --- gcc/testsuite/gcc.target/riscv/cpymem-32-ooo.c | 20 +++++++--------- gcc/testsuite/gcc.target/riscv/cpymem-64-ooo.c | 33 ++++++++++---------------- 2 files changed, 20 insertions(+), 33 deletions(-) diff --git a/gcc/testsuite/gcc.target/riscv/cpymem-32-ooo.c b/gcc/testsuite/gcc.target/riscv/cpymem-32-ooo.c index 946a773f77a0..947d58c30fa3 100644 --- a/gcc/testsuite/gcc.target/riscv/cpymem-32-ooo.c +++ b/gcc/testsuite/gcc.target/riscv/cpymem-32-ooo.c @@ -24,9 +24,8 @@ void copy_aligned_##N (void *to, void *from) \ ** ... ** lw\t[at][0-9],0\([at][0-9]\) ** sw\t[at][0-9],0\([at][0-9]\) -** ... -** lbu\t[at][0-9],6\([at][0-9]\) -** sb\t[at][0-9],6\([at][0-9]\) +** lw\t[at][0-9],3\([at][0-9]\) +** sw\t[at][0-9],3\([at][0-9]\) ** ... */ COPY_N(7) @@ -36,9 +35,8 @@ COPY_N(7) ** ... ** lw\t[at][0-9],0\([at][0-9]\) ** sw\t[at][0-9],0\([at][0-9]\) -** ... -** lbu\t[at][0-9],6\([at][0-9]\) -** sb\t[at][0-9],6\([at][0-9]\) +** lw\t[at][0-9],3\([at][0-9]\) +** sw\t[at][0-9],3\([at][0-9]\) ** ... */ COPY_ALIGNED_N(7) @@ -66,11 +64,10 @@ COPY_ALIGNED_N(8) ** ... ** ... ** lw\t[at][0-9],0\([at][0-9]\) -** ... ** sw\t[at][0-9],0\([at][0-9]\) ** ... -** lbu\t[at][0-9],10\([at][0-9]\) -** sb\t[at][0-9],10\([at][0-9]\) +** lw\t[at][0-9],7\([at][0-9]\) +** sw\t[at][0-9],7\([at][0-9]\) ** ... */ COPY_N(11) @@ -79,11 +76,10 @@ COPY_N(11) **copy_aligned_11: ** ... ** lw\t[at][0-9],0\([at][0-9]\) -** ... ** sw\t[at][0-9],0\([at][0-9]\) ** ... -** lbu\t[at][0-9],10\([at][0-9]\) -** sb\t[at][0-9],10\([at][0-9]\) +** lw\t[at][0-9],7\([at][0-9]\) +** sw\t[at][0-9],7\([at][0-9]\) ** ... */ COPY_ALIGNED_N(11) diff --git a/gcc/testsuite/gcc.target/riscv/cpymem-64-ooo.c b/gcc/testsuite/gcc.target/riscv/cpymem-64-ooo.c index 08a927b94835..108748690cd3 100644 --- a/gcc/testsuite/gcc.target/riscv/cpymem-64-ooo.c +++ b/gcc/testsuite/gcc.target/riscv/cpymem-64-ooo.c @@ -24,9 +24,8 @@ void copy_aligned_##N (void *to, void *from) \ ** ... ** lw\t[at][0-9],0\([at][0-9]\) ** sw\t[at][0-9],0\([at][0-9]\) -** ... -** lbu\t[at][0-9],6\([at][0-9]\) -** sb\t[at][0-9],6\([at][0-9]\) +** lw\t[at][0-9],3\([at][0-9]\) +** sw\t[at][0-9],3\([at][0-9]\) ** ... */ COPY_N(7) @@ -36,9 +35,8 @@ COPY_N(7) ** ... ** lw\t[at][0-9],0\([at][0-9]\) ** sw\t[at][0-9],0\([at][0-9]\) -** ... -** lbu\t[at][0-9],6\([at][0-9]\) -** sb\t[at][0-9],6\([at][0-9]\) +** lw\t[at][0-9],3\([at][0-9]\) +** sw\t[at][0-9],3\([at][0-9]\) ** ... */ COPY_ALIGNED_N(7) @@ -66,9 +64,8 @@ COPY_ALIGNED_N(8) ** ... ** ld\t[at][0-9],0\([at][0-9]\) ** sd\t[at][0-9],0\([at][0-9]\) -** ... -** lbu\t[at][0-9],10\([at][0-9]\) -** sb\t[at][0-9],10\([at][0-9]\) +** lw\t[at][0-9],7\([at][0-9]\) +** sw\t[at][0-9],7\([at][0-9]\) ** ... */ COPY_N(11) @@ -77,11 +74,9 @@ COPY_N(11) **copy_aligned_11: ** ... ** ld\t[at][0-9],0\([at][0-9]\) -** ... ** sd\t[at][0-9],0\([at][0-9]\) -** ... -** lbu\t[at][0-9],10\([at][0-9]\) -** sb\t[at][0-9],10\([at][0-9]\) +** lw\t[at][0-9],7\([at][0-9]\) +** sw\t[at][0-9],7\([at][0-9]\) ** ... */ COPY_ALIGNED_N(11) @@ -90,11 +85,9 @@ COPY_ALIGNED_N(11) **copy_15: ** ... ** ld\t[at][0-9],0\([at][0-9]\) -** ... ** sd\t[at][0-9],0\([at][0-9]\) -** ... -** lbu\t[at][0-9],14\([at][0-9]\) -** sb\t[at][0-9],14\([at][0-9]\) +** ld\t[at][0-9],7\([at][0-9]\) +** sd\t[at][0-9],7\([at][0-9]\) ** ... */ COPY_N(15) @@ -103,11 +96,9 @@ COPY_N(15) **copy_aligned_15: ** ... ** ld\t[at][0-9],0\([at][0-9]\) -** ... ** sd\t[at][0-9],0\([at][0-9]\) -** ... -** lbu\t[at][0-9],14\([at][0-9]\) -** sb\t[at][0-9],14\([at][0-9]\) +** ld\t[at][0-9],7\([at][0-9]\) +** sd\t[at][0-9],7\([at][0-9]\) ** ... */ COPY_ALIGNED_N(15)