From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C72753858C50; Tue, 28 Mar 2023 13:19:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C72753858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680009577; bh=/YBfL8Tj9gKAUPnlElG++y57J9M0gX9QpL9jbhpvNZM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Qya1S7zQP4IXOr3uqkCDPKJt5+QwzPf/FYCsWsEjFR2zRn62ZgGzuBRhVSx4zu0O+ kiZL5zSkXcbOcrdlz3Y/fBfQQeGXNXuJXQ9kWoeffOi8QWjzhwO50QYR/XTa7qlJaJ aSoFyzDuN/KVUS+bIznzWwDTcA91k6nlj+K0yUjk= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109154] [13 regression] jump threading de-optimizes nested floating point comparisons Date: Tue, 28 Mar 2023 13:19: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: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth 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: 13.0 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=3D109154 --- Comment #29 from Richard Biener --- For the testcase in comment#26 we see that if-conversion from if (distbb_170 >=3D 0.0) goto ; [59.00%] else goto ; [41.00%] [local count: 311875831]: ... if (distbb_170 < iftmp.0_97) goto ; [20.00%] else goto ; [80.00%] [local count: 62375167]: ... [local count: 528603100]: # prephitmp_153 =3D PHI <0.0(42), _158(44), chrg_init_70(41)> produces _102 =3D distbb_170 >=3D 0.0; _109 =3D iftmp.0_97 > distbb_170; _104 =3D _102 & _109; _86 =3D iftmp.0_97 <=3D distbb_170; _87 =3D _86 & _102; _ifc__124 =3D _87 ? 0.0 : _158; _ifc__123 =3D _104 ? _158 : _ifc__124; _122 =3D distbb_170 < 0.0; prephitmp_153 =3D _122 ? chrg_init_70 : _ifc__123; so from two comparisons it ends up generating four (two inverted) and three COND_EXPRs. There's optimization to explicitely negate but the _85 =3D iftmp.0_97 > distbb_170 _86 =3D ~_85; that's originally created gets CSEd and then, when _109 is substituted, folded to the inverted comparison (by match.pd:5069). At least the last COND_EXPR could have recovered the original compare by swapping the COND_EXPR arms - best the if-conversion code emission should do this itself. It currently emits _102 =3D distbb_170 >=3D 0.0; _145 =3D distbb_170 >=3D 0.0; _158 =3D chrg_init_70 * iftmp.3_159; _109 =3D iftmp.0_97 > distbb_170; _104 =3D _102 & _109; _85 =3D iftmp.0_97 > distbb_170; _86 =3D ~_85; _87 =3D _86 & _102; _ifc__124 =3D _87 ? 0.0 : _158; _ifc__123 =3D _104 ? _158 : _ifc__124; _122 =3D ~_145; prephitmp_153 =3D _122 ? chrg_init_70 : _ifc__123; so that micro-optimization would help us a little bit here. I have a patch in testing to do that.=