https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64025
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Just to explain more why the strcpy.c testcase breaks.
During postreload cse, we have:
(insn 63 61 70 5 (set (mem/c:QI (plus:SI (reg:SI 5 di [87])
(const:SI (plus:SI (unspec:SI [
(symbol_ref:SI ("p") [flags 0x2] <var_decl
0x7f4bb4427990 p>)
] UNSPEC_GOTOFF)
(const_int 1 [0x1])))) [0 MEM[(void *)&p + 1B]+0 S1
A8])
(const_int 0 [0]))
/usr/src/gcc/gcc/testsuite/gcc.c-torture/execute/builtins/strcpy.c:22 93
{*movqi_internal}
(nil))
...
(insn 111 109 113 7 (set (mem/c:SI (plus:SI (reg:SI 5 di [87])
(const:SI (unspec:SI [
(symbol_ref:SI ("p") [flags 0x2] <var_decl
0x7f4bb4427990 p>)
] UNSPEC_GOTOFF))) [0 MEM[(void *)&p]+0 S4 A8])
(const_int 1145258561 [0x44434241]))
/usr/src/gcc/gcc/testsuite/gcc.c-torture/execute/builtins/strcpy.c:26 90
{*movsi_internal}
(nil))
and when trying to invalidate memories because of the insn 111 store, we call
find_base_term on:
(plus:SI (value:SI 23:23 @0x2068db0/0x205e3f0)
(const:SI (plus:SI (unspec:SI [
(symbol_ref:SI ("p") [flags 0x2] <var_decl 0x7ffff1865990
p>)
] UNSPEC_GOTOFF)
(const_int 1 [0x1]))))
(from the 63 instruction, stored in cselib stuff), and
ix86_delegitimize_address returns
(plus:SI (minus:SI (value:SI 23:23 @0x2068db0/0x205e3f0)
(symbol_ref:SI ("_GLOBAL_OFFSET_TABLE_")))
(const:SI (plus:SI (symbol_ref:SI ("p") [flags 0x2] <var_decl
0x7ffff1865990 p>)
(const_int 1 [0x1]))))
and finally find_base_term returns
(symbol_ref "_GLOBAL_OFFSET_TABLE_") (incorrectly), and then call
find_base_term on:
(plus:SI (reg:SI 5 di [87])
(const:SI (unspec:SI [
(symbol_ref:SI ("p") [flags 0x2] <var_decl 0x7ffff1865990 p>)
] UNSPEC_GOTOFF)))
(directly from the insn, so no VALUEs yet), and as ORIGINAL_REGNO of di is 87 -
the pic reg pseudo, we delegitimize that to
(symbol_ref:SI ("p") [flags 0x2] <var_decl 0x7ffff1865990 p>)
and find_base_term on that is that symbol, and thus we think those two memory
stores don't overlap.