Skip to content

Commit e5bfd0d

Browse files
committed
non-temporal stores: use inline assembly
1 parent 6daeb66 commit e5bfd0d

File tree

6 files changed

+59
-18
lines changed

6 files changed

+59
-18
lines changed

crates/core_arch/src/x86/avx.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -1707,7 +1707,11 @@ pub unsafe fn _mm256_lddqu_si256(mem_addr: *const __m256i) -> __m256i {
17071707
#[cfg_attr(test, assert_instr(vmovntps))] // FIXME vmovntdq
17081708
#[stable(feature = "simd_x86", since = "1.27.0")]
17091709
pub unsafe fn _mm256_stream_si256(mem_addr: *mut __m256i, a: __m256i) {
1710-
intrinsics::nontemporal_store(mem_addr, a);
1710+
crate::arch::asm!(
1711+
"vmovntps [{mem_addr}], {a}",
1712+
mem_addr = in(reg) mem_addr,
1713+
a = in(ymm_reg) a,
1714+
);
17111715
}
17121716

17131717
/// Moves double-precision values from a 256-bit vector of `[4 x double]`
@@ -1730,7 +1734,11 @@ pub unsafe fn _mm256_stream_si256(mem_addr: *mut __m256i, a: __m256i) {
17301734
#[stable(feature = "simd_x86", since = "1.27.0")]
17311735
#[allow(clippy::cast_ptr_alignment)]
17321736
pub unsafe fn _mm256_stream_pd(mem_addr: *mut f64, a: __m256d) {
1733-
intrinsics::nontemporal_store(mem_addr as *mut __m256d, a);
1737+
crate::arch::asm!(
1738+
"vmovntps [{mem_addr}], {a}",
1739+
mem_addr = in(reg) mem_addr,
1740+
a = in(ymm_reg) a,
1741+
);
17341742
}
17351743

17361744
/// Moves single-precision floating point values from a 256-bit vector
@@ -1754,7 +1762,11 @@ pub unsafe fn _mm256_stream_pd(mem_addr: *mut f64, a: __m256d) {
17541762
#[stable(feature = "simd_x86", since = "1.27.0")]
17551763
#[allow(clippy::cast_ptr_alignment)]
17561764
pub unsafe fn _mm256_stream_ps(mem_addr: *mut f32, a: __m256) {
1757-
intrinsics::nontemporal_store(mem_addr as *mut __m256, a);
1765+
crate::arch::asm!(
1766+
"vmovntps [{mem_addr}], {a}",
1767+
mem_addr = in(reg) mem_addr,
1768+
a = in(ymm_reg) a,
1769+
);
17581770
}
17591771

17601772
/// Computes the approximate reciprocal of packed single-precision (32-bit)

crates/core_arch/src/x86/avx512f.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -28014,7 +28014,11 @@ pub unsafe fn _mm_mask_testn_epi64_mask(k: __mmask8, a: __m128i, b: __m128i) ->
2801428014
#[cfg_attr(test, assert_instr(vmovntps))]
2801528015
#[allow(clippy::cast_ptr_alignment)]
2801628016
pub unsafe fn _mm512_stream_ps(mem_addr: *mut f32, a: __m512) {
28017-
intrinsics::nontemporal_store(mem_addr as *mut __m512, a);
28017+
crate::arch::asm!(
28018+
"vmovntps [{mem_addr}], {a}",
28019+
mem_addr = in(reg) mem_addr,
28020+
a = in(zmm_reg) a,
28021+
);
2801828022
}
2801928023

2802028024
/// Store 512-bits (composed of 8 packed double-precision (64-bit) floating-point elements) from a into memory using a non-temporal memory hint. mem_addr must be aligned on a 64-byte boundary or a general-protection exception may be generated.
@@ -28035,7 +28039,11 @@ pub unsafe fn _mm512_stream_ps(mem_addr: *mut f32, a: __m512) {
2803528039
#[cfg_attr(test, assert_instr(vmovntps))] //should be vmovntpd
2803628040
#[allow(clippy::cast_ptr_alignment)]
2803728041
pub unsafe fn _mm512_stream_pd(mem_addr: *mut f64, a: __m512d) {
28038-
intrinsics::nontemporal_store(mem_addr as *mut __m512d, a);
28042+
crate::arch::asm!(
28043+
"vmovntps [{mem_addr}], {a}",
28044+
mem_addr = in(reg) mem_addr,
28045+
a = in(zmm_reg) a,
28046+
);
2803928047
}
2804028048

2804128049
/// Store 512-bits of integer data from a into memory using a non-temporal memory hint. mem_addr must be aligned on a 64-byte boundary or a general-protection exception may be generated.
@@ -28056,7 +28064,11 @@ pub unsafe fn _mm512_stream_pd(mem_addr: *mut f64, a: __m512d) {
2805628064
#[cfg_attr(test, assert_instr(vmovntps))] //should be vmovntdq
2805728065
#[allow(clippy::cast_ptr_alignment)]
2805828066
pub unsafe fn _mm512_stream_si512(mem_addr: *mut i64, a: __m512i) {
28059-
intrinsics::nontemporal_store(mem_addr as *mut __m512i, a);
28067+
crate::arch::asm!(
28068+
"vmovntps [{mem_addr}], {a}",
28069+
mem_addr = in(reg) mem_addr,
28070+
a = in(zmm_reg) a,
28071+
);
2806028072
}
2806128073

2806228074
/// Sets packed 32-bit integers in `dst` with the supplied values.

crates/core_arch/src/x86/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
#[allow(unused_imports)]
44
use crate::marker::Sized;
5-
use crate::{intrinsics, mem::transmute};
5+
use crate::mem::transmute;
66

77
#[macro_use]
88
mod macros;

crates/core_arch/src/x86/sse.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -2013,7 +2013,11 @@ extern "C" {
20132013
#[stable(feature = "simd_x86", since = "1.27.0")]
20142014
#[allow(clippy::cast_ptr_alignment)]
20152015
pub unsafe fn _mm_stream_ps(mem_addr: *mut f32, a: __m128) {
2016-
intrinsics::nontemporal_store(mem_addr as *mut __m128, a);
2016+
crate::arch::asm!(
2017+
"movntps [{mem_addr}], {a}",
2018+
mem_addr = in(reg) mem_addr,
2019+
a = in(xmm_reg) a,
2020+
);
20172021
}
20182022

20192023
#[cfg(test)]

crates/core_arch/src/x86/sse2.rs

+17-5
Original file line numberDiff line numberDiff line change
@@ -1326,11 +1326,15 @@ pub unsafe fn _mm_storel_epi64(mem_addr: *mut __m128i, a: __m128i) {
13261326
///
13271327
/// See [`_mm_sfence`] for details.
13281328
#[inline]
1329-
#[target_feature(enable = "sse2")]
1329+
#[target_feature(enable = "sse,sse2")]
13301330
#[cfg_attr(test, assert_instr(movntps))] // FIXME movntdq
13311331
#[stable(feature = "simd_x86", since = "1.27.0")]
13321332
pub unsafe fn _mm_stream_si128(mem_addr: *mut __m128i, a: __m128i) {
1333-
intrinsics::nontemporal_store(mem_addr, a);
1333+
crate::arch::asm!(
1334+
"movntps [{mem_addr}], {a}",
1335+
mem_addr = in(reg) mem_addr,
1336+
a = in(xmm_reg) a,
1337+
);
13341338
}
13351339

13361340
/// Stores a 32-bit integer value in the specified memory location.
@@ -1352,7 +1356,11 @@ pub unsafe fn _mm_stream_si128(mem_addr: *mut __m128i, a: __m128i) {
13521356
#[cfg_attr(test, assert_instr(movnti))]
13531357
#[stable(feature = "simd_x86", since = "1.27.0")]
13541358
pub unsafe fn _mm_stream_si32(mem_addr: *mut i32, a: i32) {
1355-
intrinsics::nontemporal_store(mem_addr, a);
1359+
crate::arch::asm!(
1360+
"movnti [{mem_addr}], {a:e}", // `:e` for 32bit value
1361+
mem_addr = in(reg) mem_addr,
1362+
a = in(reg) a,
1363+
);
13561364
}
13571365

13581366
/// Returns a vector where the low element is extracted from `a` and its upper
@@ -2542,12 +2550,16 @@ pub unsafe fn _mm_loadl_pd(a: __m128d, mem_addr: *const f64) -> __m128d {
25422550
///
25432551
/// See [`_mm_sfence`] for details.
25442552
#[inline]
2545-
#[target_feature(enable = "sse2")]
2553+
#[target_feature(enable = "sse,sse2")]
25462554
#[cfg_attr(test, assert_instr(movntps))] // FIXME movntpd
25472555
#[stable(feature = "simd_x86", since = "1.27.0")]
25482556
#[allow(clippy::cast_ptr_alignment)]
25492557
pub unsafe fn _mm_stream_pd(mem_addr: *mut f64, a: __m128d) {
2550-
intrinsics::nontemporal_store(mem_addr as *mut __m128d, a);
2558+
crate::arch::asm!(
2559+
"movntps [{mem_addr}], {a}",
2560+
mem_addr = in(reg) mem_addr,
2561+
a = in(xmm_reg) a,
2562+
);
25512563
}
25522564

25532565
/// Stores the lower 64 bits of a 128-bit vector of `[2 x double]` to a

crates/core_arch/src/x86_64/sse2.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
//! `x86_64`'s Streaming SIMD Extensions 2 (SSE2)
22
3-
use crate::{
4-
core_arch::x86::*,
5-
intrinsics::{self, simd::*},
6-
};
3+
use crate::{core_arch::x86::*, intrinsics::simd::*};
74

85
#[cfg(test)]
96
use stdarch_test::assert_instr;
@@ -81,7 +78,11 @@ pub unsafe fn _mm_cvttsd_si64x(a: __m128d) -> i64 {
8178
#[cfg_attr(test, assert_instr(movnti))]
8279
#[stable(feature = "simd_x86", since = "1.27.0")]
8380
pub unsafe fn _mm_stream_si64(mem_addr: *mut i64, a: i64) {
84-
intrinsics::nontemporal_store(mem_addr, a);
81+
crate::arch::asm!(
82+
"movnti [{mem_addr}], {a}",
83+
mem_addr = in(reg) mem_addr,
84+
a = in(reg) a,
85+
);
8586
}
8687

8788
/// Returns a vector whose lowest element is `a` and all higher elements are

0 commit comments

Comments
 (0)