Skip to content

Commit ef74616

Browse files
Rollup merge of rust-lang#128149 - RalfJung:nontemporal_store, r=jieyouxu,Amanieu,Jubilee
nontemporal_store: make sure that the intrinsic is truly just a hint The `!nontemporal` flag 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](llvm/llvm-project#64521). 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_stream` intrinsics are unaffected by this change.~~ Fixes rust-lang#114582 Cc `@Amanieu` `@workingjubilee`
2 parents 3de829e + 80a7d5f commit ef74616

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/intrinsics/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,8 @@ fn codegen_regular_intrinsic_call<'tcx>(
725725

726726
// Cranelift treats stores as volatile by default
727727
// FIXME correctly handle unaligned_volatile_store
728-
// FIXME actually do nontemporal stores if requested
728+
// FIXME actually do nontemporal stores if requested (but do not just emit MOVNT on x86;
729+
// see the LLVM backend for details)
729730
let dest = CPlace::for_ptr(Pointer::new(ptr), val.layout());
730731
dest.write_cvalue(fx, val);
731732
}

0 commit comments

Comments
 (0)