-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Better @sqrt for f32, f64 and f128 #23865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This reverts commit 6ec781d.
f32, f64 and f128 implementations ported from a more recent musl libc. All three are correctly rounded and much faster than the previous implementation.
I investigated the test failure on hexagon and it's weird. Using prints, I've located the problem to here: sqrt.zig:240
When calling That doesn't look like an |
That sounds like an LLVM bug of some kind. If you feel like it, it would be great to get a reduced reproduction of the issue that could be filed upstream. It's still early days for Hexagon support in Zig, so on our end, we should just disable any affected tests on Hexagon; I don't think you need to include a Hexagon-specific workaround in the code. |
Sorry, I didn't mean to push that workaround. I tried but I couldn't reproduce the problem without a call to So now, I revert the that last commit and disable the failing test for hexagon in
correct? |
That's fine. A repro can just be the But it's also fine if you don't feel like going through this process; we can just file an issue and follow up in the future.
Yes, that seems reasonable. It'd be good to place the check as near to the failure as possible so that the working parts keep getting tested. |
This branch contains a zig port of the new musl sqrt function for f32, f64 and f128, found in
lib/libc/musl/src/math/sqrt*.c
I thoroughly tested the port here:
The new functions should be much faster (I only run benchmarks on aarch64 and x86_64, though.)
I ran the following tests on the branch:
stage4/bin/zig build test -Denable-llvm=true -Dskip-release=true -Dskip-non-native=true
stage4/bin/zig build test-std -Dskip-release=true -Dskip-non-native=true
zig test lib/compiler_rt.zig
on arches powerpc, riscv64, riscv32, mipsel, aarch64_be, arm, x86_64, powerpc64, hexagon, mips64el, mips64, sparc, sparc64, mips and x86 viaqemu
.They all pass expect
compiler_rt
on sparc which fails with:LLVM ERROR: SPARCv8 does not handle f128 in calls; pass indirectly
but that test was already failing before my changes.