From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 63E8A385702A; Mon, 4 Oct 2021 23:02:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 63E8A385702A From: "arjun.is at lostca dot se" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/95185] Failure to optimize specific kind of sign comparison check Date: Mon, 04 Oct 2021 23:02:38 +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: 11.0 X-Bugzilla-Keywords: easyhack, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: arjun.is at lostca dot se 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: cc 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, 04 Oct 2021 23:02:38 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95185 Arjun Shankar changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |arjun.is at lostca dot se --- Comment #3 from Arjun Shankar --- If the code is compiled as C, gcc produces essentially the same code as cla= ng with some differences in the schedule of instructions: https://godbolt.org/z/8nsq16Pen It's when the code is compiled as C++ that gcc does worse: https://godbolt.org/z/dK8hTEhjr The difference lies in the front-ends. The C front-end already appears to k= now that this is a XOR. testcase.c.004t.original looks like: return (int) (x < 0 ^ y <=3D 0); On the other hand, g++ outputs: return =3D x >=3D 0 =3D=3D y <=3D 0;=