Skip to content

Commit c1cadf5

Browse files
committed
Add _mm_loadu_si64
Fix rust-lang#40
1 parent a371069 commit c1cadf5

File tree

1 file changed

+26
-0
lines changed
  • crates/core_arch/src/x86

1 file changed

+26
-0
lines changed

crates/core_arch/src/x86/sse.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,25 @@ pub unsafe fn _mm_loadr_ps(p: *const f32) -> __m128 {
12511251
simd_shuffle4(a, a, [3, 2, 1, 0])
12521252
}
12531253

1254+
/// Loads unaligned 64-bits of integer data from memory into new vector.
1255+
///
1256+
/// `mem_addr` does not need to be aligned on any particular boundary.
1257+
///
1258+
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_loadu_si64)
1259+
#[inline]
1260+
#[target_feature(enable = "sse")]
1261+
#[cfg_attr(test, assert_instr(movups))]
1262+
#[stable(feature = "simd_x86", since = "1.46.0")]
1263+
pub unsafe fn _mm_loadu_si64(mem_addr: *const u8) -> __m128i {
1264+
let mut dst = _mm_setzero_si128();
1265+
ptr::copy_nonoverlapping(
1266+
mem_addr,
1267+
&mut dst as *mut __m128i as *mut u8,
1268+
8, // == 64 bits == mem::size_of::<__m128i>() / 2
1269+
);
1270+
dst
1271+
}
1272+
12541273
/// Stores the upper half of `a` (64 bits) into memory.
12551274
///
12561275
/// This intrinsic corresponds to the `MOVHPS` instruction. The compiler may
@@ -3659,6 +3678,13 @@ mod tests {
36593678
assert_eq_m128(r, e);
36603679
}
36613680

3681+
#[simd_test(enable = "sse2")]
3682+
unsafe fn test_mm_loadu_si64() {
3683+
let a = _mm_set_epi64x(5, 0);
3684+
let r = _mm_loadu_si64(&a as *const _ as *const _);
3685+
assert_eq_m128i(a, r);
3686+
}
3687+
36623688
#[simd_test(enable = "sse")]
36633689
unsafe fn test_mm_storeh_pi() {
36643690
let mut vals = [0.0f32; 8];

0 commit comments

Comments
 (0)