]> git.ipfire.org Git - thirdparty/gcc.git/commit
[PATCH v2] RISC-V: avlprop: Scale AVL by subreg ratio [PR122445].
authorRobin Dapp <rdapp.gcc@gmail.com>
Thu, 30 Oct 2025 13:48:07 +0000 (07:48 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Thu, 30 Oct 2025 13:48:07 +0000 (07:48 -0600)
commitbce897412c2dbf63bb6fd509cc8191cd8fbb8b56
tree8929dfc422cf26a1a0a7b9a6754ea2b15c015433
parent44c27171c36a9128da970fb35d4790de42a82b4d
[PATCH v2] RISC-V: avlprop: Scale AVL by subreg ratio [PR122445].

Hi,

Since r16-4391-g85ab3a22ed11c9 we can use a punned type/mode for grouped
loads and stores.  Vineet reported an x264 wrong-code bug since that
commit.  The crux of the issue is that in avlprop we back-propagate
the AVL from consumers (like stores) to producers.
When e.g. a V4QI vector is type-punned by a V1SI vector
  (subreg:V1SI (reg:V4QI ...)
the AVL of that instruction refers to the outer subreg mode, i.e. for an
AVL of 1 in a store we store one SImode element.  The producer of the
store data is not type punned and still uses V4QI and we produce 4
QImode elements.  Due to this mismatch we back-propagate the consumer
AVL of 1 to the producers, causing wrong code.

This patch looks if the use is inside a subreg and scales the immediate
AVL by the ratio of inner and outer mode.

Changes from v1:
 - Move NULL check into loop.
 - Add REG_P check.

Regtested on rv64gcv_zvl512b.

Regards
 Robin

PR target/122445

gcc/ChangeLog:

* config/riscv/riscv-avlprop.cc (pass_avlprop::get_vlmax_ta_preferred_avl):
Scale AVL of subreg uses.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr122445.c: New test.
gcc/config/riscv/riscv-avlprop.cc
gcc/testsuite/gcc.target/riscv/rvv/autovec/pr122445.c [new file with mode: 0644]