[libc-commits] [PATCH] D118157: [libc] Improve hypotf performance with different algorithm correctly rounded to all rounding modes.

Paul Zimmermann via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Jan 26 06:07:33 PST 2022


zimmermann6 requested changes to this revision.
zimmermann6 added a comment.
This revision now requires changes to proceed.

I get some errors for rounding to nearest:

  Difference for 0x1.faf49ep+25,0x1.480002p+23
  llvm_hypot: 0x1.00c5bp+26
  as_hypot:   0x1.00c5b2p+26
  pz_hypot:   0x1.00c5b2p+26
  }}}



================
Comment at: libc/src/math/generic/hypotf.cpp:29-30
+  // Compute the rounding error with Dekker's algorithm.
+  double err = ((sumSq - xSq) - ySq) + ((sumSq - ySq) - xSq);
+
+  // Take sqrt in double precision.
----------------
I hadn't seen that trick to compute the rounding error, do you have a reference?
By the way, I'm not sure the reference to Dekker is appropriate. For me, Dekker's algorithm splits
two floating-point numbers in two each, and computes their product (high + low part) using 4 multiplies.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118157/new/

https://reviews.llvm.org/D118157



More information about the libc-commits mailing list