-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Use -0.0 in intrinsics::simd::reduce_add_unordered
#130325
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//@ revisions: x86_64 aarch64 | ||
//@ assembly-output: emit-asm | ||
//@ compile-flags: --crate-type=lib -O | ||
//@[aarch64] only-aarch64 | ||
//@[x86_64] only-x86_64 | ||
//@[x86_64] compile-flags: -Ctarget-feature=+sse3 | ||
#![feature(portable_simd)] | ||
#![feature(core_intrinsics)] | ||
use std::intrinsics::simd as intrinsics; | ||
use std::simd::*; | ||
// Regression test for https://github.com/rust-lang/rust/issues/130028 | ||
// This intrinsic produces much worse code if you use +0.0 instead of -0.0 because | ||
// +0.0 isn't as easy to algebraically reassociate, even using LLVM's reassoc attribute! | ||
// It would emit about an extra fadd, depending on the architecture. | ||
|
||
// CHECK-LABEL: reduce_fadd_negative_zero | ||
pub unsafe fn reduce_fadd_negative_zero(v: f32x4) -> f32 { | ||
// x86_64: addps | ||
// x86_64-NEXT: movshdup | ||
// x86_64-NEXT: addss | ||
// x86_64-NOT: xorps | ||
|
||
// aarch64: faddp | ||
// aarch64-NEXT: faddp | ||
|
||
// CHECK-NOT: {{f?}}add{{p?s*}} | ||
// CHECK: ret | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In order to mitigate LVI vulnerabilities, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sort of thing is a constant issue with the SGX target. Please PR compiletest with an appropriate modification that handles this issue globally without having to modify each and every single test with "oh yeah, and SGX is special, as usual". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realize I have probably indulged you significantly in the past and I wish to be clear, I do appreciate that Fortanix actually runs the tests in their CI, unlike some, but I must at this point refer to the target tier policy:
Like we really need proper turnkey cross-compile testing support per #130375 or even just an SGX exception built in to compiletest or something, twiddling every single test isn't really sustainable for you or for me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really understand what the appropriate compiletest modification here would be -- unless you are suggesting to skip all assembly tests on SGX? Assembly tests in general are very finicky, you're lucky if they merge in less than 3 cycles, for one reason or another. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A flat skip wouldn't work for them, a nonzero number of assembly tests are specifically for SGX-related codegen. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably, yeah, and that requirement has to go away, which is why I opened #130375 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you not dereference the pointer the first time I linked it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #130375 is an interesting approach, but I don't see how this would avoid issues like the SGX special case. There isn't a special flag you need to add for the test to succeed on SGX. It's the test itself that causes issues. For most of the exceptions we currently have for SGX, they're there because of the test using |
||
intrinsics::simd_reduce_add_unordered(v) | ||
} |
Uh oh!
There was an error while loading. Please reload this page.