public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "joseph at codesourcery dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libquadmath/105101] incorrect rounding for sqrtq
Date: Mon, 13 Jun 2022 20:20:15 +0000	[thread overview]
Message-ID: <bug-105101-4-WTfvLqehQa@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-105101-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #22 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
On Mon, 13 Jun 2022, already5chosen at yahoo dot com via Gcc-bugs wrote:

> > The function should be sqrtf128 (present in glibc 2.26 and later on 
> > x86_64, x86, powerpc64le, ia64).  I don't know about support in non-glibc 
> > C libraries.
> 
> x86-64 gcc on Godbolt does not appear to know about it.
> I think, Godbolt uses rather standard Linux with quite new glibc and headers.
> https://godbolt.org/z/Y4YecvxK6

Make sure to define _GNU_SOURCE or __STDC_WANT_IEC_60559_TYPES_EXT__ to 
get these declarations.

> May be. I don't know how to get soft-fp version.

For long double it's sysdeps/ieee754/soft-fp/s_fmal.c in glibc - some 
adjustments would be needed to be able to use that as a version for 
_Float128 (where sysdeps/ieee754/float128/s_fmaf128.c currently always 
uses the ldbl-128 version), in appropriate cases.

> It seems, you didn't pay attention that in my later posts I am giving
> implementations of binary128 *division* rather than sqrtq().

Ah - binary128 division is nothing to do with libquadmath at all (the 
basic arithmetic operations go in libgcc, not libquadmath).  Using a PR 
about one issue as an umbrella discussion of various vaguely related 
things is generally confusing and unhelpful to tracking the status of what 
is or is not fixed.

In general, working out how to optimize the format-generic code in soft-fp 
if possible would be preferred to writing format-specific implementations.  
Note that for multiplication and division there are already various 
choices of implementation approaches that can be selected via macros 
defined in sfp-machine.h.

> BTW, I see no mentioning of rounding control or of any sort of exceptions in
> GCC libquadmath docs. No APIs with names resembling fesetround() or
> mpfr_set_default_rounding_mode().

The underlying arithmetic (in libgcc, not libquadmath) uses the hardware 
rounding mode and exceptions (if the x87 and SSE rounding modes disagree, 
things are liable to go wrong), via various macros defined in 
sfp-machine.h.

  parent reply	other threads:[~2022-06-13 20:20 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29 19:44 [Bug libquadmath/105101] New: " tkoenig at gcc dot gnu.org
2022-03-30 11:34 ` [Bug libquadmath/105101] " fxcoudert at gcc dot gnu.org
2022-03-30 12:15 ` jakub at gcc dot gnu.org
2022-03-30 16:28 ` kargl at gcc dot gnu.org
2022-03-30 16:31 ` kargl at gcc dot gnu.org
2022-04-02 19:33 ` already5chosen at yahoo dot com
2022-04-09 10:09 ` tkoenig at gcc dot gnu.org
2022-04-09 10:23 ` jakub at gcc dot gnu.org
2022-04-09 10:25 ` tkoenig at gcc dot gnu.org
2022-04-09 15:50 ` sgk at troutmask dot apl.washington.edu
2022-04-15 13:49 ` already5chosen at yahoo dot com
2022-04-16 22:54 ` already5chosen at yahoo dot com
2022-04-18 23:57 ` already5chosen at yahoo dot com
2022-04-20 12:57 ` already5chosen at yahoo dot com
2022-04-21 15:09 ` already5chosen at yahoo dot com
2022-06-09  7:52 ` tkoenig at gcc dot gnu.org
2022-06-09  8:03 ` jakub at gcc dot gnu.org
2022-06-10 16:16 ` already5chosen at yahoo dot com
2022-06-10 16:18 ` already5chosen at yahoo dot com
2022-06-10 17:40 ` joseph at codesourcery dot com
2022-06-11 21:15 ` already5chosen at yahoo dot com
2022-06-13 17:59 ` joseph at codesourcery dot com
2022-06-13 20:05 ` already5chosen at yahoo dot com
2022-06-13 20:20 ` joseph at codesourcery dot com [this message]
2022-06-13 20:56 ` already5chosen at yahoo dot com
2022-06-13 22:34 ` joseph at codesourcery dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-105101-4-WTfvLqehQa@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).