Skip to content

Commit 27a8477

Browse files
committed
Add sfence after non-temporal stores on x86
We definitely need fences there, see: https://doc.rust-lang.org/core/arch/x86/fn._mm_sfence.html Even more interesting, the discussion on NT stores in Rust: rust-lang/rust#114582 And on broken NT stores in LLVM: llvm/llvm-project#64521 Oh boy ...
1 parent ac9c40a commit 27a8477

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

benches/memcpy.rs

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ unsafe fn memcpy_avx(mut src: *const u8, mut dst: *mut u8, count: usize) {
3939
_mm_prefetch::<_MM_HINT_T2>(src as *const i8);
4040
dst = dst.add(32);
4141
}
42+
_mm_sfence();
4243
}
4344

4445
#[cfg(all(any(target_arch = "x86", target_arch = "x86_64"), target_feature = "sse", target_feature = "avx512f"))]
@@ -51,6 +52,7 @@ unsafe fn memcpy_avx512(mut src: *const u8, mut dst: *mut u8, count: usize) {
5152
_mm_prefetch::<_MM_HINT_T2>(src as *const i8);
5253
dst = dst.add(64);
5354
}
55+
_mm_sfence();
5456
}
5557

5658
#[cfg(all(target_arch = "aarch64", target_feature = "neon"))]

0 commit comments

Comments
 (0)