From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 80FD1385783D; Sat, 10 Jul 2021 16:26:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 80FD1385783D From: "roger at nextmovesoftware dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101403] [12 Regression] wrong code with __builtin_bswap16() at -O1 by r12-2137 Date: Sat, 10 Jul 2021 16:26:23 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: roger at nextmovesoftware dot com X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: roger at nextmovesoftware dot com X-Bugzilla-Target-Milestone: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status assigned_to 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: Sat, 10 Jul 2021 16:26:23 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101403 Roger Sayle changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |roger at nextmoveso= ftware dot com --- Comment #3 from Roger Sayle --- Testing a fix. Sorry for the inconvenience. An even more reduced test case= is: unsigned int foo (unsigned int a) { unsigned int u; /* b =3D=3D 0x8000 */ unsigned short b =3D __builtin_bswap16 (a); /* result =3D 0x0008 */ // This works: return b >> 12; // This doesn't: return b >> (u, 12); } int main (void) { unsigned int x =3D foo (0x80); if (x !=3D 0x0008) __builtin_abort (); return 0; } The change in signedness of the right shift (from logical to arithmetic) triggers an oversight in my recent folding optimization.=