From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9B5333858D3C; Sun, 28 May 2023 00:32:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9B5333858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685233956; bh=2GdrSnEav18JTmOhOB3FhOWbFRH3OR4V1tUeAry6EuI=; h=From:To:Subject:Date:From; b=FP7bSQVqdxR47qGt5Toy8EnabCfpaUNN7zvZYRsGAkDFkYJ5Q4EsXd4KuelpnWGWQ 4caWw/5errtwCLczFHyLVSSiNXyncDkd8vYQUaqqtxp1JBEMrHBdzXFEq3TNCpdQVH E5jyRKqYRE6/3NiCxPIw7WDGk5xP8f3XwAd9nvyg= From: "vincent-gcc at vinc17 dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/110011] New: -mfull-toc yields incorrect _Float128 constants on power9 Date: Sun, 28 May 2023 00:32:35 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 8.3.1 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=3D110011 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, bu= t 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 n= ot 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]), an= d I did some tests with it. It appears that when -mfull-toc is provided, the cause is incorrect _Float1= 28 constants MPFR_FLOAT128_MAX and -MPFR_FLOAT128_MAX, where one has #define MPFR_FLOAT128_MAX 0x1.ffffffffffffffffffffffffffffp+16383f128 Indeed, I added _Float128 m =3D MPFR_FLOAT128_MAX, n =3D -MPFR_FLOAT128_MAX; at the beginning of the mpfr_set_float128 function in src/set_float128.c, a= nd did the following: 1. Compile MPFR (and the testsuite) using CFLAGS=3D"-mcpu=3Dpower9 -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 =3D 5.96937875341074040910051755689516189e-4947 (gdb) print n $2 =3D 1.19416736664469867978830578385372193e-4946 Both are wrong. If I do the same test with CFLAGS=3D"-mcpu=3Dpower9 -O0 -g" (i.e. without -mfull-toc), then I get (gdb) print m $1 =3D 1.18973149535723176508575932662800702e+4932 (gdb) print n $2 =3D -1.18973149535723176508575932662800702e+4932 These are the expected values. Unfortunately, I couldn't reproduce the issue with a simple C program.=