]> gcc.gnu.org Git - gcc.git/commit
Handle arithmetic on eliminated address indices [PR116413]
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 27 Aug 2024 08:48:28 +0000 (09:48 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 27 Aug 2024 08:48:28 +0000 (09:48 +0100)
commit708ee71808ea61758e73d0e36274b4194b28576a
tree4264f4519f950fba8e3af54697d495bb0f232245
parent9db997e5ac4a206b9428eb2447fcdc90e37725f4
Handle arithmetic on eliminated address indices [PR116413]

This patch fixes gcc.c-torture/compile/opout.c for m68k with LRA
enabled.  The test has:

...
z (a, b)
{
  return (int) &a + (int) &b + (int) x + (int) z;
}

so it adds the address of two incoming arguments.  This ends up
being treated as an LEA in which the "index" is the incoming
argument pointer, which the LEA multiplies by 2.  The incoming
argument pointer is then eliminated, leading to:

(plus:SI (plus:SI (ashift:SI (plus:SI (reg/f:SI 24 %argptr)
                (const_int -4 [0xfffffffffffffffc]))
            (const_int 1 [0x1]))
        (reg/f:SI 41 [ _6 ]))
    (const_int 20 [0x14]))

In the address_info scheme, the innermost plus has to be treated
as the index "term", since that's the thing that's subject to
index_reg_class.

gcc/
PR middle-end/116413
* rtl.h (address_info): Update commentary.
* rtlanal.cc (valid_base_or_index_term_p): New function, split
out from...
(get_base_term, get_index_term): ...here.  Handle elimination PLUSes.
gcc/rtl.h
gcc/rtlanal.cc
This page took 0.067074 seconds and 6 git commands to generate.