From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C0B16385DC1C; Thu, 16 Apr 2020 15:35:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C0B16385DC1C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587051300; bh=E+jWqgtv3oCmrg/TH4E2N00s0V+XZoibEd5qoG47Vnk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=pbNX2ciXP9GS98LBa3jKJXihYMrZXGzfYxIkw5Y0ch9he/XkTe/o282tOR2RVARvV 3eMISYMx1Th+v3Sj2t/R+ScKVjTsntuhH7dn/nGoaJTxIjqrniSvTq/46PQnLf7Q5X yALT87hznza26ynCzzjZ6Q9wauiaak3QVsD9CO3Y= From: "vincent-gcc at vinc17 dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/34678] Optimization generates incorrect code with -frounding-math option (#pragma STDC FENV_ACCESS not implemented) Date: Thu, 16 Apr 2020 15:35:00 +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: 4.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vincent-gcc at vinc17 dot net X-Bugzilla-Status: NEW 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: Thu, 16 Apr 2020 15:35:00 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D34678 --- Comment #43 from Vincent Lef=C3=A8vre -= -- Note that the effect of changing the rounding mode after a computation, whe= ther -frounding-math is used or not, is not just that the change of rounding mode may not be honored. If can yield inconsistencies in a block where the round= ing mode is not changed. #include #include #include #pragma STDC FENV_ACCESS ON #define CST 0x1p-200 int main (void) { volatile double a =3D CST; double b =3D a, c =3D a, d; printf ("%a\n", 1.0 - b); fesetround (FE_DOWNWARD); printf ("%a\n", 1.0 - c); if (b =3D=3D c && b =3D=3D CST && c =3D=3D CST) { printf ("%d\n", 1.0 - b =3D=3D 1.0 - c); printf ("1: %a\n", 1.0 - b); printf ("2: %a\n", 1.0 - c); d =3D b =3D=3D CST ? b : (abort (), 1.0); printf ("3: %a\n", 1.0 - d); d =3D b =3D=3D CST ? b : 1.0; printf ("4: %a\n", 1.0 - d); } return 0; } With -std=3Dc17 -frounding-math -O3 -lm, I get: 0x1p+0 0x1.fffffffffffffp-1 0 1: 0x1p+0 2: 0x1.fffffffffffffp-1 3: 0x1p+0 4: 0x1.fffffffffffffp-1=