From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BA35F3861021; Tue, 26 Jan 2021 08:20:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA35F3861021 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/98829] Different results with -O3 and custom quiet NaN Date: Tue, 26 Jan 2021 08:20:41 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2021 08:20:41 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98829 --- Comment #4 from Richard Biener --- The issue is likely GCC canonicalizing the NaN somewhere and your is_value doing a 1:1 bit comparison. In particular we optimize MyNAN::value to MyNAN::value () { [local count: 1073741824]: return Nan; but ::is_value is MyNAN::is_value (double d) { long unsigned int _2; bool _3; [local count: 1073741824]: _2 =3D VIEW_CONVERT_EXPR(d_1(D)); _3 =3D _2 =3D=3D 9218868437227407042; return _3; MyNAN::value is optimized by CSE via native_encode/interpret. I'm not sure why -O2 vs. -O3 makes a difference in the end but I think your program is ill-formed.=