Skip to content

Commit fae0fa6

Browse files
committed
Added implementation and test of _MM_SHUFFLE macro.
1 parent dda4072 commit fae0fa6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

coresimd/x86/sse.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,14 @@ pub unsafe fn _mm_setzero_ps() -> __m128 {
968968
__m128(0.0, 0.0, 0.0, 0.0)
969969
}
970970

971+
/// A utility function for creating masks to use with Intel shuffle and permute intrinsics.
972+
#[inline]
973+
#[allow(non_snake_case)]
974+
#[stable(feature = "simd_x86", since = "1.28.0")]
975+
pub const fn _MM_SHUFFLE(z: u32, y: u32, x: u32, w: u32) -> u32 {
976+
(z << 6) | (y << 4) | (x << 2) | w
977+
}
978+
971979
/// Shuffle packed single-precision (32-bit) floating-point elements in `a` and
972980
/// `b` using `mask`.
973981
///
@@ -3570,6 +3578,13 @@ mod tests {
35703578
assert_eq_m128(r, _mm_set1_ps(0.0));
35713579
}
35723580

3581+
#[simd_test(enable = "sse")]
3582+
unsafe fn test_mm_shuffle() {
3583+
assert_eq!(_MM_SHUFFLE(0, 1, 1, 3), 0b00_01_01_11);
3584+
assert_eq!(_MM_SHUFFLE(3, 1, 1, 0), 0b11_01_01_00);
3585+
assert_eq!(_MM_SHUFFLE(1, 2, 2, 1), 0b01_10_10_01);
3586+
}
3587+
35733588
#[simd_test(enable = "sse")]
35743589
unsafe fn test_mm_shuffle_ps() {
35753590
let a = _mm_setr_ps(1.0, 2.0, 3.0, 4.0);

0 commit comments

Comments
 (0)