From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B0D6D385220F; Thu, 17 Nov 2022 20:59:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B0D6D385220F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668718758; bh=ltD3WwMab668x9uj+qu2Hg22lIh+ei6ff4pZ3Gwo+tg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rtcl3ZlS4f4vDSLeUaEoTorv/7b5v8U5ykumxapBG6VuyjmKSy+t98KK445DhDqFW 0nGZJW2JsWMaTCpwTIuhHqOj79nMvrkDkSrbLcCY0AWAIIh1zUzVWSdywttmkH4h70 F0wPGeJdwY1XNZUA+2Nf2jBlcbhLsHaC4T8Y5YKc= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107740] [12/13 Regression] if-to-switch conversion happens for simple predicate function when compiled with gcc but not with g++ Date: Thu, 17 Nov 2022 20:59:17 +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: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: everconfirmed target_milestone cf_reconfirmed_on bug_status short_desc 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=3D107740 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Target Milestone|--- |12.3 Last reconfirmed| |2022-11-17 Status|UNCONFIRMED |NEW Summary|if-to-switch conversion |[12/13 Regression] |happens for simple |if-to-switch conversion |predicate function when |happens for simple |compiled with gcc but not |predicate function when |with g++ |compiled with gcc but not | |with g++ --- Comment #2 from Andrew Pinski --- The difference is PHI-OPT: For C++ we have: _4 =3D c_8(D) =3D=3D 13; _5 =3D c_8(D) =3D=3D 9; _6 =3D _4 | _5; if (_6 !=3D 0) goto ; [INV] else goto ; [INV] : : # iftmp.0_7 =3D PHI <1(4), 0(3)> Which phi-opt1 changes to: _4 =3D c_8(D) =3D=3D 13; _5 =3D c_8(D) =3D=3D 9; _6 =3D _4 | _5; : # iftmp.0_7 =3D PHI <1(2), _6(3)> (note type is bool) But for C we have: if (_6 !=3D 0) goto ; [INV] else goto ; [INV] : : # iftmp.0_7 =3D PHI <1(4), 0(3)> (note the type is int) phi-opt1 is the "early phi-opt" which tries not to do it here. Also this is a regression from GCC 11.3.0. There has been improvements to phi-opt and there was slight IR change due to cleanup cfg after cddce1 which allowed phi-opt to do the change here. Note PHI-OPT is not at fault really but if-to-switch not handling the slightly different IR really.=