From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 30D263858C27; Thu, 26 Jan 2023 11:41:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 30D263858C27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674733265; bh=n8SFWBP3N4UPbWrwj55FnvdIQnq4G0EkwEICx5xXjmY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=q1BdlRNTB+Lb6/Lb1DnFmtacGgHtwGJl+iI/XrzBp7SoyZCsV7gOR5o97wD8bgM53 IKWqJOiOLTh/k/VW0GkYaw71qhuBbRSVxQRntZ0QrJ1a9H1nyxX4qbO4vxy1ert87n bQnwAg0L9oSFSdZIFAPYXJ3liydHSq5uMqONFPVw= 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 11:41:04 +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 #3 from Jakub Jelinek --- I think int foo (int x, double d) { if (x =3D=3D 42) d =3D -0.0; if (d =3D=3D 0.0) return 42; return 12; } behaves similarly with threading. The above function is basically return (= x =3D=3D 42 || d =3D=3D 0.0) ? 42 : 12; In forwprop1 at -O2 we still have correct: : if (x_3(D) =3D=3D 42) goto ; [INV] else goto ; [INV] : : # d_1 =3D PHI if (d_1 =3D=3D 0.0) goto ; [INV] else goto ; [INV] : // predicted unlikely by early return (on trees) predictor. : # RANGE [irange] int [-INF, +INF] NONZERO 0x2e # _2 =3D PHI <42(5), 12(4)> but then comes ethread and turns that into: : if (x_3(D) =3D=3D 42) goto ; [INV] else goto ; [INV] : # d_5 =3D PHI <-0.0(2)> goto ; [100.00%] : # d_1 =3D PHI if (d_1 =3D=3D 0.0) goto ; [INV] else goto ; [INV] : // predicted unlikely by early return (on trees) predictor. : # RANGE [irange] int [-INF, +INF] NONZERO 0x2e # _2 =3D PHI <42(5), 12(4), 12(3)> as if -0.0 =3D=3D 0.0 was false rather than true.=