From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 249F73870849; Thu, 19 Nov 2020 13:02:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 249F73870849 From: "mhillen at linux dot ibm.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/92294] alias attribute generates incorrect code Date: Thu, 19 Nov 2020 13:02:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 4.8.4 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: mhillen at linux dot ibm.com X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rsandifo at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2020 13:02:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D92294 --- Comment #8 from Marius Hillenbrand --- >>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 elimin= ate the read from b (reusing the const 1 from b=3D1). the rtl addresses a via the section anchor yet b via its symbol reference: b =3D 1 becomes (set (reg/f:DI 62) (symbol_ref:DI ("b") [flags 0x602] )) (set (mem/c:SI (reg/f:DI 62) [1 b+0 S4 A32]) (const_int 1 [0x1])) vs a=3D2 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 dr= op 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] ) 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).=