On Wed, Jul 29, 2026 at 03:16:54PM +0200, Konstantinos Eleftheriou wrote:
> When store forwarding is avoided without eliminating the load (the store
> only partially covers it), the extension wrapping the load's MEM is
> re-applied after the bit-insert sequence, reusing SET_DEST (load) as the
> move destination. As the load insn is kept here, that rtx is now shared
> between two insns. That is fine for a plain REG, but in the case that the
> dest is a SUBREG, it must not be shared (verify_rtx_sharing ICEs).
>
> Unshare the destination with copy_rtx when building the move.
>
> Bootstrapped/regtested on AArch64, x86-64 and PowerPC.
>
> PR rtl-optimization/126434
>
> gcc/ChangeLog:
>
> * avoid-store-forwarding.cc (process_store_forwarding): Unshare the
> load destination when building the re-extension move.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.dg/pr126434.c: New test.
LGTM.
Jakub