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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Richard Sandiford <rsand...@gcc.gnu.org>:

https://gcc.gnu.org/g:ac6d433b02ce26a646b2a7254b1d87fcc06b0beb

commit r15-3288-gac6d433b02ce26a646b2a7254b1d87fcc06b0beb
Author: Richard Sandiford <richard.sandif...@arm.com>
Date:   Thu Aug 29 14:00:23 2024 +0100

    Allow subregs around constant displacements [PR116516]

    This patch fixes a regression introduced by g:708ee71808ea61758e73.
    x86_64 allows addresses of the form:

      (zero_extend:DI (subreg:SI (symbol_ref:DI "foo") 0))

    Before the previous patch, a lax SUBREG check meant that we would
    treat the subreg as a base and reload it into a base register.
    But that wasn't what the target was expecting.  Instead we should
    treat "foo" as a constant displacement, to match:

            leal foo, <dest>

    After the patch, we recognised that "foo" isn't a base register,
    but ICEd on it rather than handling it as a displacement.

    With or without the recent patches, if the address had instead been:

      (zero_extend:DI
        (subreg:SI (plus:DI (reg:DI R) (symbol_ref:DI "foo") 0)))

    then we would have treated "foo" as the displacement and R as the base
    or index, as expected.  The problem was that the code that does this was
    rejecting all subregs of objects, rather than just subregs of variable
    objects.

    gcc/
            PR middle-end/116516
            * rtlanal.cc (strip_address_mutations): Allow subregs around
            constant displacements.

    gcc/testsuite/
            PR middle-end/116516
            * gcc.c-torture/compile/pr116516.c: New test.

Reply via email to