Hi, Digging into a test case failure with section anchors, I found dependence analysis return false negatives, leading to bad optimization by cse1. Two variables are synthetically constructed aliases. One is addressed relative to the section anchor and the other using a symbol ref, yet write_dependence_p() claims that they could not alias. I can reproduce that miscompile on aarch64, ppc64, and s390x. How is write_dependence_p() supposed to handle such cases with section anchors?
Example: (simplified version of gcc.c-torture/execute/alias-2.c) int off; // causing nonzero offset of a to the section anchor int a; extern int b __attribute__ ((alias("a"))); /* ... */ int main() b=1; <-- uses symbol_ref to b a=2; <-- uses the section anchor + offset 4 if (b!=2) __builtin_abort (); return 0; } so write_dependence gets to compare the canonicalized addresses (const:DI (plus:DI (symbol_ref:DI ("*.LANCHOR0") [flags 0x182]) (const_int 4 [0x4]))) and (symbol_ref:DI ("b") [flags 0x602] <var_decl b>) and I believe there are two ideas in the code, which could apply to this scenario: (a) identify anchor+4 being equal to the symbol_ref for a (in canonicalization?), (b) instead lookup (symbol_ref "b") -> a -> anchor+4, identify the shared section anchor and compare offsets (compare_base_symbol_refs appears to attempt that; yet find_base_term has dropped a's offset to the section anchor), or (c) that I am not aware of? How is that analysis supposed to drill into the addresses? (see also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92294 for the initial report on aarch64 and my full example) Marius -- Marius Hillenbrand Linux on Z development IBM Deutschland Research & Development GmbH Vors. des Aufsichtsrats: Gregor Pillen / Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294