-
Notifications
You must be signed in to change notification settings - Fork 13k
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
f128
symbols on powerpc64 give inaccurate results
#125109
Comments
cc @ecnelises @rustbot label +F-f16_and_f128 +A-ABI +T-libs +C-bug -needs-triage |
This is being caused by a calling convention mismatch; the Rust version passes/returns the |
That is interesting. Any idea what is best to do here? |
This is the equivalent of #116344 but for PowerPC; LLVM will generate builtins calls using whatever target features are enabled for the current function. For another example (compiler explorer) #![feature(f16, f128)]
#[inline(never)]
pub fn soft_float(x: f128, dest: &mut f16) {
*dest = x as f16;
}
#[inline(never)]
#[target_feature(enable = "sse2")]
pub unsafe fn hard_float(x: f128, dest: &mut f16) {
*dest = x as f16;
} When the above code is compiled for the The possible solutions I can think of are:
Option 4 is probably the best solution here. Option 2/3 will probably be required for things like #116558, but that's a separate (but closely related) issue. |
For some reason, the
__addkf3
symbol linked by rustc says that0x00000000000000000000000000000000 + 0x00000000000000000000000000000001 = 0x00000000000000000000000000000000
, when the answer should be0x00000000000000000000000000000001
. Other symbols likely do the wrong thing here too.Example:
Our Rust code emits
__addkf3
which calls the hardware f128 addition routinexsaddup
. The part I cannot explain is that the C version also emits__addkf3
which also callsxsaddup
, but somehow produces a correct result. I checked with GDB to make sure they are both hittingxsaddup
, so can't really explain the discrepancy.Original notes at rust-lang/compiler-builtins#606 (comment), discussion on Zulip at https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/f128.20system.20libraries.20noncompliant.20platforms/near/438486364.
Full code copied from rust-lang/compiler-builtins#606 (comment):
Rust code
C code
Assembly generated from Rust (incorrect result)
Assembly generated from C (correct result)
The text was updated successfully, but these errors were encountered: