[libc-commits] [PATCH] D130629: [libc] Change sinf range reduction to mod pi/16 to be shared with cosf.

Tue Ly via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Jul 27 08:47:22 PDT 2022


lntue added inline comments.


================
Comment at: libc/src/math/generic/range_reduction.h:82
 
-  return static_cast<int64_t>(k_hi + k_lo);
+  return static_cast<int64_t>(k_hi) + static_cast<int64_t>(k_lo);
 }
----------------
orex wrote:
> From my point of view, this line can be changed to `static_cast<int64_t>(k_hi + k_low)`, because `k_hi` and `k_low` are already "integer", so you can do one static cast instead of two. Probably it can increase performance.
This is actually a must, since there are inputs which makes `k_hi < 2^54` and `k_hi + k_lo > 2^54`, causing rounding errors on the last integral bits due to rounding.  If we work it out carefully and adjust a bit, we might be able to avoid these rounding errors.  But for simplicity, I went with casting both to int64 in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130629



More information about the libc-commits mailing list