From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 524283858416; Mon, 15 Nov 2021 08:35:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 524283858416 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/55177] missed optimizations with __builtin_bswap Date: Mon, 15 Nov 2021 08:35:33 +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: 4.7.2 X-Bugzilla-Keywords: missed-optimization, TREE X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: pinskia 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 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, 15 Nov 2021 08:35:34 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D55177 --- Comment #22 from Andrew Pinski --- (In reply to Andrew Pinski from comment #20) > So the original testcase shows there are missing other bitop related > optimizations on the tree level and conversions. > I have two patches which fix the original issue. > The first patch also fixes: > unsigned foo(unsigned x, int b) > { > int a =3D x; > a &=3D b; > x =3D a; > x |=3D b; > return x; > } > --- CUT --- > The problem here is: > a_3 =3D (int) x_2(D); > a_5 =3D a_3 & b_4(D); > x_6 =3D (unsigned int) a_5; >=20 > is not optimized to: > _7 =3D (unsigned int) b_4(D); > x_6 =3D _6 & x_2(D); >=20 > Which shows up in testcase in comment #0: > _2 =3D __builtin_bswap32 (x.0_1); > a_6 =3D (int) _2; > a_7 =3D a_6 & 1515936861; > a.1_3 =3D (unsigned int) a_7; > _4 =3D __builtin_bswap32 (a.1_3); >=20 > Fixing the bitop with convert, we get rid of the two byteswaps in comment= #0. That I happened to file as PR 103228 a few days ago but only on accident wh= ile looking into a different issue. Since PR 60669 is now fixed, I will test my original patch to fix this.=