-
Notifications
You must be signed in to change notification settings - Fork 214
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
Fix incorrect rounding with subnormal/zero results of float multiplication #637
Conversation
There has to be a bug in either GCC or LLVM's libraries at least on some platforms for f128, I was able to reproduce in C llvm/llvm-project#91840. The clippy failure is from #634 (comment) |
01a7c0c
to
01b0b37
Compare
Probably just |
Allowing the lint results in the contradictory
so I've added a temporary |
CI is now green 🎉. Thanks for the help. |
// FIXME(f16_f128): rounding error | ||
// FIXME(#616): re-enable once fix is in nightly | ||
// <https://github.com/rust-lang/compiler-builtins/issues/616> | ||
"mul_f128", | ||
"mul_f32", | ||
"mul_f64", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why will these be fixed with the nightly bump? I guess if __mul[sd]f3
don't exist since they are expected to lower to assembly, then linking the extern "C"
symbols is linking to the weak ones from this library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your guess is correct.
testcrate/src/bench.rs
Outdated
// FIXME(f16_f128): Incorrect rounding. | ||
// <https://github.com/llvm/llvm-project/issues/91840> | ||
const AARCH64_SKIPPED: &[&str] = &["mul_f128"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this must have been reproduced in CI then, which is good. Any idea where the problem is coming from? https://github.com/llvm/llvm-project/blob/8598bcb9934dca16ea16d87304e00defc85d986c/compiler-rt/lib/builtins/fp_lib.h and https://github.com/llvm/llvm-project/blob/8598bcb9934dca16ea16d87304e00defc85d986c/compiler-rt/lib/builtins/fp_mul_impl.inc don't seem to have any architecture-specific behavior except for fmaxf
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just reproduced the bug using the instructions from llvm/llvm-project#91840 on x86_64-unknown-linux-gnu
; I don't think the bug is platform specific, just compiler-rt
specific. It only shows up on AArch64 in CI as that's the only architecture tested in compiler-builtins
CI that used to build the C version of the builtin in the version of compiler-builtins
currently used by nightly rustc
(in the build.rs
that's currently used by nightly, notice how multf3.c
is only included on aarch64/arm64ec, mips64 and loongarch64).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the FIXME
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah great, guess I just didn't test this on other platforms. Thanks for testing
Fix float multiplication that results in subnormals (or zero), and enable tests for those cases. Also remove dead code left over from when this was ported from
compiler-rt
(the other branches of theif
statement are unreachable asshift
is always less thanbits
at this point). The equivalent code incompiler-rt
does not have this bug.Fixes #616