From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 51A5E38582BD; Wed, 7 Jun 2023 22:48:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 51A5E38582BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686178117; bh=aIKqBDjYU1tzVwHL5vJ6VaioRJ7A0r1HXDoHD9wExPY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=sGp1G89RY3rTBQt4Dm1dzwMcjTl1r8eTaIKGQGq7p1VCdCxQ5NrZq1DZO1ZPV/nNb pNGlui7c9zIMNgALVjKN8wnttp2uN/biW+m3+4mnS5PlgRpDwhFtouRwfG3CIinvMF 7CcnAhYteST9YUX23ACIpzoI0mSzaMl29FacNTKE= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109959] `(a > 1) ? 0 : (a == 1)` is not optimized when spelled out at -O2+ Date: Wed, 07 Jun 2023 22:48:37 +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: 14.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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109959 --- Comment #6 from Andrew Pinski --- (In reply to Andrew Pinski from comment #5) > This is basically PR 102138 . Except it works at -O1 because the cast is pushed out of the phi by phiopt = but the cast is the same as a & 1 here :(. For comment #0 we could just match this for unsigned type a_2(D) > 1 ? 0 : a_2(D) =3D=3D a_2(D) <=3D 1 ? a_2(D) : 0 -> (unsigned)(a = =3D=3D 1) For comment #3 we need to pattern match this now: _7 =3D (_Bool) a_6(D); _9 =3D a_6(D) <=3D 1; _10 =3D _7 & _9;=