From: Christoph Müllner Date: Mon, 29 Apr 2024 01:06:52 +0000 (+0200) Subject: RISC-V: add tests for overlapping mem ops X-Git-Tag: basepoints/gcc-16~9046 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5814437b4fcc550697d6e286f49a2f8b108815bf;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/testsuite/gcc.target/riscv/cpymem-32-ooo.c b/gcc/testsuite/gcc.target/riscv/cpymem-32-ooo.c index 946a773f77a..947d58c30fa 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 08a927b9483..108748690cd 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)