From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BBCDA385841D; Mon, 24 Oct 2022 20:59:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BBCDA385841D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666645163; bh=XMhzlzKmVoj8p4BvkzjqGB6LDdbKqgIPkTJ+pFhEwgE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=pHyVyv1898hkiueTE07H8fu9l4vIKYDrgFyx+2C6t78YdyWcVmuO+rClDExhbW41D sGHjaakd5ymwdIBcVdhNGxg3c/H0YRWRgMtOvyzA/FO+anU5aYSjc8OX/A0+vsr0cu IdX8TGwc/BhVVw9Xx5YQ1HelELT4+1RFMBqT7K1o= From: "jacob at jacob dot remcomp.fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/107370] long double sqrtl constant folding is wrong Date: Mon, 24 Oct 2022 20:59:23 +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: 10.2.1 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jacob at jacob dot remcomp.fr 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107370 --- Comment #18 from jacob navia --- I can=E2=80=99t reply you because you do not accept accented characters, ju= st plain ascii, and my mailer uses a French Accentuated character to say =C2=AB You wrote =C2=BB and the whole message = is translated into mime/html. I posted my reply in the bug mailer=20 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107370 Jacob > Le 24 oct. 2022 =C3=A0 22:50, gcc-bugzilla@gcc.gnu.org a =C3=A9crit : >=20 > Attachments with a MIME type of "text/html" are not allowed on this insta= llation.=20 >=20 > jacob navia wrote: >>=20 >>=20 >>> Le 24 oct. 2022 =C3=83 22:21, jakub at gcc dot gnu.org a =C3=83=C2=A9crit : >>>=20 >>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107370 >>>=20 >>> --- Comment #12 from Jakub Jelinek --- >>> I have to agree with Joseph (on x86_64-linux I get): >>> #define _GNU_SOURCE >>> #include >>> #include >>>=20 >>> int >>> main () >>> { >>> volatile _Float128 x =3D __builtin_sqrtf128(2.0f128); >>> char buf[256]; >>> strfromf128 (buf, 128, "%a", x); >>> strfromf128 (buf + 128, 128, "%.36f", x); >>> printf ("%s\t%s\n", buf, buf + 128); >>> x =3D x * x; >>> strfromf128 (buf, 128, "%a", x); >>> strfromf128 (buf + 128, 128, "%.36f", x); >>> printf ("%s\t%s\n", buf, buf + 128); >>> // The value you want to see >>> x =3D 0x1.6a09e667f3bcc908b2fb1366dc6dp+0f128; >>> strfromf128 (buf, 128, "%a", x); >>> strfromf128 (buf + 128, 128, "%.36f", x); >>> printf ("%s\t%s\n", buf, buf + 128); >>> x =3D x * x; places. >>=20 >>> strfromf128 (buf, 128, "%a", x); >>> strfromf128 (buf + 128, 128, "%.36f", x); >>> printf ("%s\t%s\n", buf, buf + 128); >>> } >>>=20 >>> 0x1.6a09e667f3bcc908b2fb1366ea95p+0 1.41421356237309504880168872420= 9697984 >>> 0x1.ffffffffffffffffffffffffffffp+0 1.99999999999999999999999999999= 9999807 >>> 0x1.6a09e667f3bcc908b2fb1366dc6dp+0 1.41421356237309504880168872420= 9000027 >>> 0x1.ffffffffffffffffffffffffd7f4p+0 1.99999999999999999999999999999= 8025537 >>>=20 >>> Clearly the value GCC uses for sqrtf128(2.0f128) multiplied by itself i= s 1ulp >>> smaller than 2.0, >>> while the value you want to see is 10252ulps smaller than 2.0. >>>=20 >>> --=20 >>> You are receiving this mail because: >>> You reported the bug. >>=20 >> Sorry but the program I used was compiled with gcc. It suffers from lack= of precision too. >>=20 >> In ANY case, in decimal now, the square root of 2 is >> 1.414 213 562 373 095 048 801 688 724 209 698 078 GP PARI calculator >> 1.414 213 562 373 095 145 547 462 185 874 gcc: only the first 15 digits = are OK >> ^^^^^=20 >> In ANOTHER example: >> #include >> #include >>=20 >> int main(void) { printf("%.30Lg \n",sqrtl(powl(2,225))); } >>=20 >> This produces: >> 7.34301663720716943338259962711e+33 >> But bc produces=20 >> ~/lcc/book/test % bc >> bc 1.06 >> Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc. >> This is free software with ABSOLUTELY NO WARRANTY. >> For details type `warranty'.=20 >> scale=3D32 >> sqrt(2^225) >> 7343016637207168931428032607349397.48923080385562326502615381523522 >>=20 >> To make things clearer I put now the results side by side >> 7.34301663720716943338259962711e+33 gcc >> 734301663720716 8931428032607349397.48923080385562326502615381523522 bc >>=20 >> As you can see, after the 15th digits all others are wrong!!! >>=20 >> Jacob=