On 3/5/25 7:39 AM, Robin Dapp wrote:
Hi,

when merging two vsetvls that both only demand "SEW >= ..." we
use their maximum SEW and keep the LMUL.  That may lead to invalid
vector configurations like
  e64, mf4.
As we make sure that the SEW requirements overlap we can use the SEW
and LMUL of the configuration with the larger SEW.

Ma Jin already touched this merge rule some weeks ago and fixed the
ratio calculation (r15-6873).  Calculating the ratio from an invalid
SEW/LMUL combination lead to an overflow in the ratio variable, though.
I'd argue the proper fix is to update SEW and LMUL, keeping the ratio
as before.  This "breaks" bug-10.c but its check only checked for a
workaround anyway so I turned it into a run test.

For V2, Ma Jin helped minify the PR's test and provided a larger test
case for bug-10.

Regtested on rv64gcv_zvl512b.

Regards
Robin

     PR target/117955

gcc/ChangeLog:

     * config/riscv/riscv-vsetvl.cc: Use LMUL/ratio from vsetvl with
     larger SEW.

gcc/testsuite/ChangeLog:

     * gcc.target/riscv/rvv/base/bug-10.c: Convert to run test.
     * gcc.target/riscv/rvv/base/bug-10-2.c: New test.
     * gcc.target/riscv/rvv/base/pr117955.c: New test.
OK
jeff

Reply via email to