From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 63AB43858D1E; Sat, 1 Oct 2022 02:59:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 63AB43858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664593153; bh=u2EMg6zUaMYdhgaB6SN0agFz7+zZhwdQTGx87iEq8z4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ECDec3tgNI96pcMFnRiNwZW6YZ7Cg132QA/eMU1AuaognkXjP/lpb06xQmgflwPgC 8lJUTex198Ch6D5NJf7fBKB9y7frFDc73WTo3I81Uivy2UipB5YwrehqsTl4vp7Sry Ejh5MFqe3DJuCIYirdeptBeclUaNzrqtDVXjJ66Q= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/107107] Wrong codegen from TBAA when stores to distinct same-mode types are collapsed? Date: Sat, 01 Oct 2022 02:59:13 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: unknown X-Bugzilla-Keywords: alias, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107107 --- Comment #2 from Andrew Pinski --- Confirmed. I don't think it is exactly TBAA which is causing the issue but rather the way PRE does aliasing walks. Take: ``` static inline void set_longish(int is_long, void *p, long x) { if (is_long) *(long*)p =3D x; else *(long long*)p =3D x; } static long test(long long *p, int index, int mode) { *p =3D 1; set_longish(mode, p+index, 2); return *p; } long (*volatile vtest)(long long*, int, int) =3D test; #include int main(void) { long long x; long result =3D vtest(&x, 0, 0); printf("%lu/%llu\n", result, x); } ``` Which is only difference by which order the if statement (and mode which is swapped). This case works.=