From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 69B1B385E021; Mon, 23 May 2022 09:15:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 69B1B385E021 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/105629] [13 Regression] g++.dg/opt/pr94589-2.C for cris, m68k, s390x Date: Mon, 23 May 2022 09:15:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end 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: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc bug_status priority cf_reconfirmed_on cf_gcctarget everconfirmed assigned_to 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, 23 May 2022 09:15:57 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105629 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org Status|UNCONFIRMED |ASSIGNED Priority|P3 |P1 Last reconfirmed| |2022-05-23 Target| |x86_64-*-* Ever confirmed|0 |1 Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot = gnu.org --- Comment #7 from Richard Biener --- Thanks, so the relevant IL change is probably # c$_M_value_3 =3D PHI <-1(3), 0(2), 2(5), 1(4)> _11 =3D (unsigned char) c$_M_value_3; _16 =3D _11 <=3D 1; vs # c$_M_value_3 =3D PHI <-1(3), 0(2), 2(5), 1(4)> _11 =3D (unsigned int) c$_M_value_3; _16 =3D _11 <=3D 1; where the conversion from c$_M_value_3 is now sign-extending which is somet= hing spaceship_replacement does not expect. We how do Matching expression match.pd:2114, generic-match.cc:676 Matching expression match.pd:2121, generic-match.cc:736 Applying pattern match.pd:5497, generic-match.cc:23783 (****) Matching expression match.pd:2114, generic-match.cc:676 Matching expression match.pd:2121, generic-match.cc:736 Matching expression match.pd:2126, generic-match.cc:776 Applying pattern match.pd:5868, generic-match.cc:62355 Applying pattern match.pd:3662, generic-match.cc:27474 Applying pattern match.pd:3742, generic-match.cc:26853 Applying pattern match.pd:3648, generic-match.cc:27432 ;; Function constexpr bool std::operator>=3D(partial_ordering, __cmp_cat::__unspec) (null) ;; enabled by -tree-original <<< Unknown tree: must_not_throw_expr return =3D (unsigned int) __v._M_value <=3D 1 >>>; with the marked (****) folding that eventually you re-disable for GENERIC. In the end we use .SPACESHIP on x86_64 but end up with bool f17 (double i) { bool _2; int _7; bool prephitmp_8; [local count: 1073741824]: _7 =3D .SPACESHIP (i_1(D), 5.0e+0); if (_7 !=3D 0) goto ; [50.00%] else goto ; [50.00%] [local count: 536870913]: if (_7 =3D=3D 1) goto ; [50.00%] else goto ; [50.00%] [local count: 268435456]: _2 =3D i_1(D) > 5.0e+0; [local count: 1073741824]: # prephitmp_8 =3D PHI <1(2), _2(4), 0(3)> return prephitmp_8; which is a regression from GCC 12. I think the non-widening constraint can be relaxed. Indeed the following fixes it - Jakub, is there anything that would prevent sign-extending to work? diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 8c9c46d41f1..e61d9736937 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -2217,7 +2217,7 @@ spaceship_replacement (basic_block cond_bb, basic_blo= ck middle_bb, if (!TYPE_UNSIGNED (ty2) || !INTEGRAL_TYPE_P (ty2)) return false; - if (TYPE_PRECISION (ty1) !=3D TYPE_PRECISION (ty2)) + if (TYPE_PRECISION (ty1) > TYPE_PRECISION (ty2)) return false; if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (orig_use_lhs)) return false;=