public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/110011] New: -mfull-toc yields incorrect _Float128 constants on power9
@ 2023-05-28  0:32 vincent-gcc at vinc17 dot net
  2023-05-28  3:41 ` [Bug target/110011] -mfull-toc (-mfp-in-toc) " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: vincent-gcc at vinc17 dot net @ 2023-05-28  0:32 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110011
           Summary: -mfull-toc yields incorrect _Float128 constants on
                    power9
           Product: gcc
           Version: 8.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincent-gcc at vinc17 dot net
  Target Milestone: ---

Note: I selected version 8.3.1, because this is what I had for my tests, but at
least 13.1.0 is still affected (see below).

We got a report of a GNU MPFR failure on an IBM POWER9 machine:
https://sympa.inria.fr/sympa/arc/mpfr/2023-05/msg00000.html

With additional information given in a private discussion, Matthew R. Wilson
found that the failure came from the use of -mfull-toc in CFLAGS (this is not
visible in the report mentioned above), and he could reproduce the behavior
with GCC 13.1.0, 12.2.0, as well as the Debian-provided GCC 10.2.1. As he
noticed, -mfull-toc is documented to be the default, so that this shouldn't
have any effect.

I could reproduce the failure on gcc135 at the Compile Farm with
/opt/at12.0/bin/gcc
(gcc (GCC) 8.3.1 20190304 (Advance-Toolchain-at12.0) [revision 269374]), and I
did some tests with it.

It appears that when -mfull-toc is provided, the cause is incorrect _Float128
constants MPFR_FLOAT128_MAX and -MPFR_FLOAT128_MAX, where one has

#define MPFR_FLOAT128_MAX 0x1.ffffffffffffffffffffffffffffp+16383f128

Indeed, I added

  _Float128 m = MPFR_FLOAT128_MAX, n = -MPFR_FLOAT128_MAX;

at the beginning of the mpfr_set_float128 function in src/set_float128.c, and
did the following:

1. Compile MPFR (and the testsuite) using
   CFLAGS="-mcpu=power9 -O0 -g -mfull-toc"
2. In the "tests" directory, gdb ./tset_float128
3. Add a breakpoint on mpfr_set_float128, then run, next, and print values:

(gdb) print m
$1 = 5.96937875341074040910051755689516189e-4947
(gdb) print n
$2 = 1.19416736664469867978830578385372193e-4946

Both are wrong.

If I do the same test with CFLAGS="-mcpu=power9 -O0 -g" (i.e. without
-mfull-toc), then I get

(gdb) print m
$1 = 1.18973149535723176508575932662800702e+4932
(gdb) print n
$2 = -1.18973149535723176508575932662800702e+4932

These are the expected values.

Unfortunately, I couldn't reproduce the issue with a simple C program.

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

end of thread, other threads:[~2024-01-14 21:55 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-28  0:32 [Bug target/110011] New: -mfull-toc yields incorrect _Float128 constants on power9 vincent-gcc at vinc17 dot net
2023-05-28  3:41 ` [Bug target/110011] -mfull-toc (-mfp-in-toc) " pinskia at gcc dot gnu.org
2023-05-28  3:54 ` pinskia at gcc dot gnu.org
2023-05-30  6:47 ` linkw at gcc dot gnu.org
2023-05-30  7:51 ` vincent-gcc at vinc17 dot net
2023-05-30  8:09 ` linkw at gcc dot gnu.org
2023-05-30  8:11 ` linkw at gcc dot gnu.org
2023-06-12  6:10 ` cvs-commit at gcc dot gnu.org
2023-06-19  9:29 ` cvs-commit at gcc dot gnu.org
2023-06-20  3:20 ` cvs-commit at gcc dot gnu.org
2023-06-20  3:21 ` cvs-commit at gcc dot gnu.org
2023-06-20  8:24 ` cvs-commit at gcc dot gnu.org
2023-06-20  8:27 ` LpSolit at gmail dot com

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).