From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 94C8B3858D20; Wed, 5 Apr 2023 19:47:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 94C8B3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680724035; bh=sKM8JlNRIDs1wkmZqo7xdycR6rWtcRfMfIqEV3rIhEg=; h=From:To:Subject:Date:From; b=ix9isoEoDWyddQdln9cKoXFLZ9bUJns6v39MHfxWX1l26dgz3lz+qWEQpy0BQBGq6 A+xKJzuv+neWwwyKyPbxupZ/NegKBypNHjjMwqaDhuW5OUk96wBVBnQFNW0xUAhwmL FeEKrGuuAqH2kLcyh6W+PquvHKIYeIOEX9a2p6Jo= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109424] New: ~ Date: Wed, 05 Apr 2023 19:47:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D109424 Bug ID: 109424 Summary: ~ Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: pinskia at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` int f(int x, int y) { int t =3D ((x > y) ? x : y); return ~t; } int f1(int x, int y) { return ~((x > y) ? x : y); } ``` You would assume GCC produce the same code for both, but nope, the first f = is worse. The reason why is GCC decides to move the ~ into the ?: operator making the code worse. fold does this "optimization" but nothing undones it, phi-opt undones it for casts in some but not all cases.=