]> git.ipfire.org Git - thirdparty/gcc.git/commit
[PATCH 3/7] RISC-V: Fix vector memcpy smaller LMUL generation
authorCraig Blackmore <craig.blackmore@embecosm.com>
Fri, 18 Oct 2024 15:17:21 +0000 (09:17 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Fri, 18 Oct 2024 15:17:21 +0000 (09:17 -0600)
commitb039d06c9a810a3fab4c5eb9d50b0c7aff94b2d8
tree4467964e4619b45bfb03bcd035273f569b010669
parent212d8685e4590c9f1168f503a383e3ea2639b418
[PATCH 3/7] RISC-V: Fix vector memcpy smaller LMUL generation

If riscv_vector::expand_block_move is generating a straight-line memcpy
using a predicated store, it tries to use a smaller LMUL to reduce
register pressure if it still allows an entire transfer.

This happens in the inner loop of riscv_vector::expand_block_move,
however, the vmode chosen by this loop gets overwritten later in the
function, so I have added the missing break from the outer loop.

I have also addressed a couple of issues with the conditions of the if
statement within the inner loop.

The first condition did not make sense to me:
```
  TARGET_MIN_VLEN * lmul <= nunits * BITS_PER_UNIT
```
I think this was supposed to be checking that the length fits within the
given LMUL, so I have changed it to do that.

The second condition:
```
  /* Avoid loosing the option of using vsetivli .  */
  && (nunits <= 31 * lmul || nunits > 31 * 8)
```
seems to imply that lmul affects the range of AVL immediate that
vsetivli can take but I don't think that is correct.  Anyway, I don't
think this condition is necessary because if we find a suitable mode we
should stick with it, regardless of whether it allowed vsetivli, rather
than continuing to try larger lmul which would increase register
pressure or smaller potential_ew which would increase AVL.  I have
removed this condition.

gcc/ChangeLog:

* config/riscv/riscv-string.cc (expand_block_move): Fix
condition for using smaller LMUL.  Break outer loop if a
suitable vmode has been found.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/vsetvl/pr112929-1.c: Expect smaller lmul.
* gcc.target/riscv/rvv/vsetvl/pr112988-1.c: Likewise.
* gcc.target/riscv/rvv/base/cpymem-3.c: New test.
gcc/config/riscv/riscv-string.cc
gcc/testsuite/gcc.target/riscv/rvv/base/cpymem-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/vsetvl/pr112929-1.c
gcc/testsuite/gcc.target/riscv/rvv/vsetvl/pr112988-1.c