From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AA79E3858D38; Thu, 26 Jan 2023 12:37:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA79E3858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674736662; bh=KixgYWdy9PUKT5MPkGEN9j990UvilmP0D18PrrsopDw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZvB4xX0fGrozn5slLIcCj881D/5LqIBukkkld4BPcJJEZMGblt3EQuZedZRzgYb3Q HIp8u+5nIP6mfcmcS2ZBiMLgD401YhWlr+56nMgRsEBe20hRIvglKNSSxq81K4L2gt VRPcV+ahM7I4FVtWW5oc9rVors+f3o+/MQ5gkS2U= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/108540] [13 Regression] Frange miscompilation of ruby since r13-3261 Date: Thu, 26 Jan 2023 12:37:42 +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: NEW 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=3D108540 --- Comment #5 from Jakub Jelinek --- --- gcc/range-op-float.cc.jj 2023-01-16 09:39:36.191929750 +0100 +++ gcc/range-op-float.cc 2023-01-26 13:33:48.712018907 +0100 @@ -607,6 +607,10 @@ foperator_equal::fold_range (irange &r, { if (op1 =3D=3D op2) r =3D range_true (type); + // If one operand is -0.0 and other 0.0, they are still equal. + else if (real_iszero (&op1.lower_bound ()) + && real_iszero (&op2.lower_bound ())) + r =3D range_true (type); else r =3D range_false (type); } @@ -617,7 +621,18 @@ foperator_equal::fold_range (irange &r, frange tmp =3D op1; tmp.intersect (op2); if (tmp.undefined_p ()) - r =3D range_false (type); + { + // If one range is [whatever, -0.0] and another + // [0.0, whatever2], we don't know anything either, + // because -0.0 =3D=3D 0.0. + if ((real_iszero (&op1.upper_bound ()) + && real_iszero (&op2.lower_bound ())) + || (real_iszero (&op1.lower_bound ()) + && real_iszero (&op2.upper_bound ()))) + r =3D range_true_and_false (type); + else + r =3D range_false (type); + } else r =3D range_true_and_false (type); } fixes both testcases, but I'm afraid I need to look at other relations too = with -0.0 =3D=3D 0.0 in mind.=