From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CEEA33858C31; Sun, 1 Oct 2023 23:57:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CEEA33858C31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696204668; bh=iMkYuGmfZEbZIa4VsjSgvdG079ggRQyXve+Z1UAiZDM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ULE4NVGpXJVJJswioTKIUNKk98s4B+jsNmorPW9C4biZ/gioGQrfwsNMH7QxgMzp1 ocNCyIloqe8HBzYyxNuPBZ3gGQovrvhNBwW78M1rgibb6eAmPp1tUPkxwmxzuxFEfy cWZ0H5stAkg8xiN0KcLR3OQnanBjHwHOTcOfI2is= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/111655] wrong code generated for __builtin_signbit and 0./0. on x86-64 -O2 Date: Sun, 01 Oct 2023 23:57:47 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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=3D111655 --- Comment #6 from Andrew Pinski --- (In reply to Paul Eggert from comment #5) > > The match pattern which causes the issue: > > (simplify > > /* signbit(x) -> 0 if x is nonnegative. */ > > (SIGNBIT tree_expr_nonnegative_p@0) > > { integer_zero_node; }) > I don't see anything wrong with that match pattern. >=20 > I speculate that what's wrong is that GCC incorrectly thinks that 0.0/0.0= is > nonnegative. Although it's tempting to say that the sign bit of a division > is the exclusive OR of the sign bits of its operands, evidently this is n= ot > true on x86-64 when NaNs are involved. tree_expr_nonnegative_p for divide does: case RDIV_EXPR: case TRUNC_DIV_EXPR: case CEIL_DIV_EXPR: case FLOOR_DIV_EXPR: case ROUND_DIV_EXPR: return RECURSE (op0) && RECURSE (op1); Since 0.0 and 0.0 both don't have their sign bits set, GCC assumes diving t= hem won't produce a value with the sign bit set ... I really think x86_64 div instruction is broken for IEEE really.=