From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A707438582AE; Thu, 4 Aug 2022 10:23:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A707438582AE From: "kristerw at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106523] New: forwprop miscompile Date: Thu, 04 Aug 2022 10:23:41 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kristerw 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone 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: Thu, 04 Aug 2022 10:23:41 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106523 Bug ID: 106523 Summary: forwprop miscompile Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: kristerw at gcc dot gnu.org Target Milestone: --- The function f7 from testsuite/c-c++-common/rotate-2.c is miscompiled by forwprop. This can be seen by running the function as __attribute__((noinline)) unsigned char f7 (unsigned char x, unsigned int y) { unsigned int t =3D x; return (t << y) | (t >> ((-y) & 7)); } int main (void) { volatile unsigned char x =3D 152; volatile unsigned int y =3D 19; if (f7(x, y) !=3D 4) __builtin_abort (); return 0; } This fails at -O1 and higher optimization levels. What is happening here is that forwprop1 has optimized the function to _10 =3D x_7(D) r<< y_9(D); return _10;=