From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8C7173861C54; Tue, 6 Jul 2021 08:39:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C7173861C54 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/54571] Missed optimization converting between bit sets Date: Tue, 06 Jul 2021 08:39:30 +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: 4.8.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW 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 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: Tue, 06 Jul 2021 08:39:30 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D54571 --- Comment #2 from Andrew Pinski --- (In reply to Richard Biener from comment #1) > Confirmed. The natural place to optimize this is the tree level phiopt p= ass. >=20 > : > _3 =3D x_2(D) & 2; > if (_3 !=3D 0) > goto ; > else > goto ; >=20 > : > y_5 =3D y_4(D) | 1; >=20 > : > # y_1 =3D PHI >=20 > where we should handle >=20 > int f1(int x, int y, int d) { int tem; if ((tem =3D x & d)) y |=3D tem; r= eturn > y; } >=20 > as well. Yes, that's just y |=3D x & d, but it falls out naturally if the > transform is implemented in a generic enough way. This one should be easy to add to match.pd: (simplify (cond @1 (ior @2 INTEGER_CST@3) @2) (ior @2 (bit_and (negate (convert @1)) @3))) (bit_and (negate (convert thurth_value@1)) integer_onep) should be just converted to: @1 Which is not done right now, I fill that as a bug.=