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

--- Comment #8 from Marius Hillenbrand <mhillen at linux dot ibm.com> ---
>From my current understanding, gcc addresses a and b in two different ways,
which is not handled correctly by the dependency analysis / alias analysis
while employed by the cse1 pass, and then causes cse1 to incorrectly eliminate
the read from b (reusing the const 1 from b=1).

the rtl addresses a via the section anchor yet b via its symbol reference:

b = 1 becomes
(set (reg/f:DI 62) (symbol_ref:DI ("b") [flags 0x602]  <var_decl .. b>))
(set (mem/c:SI (reg/f:DI 62) [1 b+0 S4 A32]) (const_int 1 [0x1]))

vs

a=2 becomes
(set (reg/f:DI 64) (symbol_ref:DI ("*.LANCHOR0") [flags 0x182]))
(set (mem/c:SI (plus:DI (reg/f:DI 64) (const_int 4 [0x4])) [1 a+0 S4 A32])
(const_int 2 [0x2]))

when visiting the write to a, cse1 should identify the aliasing and thus drop
the "remembered" b. for that, cse iterates its hash table and compares all
present MEM rtx to the new address (cse.c:invalidate()).

that step compares (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>)

the comparison of these two (in alias.c:write_dependence_p()) falsely claims
that there is no anti-dependence between the two.

I am not certain yet how that comparison is supposed to work with section
anchors. It looks like we either fail to reconnect (anchor + 4) to the
symbol_ref of "a" (so we could identify both symbol_refs as equivalent) or lose
the offset relative to the anchor (so we could see that both have the same
offset relative to the anchor).

Reply via email to