From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1219B3858CDA; Thu, 10 Nov 2022 19:29:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1219B3858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668108596; bh=F/4T3kfLbzGtoqPYMcBOg170xBJpoSwcf2N58OddueA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fyVKANbt5GSMhiaDwMSWM97me+AGgx+qlzxcCVPPEK49g6rsE9zw+IeM1bw9c3Z6E fx1eq5Y/TwDoxVRTbh39Eh/bhAOIujs70ygJqVJ3qjJS6OCA5WH3e95Ohe0qntLZOG N2Xwk3Arv3kJOWqOrUqCbgnjjgbAuEMXElmw2LkE= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107569] [13 Regression] Failure to optimize std::isfinite since r13-3596 Date: Thu, 10 Nov 2022 19:29:53 +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: jakub at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 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=3D107569 --- Comment #34 from Jakub Jelinek --- (In reply to Aldy Hernandez from comment #33) > (In reply to Jakub Jelinek from comment #31) > > Created attachment 53873 [details] > > gcc13-pr107569-div.patch > >=20 > > This is what I meant by complete nightmare - division. >=20 > We can take this to gcc-patches when you're done, but just a few thoughts= ... >=20 > + // If +-0.0 is in both ranges, it is a maybe NAN. > + if (real_compare (LE_EXPR, &lh_lb, &dconst0) > + && real_compare (GE_EXPR, &lh_ub, &dconst0) > + && real_compare (LE_EXPR, &rh_lb, &dconst0) > + && real_compare (GE_EXPR, &rh_ub, &dconst0)) >=20 > Perhaps we could provide frange::contains_zero_p ()? Well, contains_p in irange is a method on the value range, while here we do= n't have a frange, but just naked REAL_VALUE_TYPEs. It is twice contains_zero_p... >=20 > + // +-0.0 / +-0.0 or +-INF / +-INF is a known NAN. > + if ((real_iszero (&lh_lb) > + && real_iszero (&lh_ub) > + && real_iszero (&rh_lb) > + && real_iszero (&rh_ub)) >=20 > This looks like frange::contains_zerp_p () as well. No, this is twice zero_p. Due to signed zeros it isn't a singleton + contains_zero_p, just both boundaries are zero. > + || (real_isinf (&lh_lb) > + && real_isinf (&lh_ub, real_isneg (&lh_lb)) > + && real_isinf (&rh_lb) > + && real_isinf (&rh_ub, real_isneg (&rh_lb)))) >=20 > Note that, real_isinf with only one argument checks for +-INF. I know. I'm intentionally using one and 2 argument ones to verify that lh is either [INF,INF] or [-INF,-INF], but not [-INF,INF]. > But I think > what you're looking for is frange::maybe_isinf. Again, that works on frange, which I don't have here. >=20 > Could your patch be simplified with some of these? >=20 > // fpclassify like API > bool known_isfinite () const; > bool known_isnan () const; > bool known_isinf () const; > bool maybe_isnan () const; > bool maybe_isnan (bool sign) const; > bool maybe_isinf () const; > bool signbit_p (bool &signbit) const; > bool nan_signbit_p (bool &signbit) const; >=20 > We should ultimately avoid peeking at the end points unnecessarily in ord= er > to prepare ourselves for next release when we (hopefully) have sub-ranges. No, see above (at least for now). The peeking at the end points is needed because those end points behave weirdly.=