https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120721

--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Richard Sandiford <[email protected]>:

https://gcc.gnu.org/g:8130a2ad91ca8571b099ba020443fadab7a688ca

commit r16-1621-g8130a2ad91ca8571b099ba020443fadab7a688ca
Author: Richard Sandiford <[email protected]>
Date:   Mon Jun 23 08:46:27 2025 +0100

    vregs: Use force_subreg when instantiating subregs [PR120721]

    In this PR, we started with:

        (subreg:V2DI (reg:DI virtual-reg) 0)

    and vregs instantiated the virtual register to the argument pointer.
    But:

        (subreg:V2DI (reg:DI ap) 0)

    is not a sensible subreg, since the argument pointer certainly can't
    be referenced in V2DImode.  This is (IMO correctly) rejected after
    g:2dcc6dbd8a00caf7cfa8cac17b3fd1c33d658016.

    The vregs code that instantiates the subreg above is specific to
    rvalues and already creates new instructions for nonzero offsets.
    It is therefore safe to use force_subreg instead of simplify_gen_subreg.

    I did wonder whether we should instead say that a subreg of a
    virtual register is invalid if the same subreg would be invalid
    for the associated hard registers.  But the point of virtual registers
    is that the offsets from the hard registers are not known until after
    expand has finished, and if an offset is nonzero, the virtual register
    will be instantiated into a pseudo that contains the sum of the hard
    register and the offset.  The subreg would then be correct for that
    pseudo.  The subreg is only invalid in this case because there is
    no offset.

    gcc/
            PR rtl-optimization/120721
            * function.cc (instantiate_virtual_regs_in_insn): Use force_subreg
            instead of simplify_gen_subreg when instantiating an rvalue SUBREG.

    gcc/testsuite/
            PR rtl-optimization/120721
            * g++.dg/torture/pr120721.C: New test.

Reply via email to