public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: 'GNU C Library' <libc-alpha@sourceware.org>
Subject: [PATCH v2 4/9] math: Use an improved algorithm for hypot (dbl-64)
Date: Thu, 28 Oct 2021 15:19:23 +0000	[thread overview]
Message-ID: <VE1PR08MB5599F681F87C0DE5490B6B6483869@VE1PR08MB5599.eurprd08.prod.outlook.com> (raw)

Hi Adhemerval,

On AArch64 the new version is ~25% slower even after removing wrappers.
Using the faster checks for special cases helps here too of course. However
there is another issue: issignaling is not inlined, forcing a frame to be created
plus several callee-saves. This fixes it:

  if (!isfinite(x) || !isfinite(y))
  {
    if ((isinf (x) || isinf (y))
        && !issignaling_inline (x) && !issignaling_inline (y))
      return INFINITY;
    return x + y;
  }

This gave a 20% speedup, so it is now only a little slower than before.
We could rename the inline function to __issignaling I suppose, and then
it should be used as long as you include math_config.h.

+  h = math_narrow_eval (h * scale);
+  math_check_force_underflow_nonneg (h);
+  return h;

I don't think you need math_check_force_underflow_nonneg at all given
h * scale should already set the underflow flag correctly. Removing this
gives performance within ~2% of the original.

Wilco

             reply	other threads:[~2021-10-28 15:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-28 15:19 Wilco Dijkstra [this message]
2021-10-28 17:19 ` Joseph Myers
2021-10-29 12:38   ` Wilco Dijkstra
2021-10-29 16:20     ` Joseph Myers
  -- strict thread matches above, loose matches on Subject: below --
2021-10-25 11:57 [PATCH v2 0/9] Improve hypot() Adhemerval Zanella
2021-10-25 11:57 ` [PATCH v2 4/9] math: Use an improved algorithm for hypot (dbl-64) 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=VE1PR08MB5599F681F87C0DE5490B6B6483869@VE1PR08MB5599.eurprd08.prod.outlook.com \
    --to=wilco.dijkstra@arm.com \
    --cc=adhemerval.zanella@linaro.org \
    --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).