From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6FE643858401; Wed, 12 Jul 2023 18:00:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6FE643858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689184847; bh=C/xUh4xeNacwYlwZ3aXhak0gnTmgbZNVJXV7Br04UhI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=T+tZFAsI7HRSuBjrPREjdqvToUsGLcQMBu8Yo6TZkCl/r9NteUY/7pRtSuODKltNH 9x9+O1cF75CeOUXEG9tkgkRmDZkCWsgF0OVCCLy/+MDUSi/MktrvJGdy5aCMD08jpy GLnj0hVhhPTkw6N0kKrm6zSeK7wLxsK3omQBxpVw= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/105832] [13/14 Regression] Dead Code Elimination Regression at -O3 (trunk vs. 12.1.0) Date: Wed, 12 Jul 2023 18:00:46 +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: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.2 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=3D105832 --- Comment #10 from Andrew Pinski --- I think the simple way of fixing this is optimizing: ``` bool f(int g) { return (1 >> g) !=3D 0; } ``` into ``` bool f0(int g) { return g =3D=3D 0; } ``` In threadfull1 (before vrp1) we have: ``` [local count: 894749065]: if (iftmp.0_6 <=3D 1) goto ; [41.00%] else goto ; [59.00%] [local count: 366847113]: _3 =3D (int) iftmp.0_6; _4 =3D 1 >> _3; if (_4 =3D=3D 0) goto ; [50.00%] else goto ; [50.00%] [local count: 183423557]: iftmp.1_12 =3D iftmp.0_6 << 1; [local count: 894749065]: # iftmp.1_7 =3D PHI ``` if we optimize the bb6 to: ``` if (iftmp.0_6 !=3D 0) goto ; [50.00%] else goto ; [50.00%] ``` We should be able to ifcombine the 2 GIMPLE to just: iftmp.0_6 !=3D 0 && iftmp.0_6 <=3D 1 Which then will unswitch correctly ...=