https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122445
--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jeff Law <[email protected]>: https://gcc.gnu.org/g:bce897412c2dbf63bb6fd509cc8191cd8fbb8b56 commit r16-4736-gbce897412c2dbf63bb6fd509cc8191cd8fbb8b56 Author: Robin Dapp <[email protected]> Date: Thu Oct 30 07:48:07 2025 -0600 [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.
