| 1 |
#![cfg(target_feature = "sse3")] |
| 2 |
|
| 3 |
use super::*; |
| 4 |
|
| 5 |
/// Add the high lane and subtract the low lane. |
| 6 |
/// |
| 7 |
/// * **Intrinsic:** [`_mm_addsub_pd`] |
| 8 |
/// * **Assembly:** `addsubpd xmm, xmm` |
| 9 |
#[must_use] |
| 10 |
#[inline(always)] |
| 11 |
#[cfg_attr(docsrs, doc(cfg(target_feature = "sse3")))] |
| 12 |
pub fn addsub_m128d(a: m128d, b: m128d) -> m128d { |
| 13 |
m128d(unsafe { _mm_addsub_pd(a.0, b.0) }) |
| 14 |
} |
| 15 |
|
| 16 |
/// Alternately, from the top, add a lane and then subtract a lane. |
| 17 |
/// |
| 18 |
/// * **Intrinsic:** [`_mm_addsub_ps`] |
| 19 |
/// * **Assembly:** `addsubps xmm, xmm` |
| 20 |
#[must_use] |
| 21 |
#[inline(always)] |
| 22 |
#[cfg_attr(docsrs, doc(cfg(target_feature = "sse3")))] |
| 23 |
pub fn addsub_m128(a: m128, b: m128) -> m128 { |
| 24 |
m128(unsafe { _mm_addsub_ps(a.0, b.0) }) |
| 25 |
} |
| 26 |
|
| 27 |
/// Add each lane horizontally, pack the outputs as `a` then `b`. |
| 28 |
/// |
| 29 |
/// * **Intrinsic:** [`_mm_hadd_pd`] |
| 30 |
/// * **Assembly:** `haddpd xmm, xmm` |
| 31 |
#[must_use] |
| 32 |
#[inline(always)] |
| 33 |
#[cfg_attr(docsrs, doc(cfg(target_feature = "sse3")))] |
| 34 |
pub fn add_horizontal_m128d(a: m128d, b: m128d) -> m128d { |
| 35 |
m128d(unsafe { _mm_hadd_pd(a.0, b.0) }) |
| 36 |
} |
| 37 |
|
| 38 |
/// Add each lane horizontally, pack the outputs as `a` then `b`. |
| 39 |
/// |
| 40 |
/// * **Intrinsic:** [`_mm_hadd_ps`] |
| 41 |
/// * **Assembly:** `haddps xmm, xmm` |
| 42 |
#[must_use] |
| 43 |
#[inline(always)] |
| 44 |
#[cfg_attr(docsrs, doc(cfg(target_feature = "sse3")))] |
| 45 |
pub fn add_horizontal_m128(a: m128, b: m128) -> m128 { |
| 46 |
m128(unsafe { _mm_hadd_ps(a.0, b.0) }) |
| 47 |
} |
| 48 |
|
| 49 |
/// Subtract each lane horizontally, pack the outputs as `a` then `b`. |
| 50 |
/// |
| 51 |
/// * **Intrinsic:** [`_mm_hsub_pd`] |
| 52 |
/// * **Assembly:** `hsubpd xmm, xmm` |
| 53 |
#[must_use] |
| 54 |
#[inline(always)] |
| 55 |
#[cfg_attr(docsrs, doc(cfg(target_feature = "sse3")))] |
| 56 |
pub fn sub_horizontal_m128d(a: m128d, b: m128d) -> m128d { |
| 57 |
m128d(unsafe { _mm_hsub_pd(a.0, b.0) }) |
| 58 |
} |
| 59 |
|
| 60 |
/// Subtract each lane horizontally, pack the outputs as `a` then `b`. |
| 61 |
/// |
| 62 |
/// * **Intrinsic:** [`_mm_hsub_ps`] |
| 63 |
/// * **Assembly:** `hsubps xmm, xmm` |
| 64 |
#[must_use] |
| 65 |
#[inline(always)] |
| 66 |
#[cfg_attr(docsrs, doc(cfg(target_feature = "sse3")))] |
| 67 |
pub fn sub_horizontal_m128(a: m128, b: m128) -> m128 { |
| 68 |
m128(unsafe { _mm_hsub_ps(a.0, b.0) }) |
| 69 |
} |
| 70 |
|
| 71 |
/// Copy the low lane of the input to both lanes of the output. |
| 72 |
/// |
| 73 |
/// * **Intrinsic:** [`_mm_movedup_pd`] |
| 74 |
/// * **Assembly:** `movddup xmm, xmm` |
| 75 |
#[must_use] |
| 76 |
#[inline(always)] |
| 77 |
#[cfg_attr(docsrs, doc(cfg(target_feature = "sse3")))] |
| 78 |
pub fn duplicate_low_lane_m128d_s(a: m128d) -> m128d { |
| 79 |
m128d(unsafe { _mm_movedup_pd(a.0) }) |
| 80 |
} |
| 81 |
|
| 82 |
/// Duplicate the odd lanes to the even lanes. |
| 83 |
/// |
| 84 |
/// * **Intrinsic:** [`_mm_movehdup_ps`] |
| 85 |
/// * **Assembly:** `movshdup xmm, xmm` |
| 86 |
#[must_use] |
| 87 |
#[inline(always)] |
| 88 |
#[cfg_attr(docsrs, doc(cfg(target_feature = "sse3")))] |
| 89 |
pub fn duplicate_odd_lanes_m128(a: m128) -> m128 { |
| 90 |
m128(unsafe { _mm_movehdup_ps(a.0) }) |
| 91 |
} |
| 92 |
|
| 93 |
/// Duplicate the odd lanes to the even lanes. |
| 94 |
/// |
| 95 |
/// * **Intrinsic:** [`_mm_moveldup_ps`] |
| 96 |
/// * **Assembly:** `movsldup xmm, xmm` |
| 97 |
#[must_use] |
| 98 |
#[inline(always)] |
| 99 |
#[cfg_attr(docsrs, doc(cfg(target_feature = "sse3")))] |
| 100 |
pub fn duplicate_even_lanes_m128(a: m128) -> m128 { |
| 101 |
m128(unsafe { _mm_moveldup_ps(a.0) }) |
| 102 |
} |
| 103 |
|