From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7FC14385841D; Mon, 24 Oct 2022 20:21:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7FC14385841D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666642903; bh=fwaS+2u6dxy/p16JECEoxhcOlTc6L5tFvLIbpUry6A8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=oOA4Vu9U+NzbBXqrRzvjqegtbX0TkrdybQ4zqB6YS+BlaCK5ewFqLl3cxPn6ZSiOs 0Dq4kwv3P5RGUz3aUan7WWsG9Pv3C+5AfH+auxjw1+pMbpGQw/ZTLoUJ5Jh5cbhOv4 gaD8GP+7umRIDqcZk9ZLd8Oa4itN1o6PidE0Xd7Q= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/107370] long double sqrtl constant folding is wrong Date: Mon, 24 Oct 2022 20:21:43 +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: jakub at gcc dot gnu.org 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 #12 from Jakub Jelinek --- I have to agree with Joseph (on x86_64-linux I get): #define _GNU_SOURCE #include #include 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; strfromf128 (buf, 128, "%a", x); strfromf128 (buf + 128, 128, "%.36f", x); printf ("%s\t%s\n", buf, buf + 128); } 0x1.6a09e667f3bcc908b2fb1366ea95p+0 1.414213562373095048801688724209697= 984 0x1.ffffffffffffffffffffffffffffp+0 1.999999999999999999999999999999999= 807 0x1.6a09e667f3bcc908b2fb1366dc6dp+0 1.414213562373095048801688724209000= 027 0x1.ffffffffffffffffffffffffd7f4p+0 1.999999999999999999999999999998025= 537 Clearly the value GCC uses for sqrtf128(2.0f128) multiplied by itself is 1u= lp smaller than 2.0, while the value you want to see is 10252ulps smaller than 2.0.=