public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/114746] New: With FLT_EVAL_METHOD = 2, -fexcess-precision=fast reduces the precision of floating-point constants
@ 2024-04-16 17:51 vincent-gcc at vinc17 dot net
  2024-04-17 23:18 ` [Bug c/114746] " vincent-gcc at vinc17 dot net
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: vincent-gcc at vinc17 dot net @ 2024-04-16 17:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114746

            Bug ID: 114746
           Summary: With FLT_EVAL_METHOD = 2, -fexcess-precision=fast
                    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=standard, after an assignment or a cast, the value is
converted to its semantic type; this conversion makes the program slower, hence
-fexcess-precision=fast to have faster programs *without sacrificing their
accuracy* in average (except for programs that are based on such a conversion).
Said otherwise, the values may be kept with more precision than normally
expected.

Thus it is not expected that -fexcess-precision=fast reduces the precision of a
value.

However, with FLT_EVAL_METHOD = 2, -fexcess-precision=fast reduces the
precision of floating-point constants compared to what is specified by the
standard. This is a much worse issue.

Testcase:

#include <stdio.h>
#include <float.h>

int main (void)
{
  printf ("FLT_EVAL_METHOD = %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=fast, I get:

FLT_EVAL_METHOD = 2
0xa.bcc77118461cefdp-30
0xa.bcc77118461dp-30
0x1.5798ee2308c3ap-27
0x1.5798eep-27

instead of the expected output (e.g. by using -fexcess-precision=standard)

FLT_EVAL_METHOD = 2
0xa.bcc77118461cefdp-30
0xa.bcc77118461cefdp-30
0x1.5798ee2308c3ap-27
0x1.5798ee2308c3ap-27

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-05-01 23:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-16 17:51 [Bug c/114746] New: With FLT_EVAL_METHOD = 2, -fexcess-precision=fast reduces the precision of floating-point constants vincent-gcc at vinc17 dot net
2024-04-17 23:18 ` [Bug c/114746] " vincent-gcc at vinc17 dot net
2024-04-17 23:23 ` [Bug c/114746] With FLT_EVAL_METHOD = 2, -fexcess-precision=fast reduces the precision of floating-point constants and floating-point constant expressions vincent-gcc at vinc17 dot net
2024-04-19 16:50 ` jsm28 at gcc dot gnu.org
2024-04-22  9:23 ` vincent-gcc at vinc17 dot net
2024-04-22 12:35 ` jakub at gcc dot gnu.org
2024-04-22 21:50 ` vincent-gcc at vinc17 dot net
2024-05-01 23:37 ` vincent-gcc at vinc17 dot net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).