From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 768503858C41; Tue, 16 Apr 2024 17:51:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 768503858C41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713289877; bh=KREJ2L8FiyVesBRZf5u6+3dQrMT6UTfGOJ0FMQKKufw=; h=From:To:Subject:Date:From; b=We9T6XC6wCu/22al5H+4C67gQL4uhMpJjTGV3kGwdEcQwoIGWNWX4ls4hwqiuNhaF 52okoDhQtk8Qb3fzLKAnWgOyrAgumOBHmwy7hkVuHmbImLM+SRxiInJl9GW/de4AHe UABABuvaBUXDUAdS2T0vjc4kDpbDYDn+5fAJQK2E= From: "vincent-gcc at vinc17 dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/114746] New: With FLT_EVAL_METHOD = 2, -fexcess-precision=fast reduces the precision of floating-point constants Date: Tue, 16 Apr 2024 17:51:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vincent-gcc at vinc17 dot net 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D114746 Bug ID: 114746 Summary: With FLT_EVAL_METHOD =3D 2, -fexcess-precision=3Dfast reduces the precision of floating-point constants Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: vincent-gcc at vinc17 dot net Target Milestone: --- -fexcess-precision was added to resolve bug 323, so that with -fexcess-precision=3Dstandard, after an assignment or a cast, the value is converted to its semantic type; this conversion makes the program slower, h= ence -fexcess-precision=3Dfast to have faster programs *without sacrificing their accuracy* in average (except for programs that are based on such a conversi= on). Said otherwise, the values may be kept with more precision than normally expected. Thus it is not expected that -fexcess-precision=3Dfast reduces the precisio= n of a value. However, with FLT_EVAL_METHOD =3D 2, -fexcess-precision=3Dfast reduces the precision of floating-point constants compared to what is specified by the standard. This is a much worse issue. Testcase: #include #include int main (void) { printf ("FLT_EVAL_METHOD =3D %d\n", FLT_EVAL_METHOD); printf ("%La\n%La\n", 1e-8L, (long double) 1e-8); printf ("%a\n%a\n", (double) 1e-8, (double) 1e-8f); return 0; } With GCC 14.0.1 20240330 (experimental) [master r14-9728-g6fc84f680d0] using -m32 -fexcess-precision=3Dfast, I get: FLT_EVAL_METHOD =3D 2 0xa.bcc77118461cefdp-30 0xa.bcc77118461dp-30 0x1.5798ee2308c3ap-27 0x1.5798eep-27 instead of the expected output (e.g. by using -fexcess-precision=3Dstandard) FLT_EVAL_METHOD =3D 2 0xa.bcc77118461cefdp-30 0xa.bcc77118461cefdp-30 0x1.5798ee2308c3ap-27 0x1.5798ee2308c3ap-27=