public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Joseph Myers <joseph@codesourcery.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH 8/9] i386: Move hypot implementation to C
Date: Wed, 6 Oct 2021 16:20:58 -0300	[thread overview]
Message-ID: <7168a3a0-dc2b-a093-2535-408bd55ecedb@linaro.org> (raw)
In-Reply-To: <6d85d3c2-3c4d-dc3b-e87c-141968f947b9@linaro.org>



On 06/10/2021 16:19, Adhemerval Zanella wrote:
> 
> 
> On 06/10/2021 15:37, Joseph Myers wrote:
>> On Wed, 6 Oct 2021, Adhemerval Zanella via Libc-alpha wrote:
>>
>>> +/* The i386 allows ot use the default excess of precision to optimize the
>>
>> s/ot/to/
> 
> Ack.
> 
>>
>>> +   hypot implementation, since internal multiplication and sqrt is carried
>>> +   with 80-bit FP type.  */
>>> +double
>>> +__ieee754_hypot (double x, double y)
>>> +{
>>> +  if ((isinf (x) || isinf (y))
>>> +      && !issignaling (x) && !issignaling (y))
>>> +    return INFINITY;
>>> +  if (isnan (x) || isnan (y))
>>> +    return x + y;
>>> +
>>> +  double r = math_narrow_eval (sqrt (x * x + y * y));
>>
>> There is no guarantee of when excess precision might or might not be used 
>> for intermediate computations, or whether it might not be used (so 
>> resulting in spurious overflows).  I'd expect explicit conversions of x 
>> and y to long double here, use of sqrtl and conversion of the result to 
>> double.
>>
> 
> Something like the below?
> 
>   long double lx = x;
>   long double ly = y;
>   double r = sqrtl (lx * lx + ly * ly);
>   return r;
> 

In fact we need to handle underflow:

  long double lx = x;
  long double ly = y;
  double r = sqrtl (lx * lx + ly * ly);
  math_check_force_underflow_nonneg (r);
  return r;

  reply	other threads:[~2021-10-06 19:21 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-06 18:05 [PATCH 0/9] Improve hypot() Adhemerval Zanella
2021-10-06 18:05 ` [PATCH 1/9] benchtests: Make hypot input random Adhemerval Zanella
2021-10-07  9:48   ` Paul Zimmermann
2021-10-07 11:20     ` Adhemerval Zanella
2021-10-07 17:08     ` Joseph Myers
2021-10-06 18:05 ` [PATCH 2/9] benchtests: Add hypotf Adhemerval Zanella
2021-10-07 10:40   ` Paul Zimmermann
2021-10-06 18:05 ` [PATCH 3/9] math: Simplify hypotf implementation Adhemerval Zanella
2021-10-07  9:44   ` Paul Zimmermann
2021-10-07 11:37     ` Adhemerval Zanella
2021-10-07 12:08       ` Paul Zimmermann
2021-10-06 18:05 ` [PATCH 4/9] math: Use an improved algorithm for hypot (dbl-64) Adhemerval Zanella
2021-10-06 18:05 ` [PATCH 5/9] math: Use an improved algorithm for hypotl (ldbl-96) Adhemerval Zanella
2021-10-06 18:05 ` [PATCH 6/9] math: Use an improved algorithm for hypotl (ldbl-128) Adhemerval Zanella
2021-10-06 18:05 ` [PATCH 7/9] math: Remove powerpc e_hypot Adhemerval Zanella
2021-10-06 19:43   ` Paul E Murphy
2021-10-06 19:46     ` Adhemerval Zanella
2021-10-06 19:51       ` Paul E Murphy
2021-10-12 12:17         ` Paul A. Clarke
2021-10-06 18:05 ` [PATCH 8/9] i386: Move hypot implementation to C Adhemerval Zanella
2021-10-06 18:37   ` Joseph Myers
2021-10-06 19:19     ` Adhemerval Zanella
2021-10-06 19:20       ` Adhemerval Zanella [this message]
2021-10-06 19:52         ` Joseph Myers
2021-10-07  8:28           ` Paul Zimmermann
2021-10-07 17:05             ` Joseph Myers
2021-10-06 18:05 ` [PATCH 9/9] math: Remove the error handling wrapper from hypot and hypotf Adhemerval Zanella
2021-10-06 18:38   ` Joseph Myers
2021-10-06 19:23     ` Adhemerval Zanella
2021-10-07 11:03 ` [PATCH 0/9] Improve hypot() Paul Zimmermann
2021-10-07 12:39   ` Adhemerval Zanella

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=7168a3a0-dc2b-a093-2535-408bd55ecedb@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.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).