nontemporal_store: make sure that the intrinsic is truly just a hint - #128149
Conversation
|
Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 Some changes occurred in compiler/rustc_codegen_gcc |
This comment has been minimized.
This comment has been minimized.
05e50ef to
8d0d26e
Compare
e2efa65 to
d1e92af
Compare
|
It's a bit sad if this becomes an actual no-op on x86, nontemporal stores can be (very rarely) very useful. Is this usable through anything else than mm_stream_* and friends? These functions already contain a safety note that a fence has to be used after them. |
Those intrinsic functions are, in the latest commits to |
|
So mm_stream will still emit nontemporal instructions on x86? Thanks for clarifying! |
|
Yes it will, that's why rust-lang/stdarch#1541 needs to propagate first. |
|
Ok, great, then I misunderstood this change, sorry! |
|
Thank you, @RalfJung. |
0135bb1 to
697787a
Compare
|
rust-lang/stdarch#1541 has propagated, so this should be good to go. We haven't heard from @fmease though so let's re-roll the reviewer dice. r? compiler |
| const WELL_BEHAVED_NONTEMPORAL_ARCHS: &[&str] = | ||
| &["aarch64", "arm", "riscv32", "riscv64"]; |
There was a problem hiding this comment.
Question [REV1 (2/2)]: If I understand it correctly, the codegen test is modified such that it only codegens for aarch64-unknown-linux-gnu target, but here we have 4 "well-behaved" architectures that we do emit !nontemporal for.
|
r? jieyouxu |
jieyouxu
left a comment
There was a problem hiding this comment.
Thanks, feel free to r=me,Amanieu,Jubilee after maybe fixing the nit :3
b1eca7b to
5be6c7d
Compare
|
@bors r=jieyouxu,Amanieu,Jubilee |
5be6c7d to
75743dc
Compare
|
@bors r=jieyouxu,Amanieu,Jubilee |
The
!nontemporalflag for stores in LLVM sounds like it is just a hint, but actually, it is not -- at least on x86, non-temporal stores need very special treatment by the programmer or else the Rust memory model breaks down. LLVM still treats these stores as-if they were normal stores for optimizations, which is highly dubious. Let's avoid all that dubiousness by making our own non-temporal stores be truly just a hint, which is possible on some targets (e.g. ARM). On all other targets, non-temporal stores become regular stores.Blocked on rust-lang/stdarch#1541 propagating to the rustc repo, to make sure the_mm_streamintrinsics are unaffected by this change.Fixes #114582
Cc @Amanieu @workingjubilee