From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D73643858CDB; Thu, 9 Mar 2023 13:25:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D73643858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678368310; bh=C0GefnTEdZVozfAXmPaauaGHNf0ObhetA6KlFPlWa0c=; h=From:To:Subject:Date:In-Reply-To:References:From; b=eWQS3LjtRhvOo4ntNLkA3yCB1ZQhAsP079hXSQ4nFms6uRB/2evOJNmkFCODnjX5q iLrucxQITCbFgoNMDbTrJf4zbWWRsfnf0Bi843mKWoPD6ADDhFcFjhO6wg8/ququeP cprndfsy8ZqwbXbJA/IRU2bOyYlEFPoR79eTD0Qg= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109008] [13 Regression] Wrong code in scipy package since r13-3926-gd4c2f1d376da6f Date: Thu, 09 Mar 2023 13:25:10 +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: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED 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=3D109008 --- Comment #47 from Jakub Jelinek --- For the !MODE_HAS_INFINITIES, perhaps --- gcc/range-op-float.cc.jj 2023-03-09 13:12:05.248873234 +0100 +++ gcc/range-op-float.cc 2023-03-09 14:21:51.959802517 +0100 @@ -2216,6 +2216,7 @@ float_widen_lhs_range (tree type, const return ret; REAL_VALUE_TYPE lb =3D lhs.lower_bound (); REAL_VALUE_TYPE ub =3D lhs.upper_bound (); + bool lb_inf =3D false, ub_inf =3D false; if (real_isfinite (&lb)) { frange_nextafter (TYPE_MODE (type), lb, dconstninf); @@ -2238,6 +2239,14 @@ float_widen_lhs_range (tree type, const real_arithmetic (&tem, PLUS_EXPR, &lhs.lower_bound (), &lb); real_arithmetic (&lb, RDIV_EXPR, &tem, &dconst2); } + if (!MODE_HAS_INFINITIES (TYPE_MODE (type)) + && frange_val_is_min (lhs.lower_bound (), type)) + { + /* If type doesn't have infinities, then the minimum acts + as kind of infinity. Turn it into a true infinity. */ + real_inf (&lb, true); + lb_inf =3D true; + } } if (real_isfinite (&ub)) { @@ -2256,6 +2265,14 @@ float_widen_lhs_range (tree type, const real_arithmetic (&tem, PLUS_EXPR, &lhs.upper_bound (), &ub); real_arithmetic (&ub, RDIV_EXPR, &tem, &dconst2); } + if (!MODE_HAS_INFINITIES (TYPE_MODE (type)) + && frange_val_is_max (lhs.upper_bound (), type)) + { + /* If type doesn't have infinities, then the maximum acts + as kind of infinity. Turn it into a true infinity. */ + real_inf (&ub, false); + ub_inf =3D true; + } } /* Temporarily disable -ffinite-math-only, so that frange::set doesn't reduce the range back to real_min_representable (type) as lower bound @@ -2266,6 +2283,15 @@ float_widen_lhs_range (tree type, const ret.clear_nan (); ret.union_ (lhs); flag_finite_math_only =3D save_flag_finite_math_only; + if (lb_inf || ub_inf) + { + if (ret.kind () =3D=3D VR_VARYING) + ret.m_kind =3D VR_RANGE; + if (lb_inf) + ret.m_min =3D lb; + if (ub_inf) + ret.m_max =3D ub; + } return ret; } except that the members are private and so the above will not compile. We'd need some kind of set_unsafe or whatever that would allow to override those even when it is not canonical. But given that I'm not sure if even the forward operations result in correct ranges around these non-infinity "infinities", doing something with it is perhaps premature.=