[libc-commits] [libc] [libc][math] Implement an integer-only version of double precision sin with 1 ULP errors. (PR #184752)
Simon Tatham via libc-commits
libc-commits at lists.llvm.org
Thu Mar 5 07:07:39 PST 2026
statham-arm wrote:
This looks pretty good to me! I tested on Armv7-A with no hardware FP, using a slightly hacked-up version of the `mathbench` tool found in Arm Optimized Routines (https://github.com/ARM-software/optimized-routines/blob/master/math/test/mathbench.c), running on a Fast Model (so the timings are only instruction counts, not true performance from real hardware).
| Implementation | Time per call |
| ---- | ----- |
| This integer sin | 971.98 |
| picolibc + my optimized FP arithmetic | 1205.55 |
| picolibc + standard compiler-rt | 2271.92 |
| llvm-libc's current sin | 6778.69 |
I guess llvm-libc's current sin is trying for 0.5 ULP accuracy, so it's not really solving the same problem? I don't know for sure what picolibc's accuracy/speed tradeoff is either, but it seems likely it's similar to this.
But it does look as if using integer arithmetic is a win, even with all the speedup that my own uncommitted patch series can give to the emulated-FP strategy.
This is all using reasonably small input values (up to ±π). I haven't benchmarked the range reduction on really large inputs.
https://github.com/llvm/llvm-project/pull/184752
More information about the libc-commits
mailing list