Skip to content

Commit de984bc

Browse files
pickfireAmanieu
andauthored
Add _mm_loadu_si64 (#870)
Co-authored-by: Amanieu d'Antras <[email protected]>
1 parent fa96710 commit de984bc

File tree

1 file changed

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

1 file changed

+20
-0
lines changed

crates/core_arch/src/x86/sse.rs

+20
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,19 @@ 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(all(test, not(target_arch = "x86")), assert_instr(movq))]
1262+
#[stable(feature = "simd_x86_mm_loadu_si64", since = "1.46.0")]
1263+
pub unsafe fn _mm_loadu_si64(mem_addr: *const u8) -> __m128i {
1264+
transmute(i64x2(0, ptr::read_unaligned(mem_addr as *const i64)))
1265+
}
1266+
12541267
/// Stores the upper half of `a` (64 bits) into memory.
12551268
///
12561269
/// This intrinsic corresponds to the `MOVHPS` instruction. The compiler may
@@ -3658,6 +3671,13 @@ mod tests {
36583671
assert_eq_m128(r, e);
36593672
}
36603673

3674+
#[simd_test(enable = "sse2")]
3675+
unsafe fn test_mm_loadu_si64() {
3676+
let a = _mm_setr_epi64x(5, 6);
3677+
let r = _mm_loadu_si64(&a as *const _ as *const _);
3678+
assert_eq_m128i(r, _mm_set_epi64x(5, 0));
3679+
}
3680+
36613681
#[simd_test(enable = "sse")]
36623682
unsafe fn test_mm_storeh_pi() {
36633683
let mut vals = [0.0f32; 8];

0 commit comments

Comments
 (0)