On 10/28/25 7:29 PM, 钟居哲 wrote:
LGTM
From: "Robin Dapp"<[email protected] <mailto:[email protected]>>
Date: Tue, Oct 28, 2025, 20:55
Subject: [PATCH v2] RISC-V: avlprop: Scale AVL by subreg ratio [PR122445].
To: "gcc-patches"<[email protected] <mailto:[email protected]>>
Cc: <[email protected] <mailto:[email protected]>>,
<[email protected] <mailto:[email protected]>>,
<[email protected] <mailto:[email protected]>>,
<[email protected] <mailto:[email protected]>>, <[email protected]
<mailto:[email protected]>>
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 <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.
I've pushed this to the trunk as well.
jeff