-
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
Certain simd math operations imply fast-math
, but operation naming does not make it apparent
#84268
Comments
I just tried this with |
The optimization is correct from LLVM's perspective, because rustc is emitting This is done here: rust/compiler/rustc_codegen_llvm/src/intrinsic.rs Line 1078 in 7af1f55
The change was made in #50521. This is almost certainly wrong under rust semantics. Based on the comments there, possibly the intention was to set just |
Hmm, the LLVM docs don't seem to indicate |
The documentation for
And amongst the implied ones:
In this particular case the property that's exploited is that the result is assumed to not be |
I made a PR for this at #84274. Somebody else will have to coordinate changes to |
fast-math
, but operation naming does not make it apparent
fast-math
, but operation naming does not make it apparentfast-math
, but operation naming does not make it apparent
Don't set fast-math for the SIMD operations we set it for previously Instead of `fast-math`. `fast-math` implies things like functions not being able to accept as an argument or return as a result, say, `inf` which made these functions confusingly named or behaving incorrectly, depending on how you interpret it. It seems that the intended behaviour was to set a `afn` flag instead. In doing so we also renamed the intrinsics to say `_approx` so that it is clear these are not precision oriented and the users can act accordingly. Fixes rust-lang#84268
In the following,
is_infinite
is optimized to always return zero, but it should instead performfabs
andcmp
:It works correctly in debug, and fails in release.
Playground link: https://play.rust-lang.org/?version=nightly&mode=release&edition=2018&gist=49b790d5e14139e6bea9e57b0ae381d5
The problem is related to
simd_fabs
, because instdsimd
we are currently usingsimd_xor
instead ofsimd_fabs
and that optimizes correctly.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: