From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D29053848434; Mon, 14 Jun 2021 13:45:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D29053848434 From: "stefansf at linux dot ibm.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/101066] New: Wrong code after fixup_cfg3 Date: Mon, 14 Jun 2021 13:45:20 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: stefansf at linux dot ibm.com 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: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone cf_gcctarget Message-ID: 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: Mon, 14 Jun 2021 13:45:20 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101066 Bug ID: 101066 Summary: Wrong code after fixup_cfg3 Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: stefansf at linux dot ibm.com Target Milestone: --- Target: s390*-*-*, x86_64-*-* int a =3D 1, c, d, e; int *b =3D &a; static int g(int *h) { c =3D *h; return d; } static void f(int *h) { e =3D *h; *b =3D 0; g(h); } int main() { f(b); printf("%d\n", c); } Running `gcc t.c -Os && ./a.out` results in printed 1 whereas 0 is expected. This does not happen for -O[0,1,2,3] i.e. there 0 is printed. Prior fixup_cfg3 the code looks good to me and afterwards the assignment to= c uses a cached/initial value of variable a which is wrong: int main () { int * b.0_1; int c.1_2; int _6; int _7; int * b.2_8; int _10; int _11; [local count: 1073741824]: b.0_1 =3D b; _6 =3D *b.0_1; _7 =3D _6; e =3D _7; b.2_8 =3D b; *b.2_8 =3D 0; _10 =3D _6; c =3D _10; _11 =3D d; c.1_2 =3D c; printf ("%d\n", c.1_2); return 0; } Reproducible on IBM Z as well as x86_64 using commit 831589c227c.=