1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
#![cfg(target_feature = "sse3")]

use super::*;

/// Add the high lane and subtract the low lane.
///
/// * **Intrinsic:** [`_mm_addsub_pd`]
/// * **Assembly:** `addsubpd xmm, xmm`
#[must_use]
#[inline(always)]
#[cfg_attr(docs_rs, doc(cfg(target_feature = "sse3")))]
pub fn addsub_m128d(a: m128d, b: m128d) -> m128d {
  m128d(unsafe { _mm_addsub_pd(a.0, b.0) })
}

/// Alternately, from the top, add a lane and then subtract a lane.
///
/// * **Intrinsic:** [`_mm_addsub_ps`]
/// * **Assembly:** `addsubps xmm, xmm`
#[must_use]
#[inline(always)]
#[cfg_attr(docs_rs, doc(cfg(target_feature = "sse3")))]
pub fn addsub_m128(a: m128, b: m128) -> m128 {
  m128(unsafe { _mm_addsub_ps(a.0, b.0) })
}

/// Add each lane horizontally, pack the outputs as `a` then `b`.
///
/// * **Intrinsic:** [`_mm_hadd_pd`]
/// * **Assembly:** `haddpd xmm, xmm`
#[must_use]
#[inline(always)]
#[cfg_attr(docs_rs, doc(cfg(target_feature = "sse3")))]
pub fn add_horizontal_m128d(a: m128d, b: m128d) -> m128d {
  m128d(unsafe { _mm_hadd_pd(a.0, b.0) })
}

/// Add each lane horizontally, pack the outputs as `a` then `b`.
///
/// * **Intrinsic:** [`_mm_hadd_ps`]
/// * **Assembly:** `haddps xmm, xmm`
#[must_use]
#[inline(always)]
#[cfg_attr(docs_rs, doc(cfg(target_feature = "sse3")))]
pub fn add_horizontal_m128(a: m128, b: m128) -> m128 {
  m128(unsafe { _mm_hadd_ps(a.0, b.0) })
}

/// Subtract each lane horizontally, pack the outputs as `a` then `b`.
///
/// * **Intrinsic:** [`_mm_hsub_pd`]
/// * **Assembly:** `hsubpd xmm, xmm`
#[must_use]
#[inline(always)]
#[cfg_attr(docs_rs, doc(cfg(target_feature = "sse3")))]
pub fn sub_horizontal_m128d(a: m128d, b: m128d) -> m128d {
  m128d(unsafe { _mm_hsub_pd(a.0, b.0) })
}

/// Subtract each lane horizontally, pack the outputs as `a` then `b`.
///
/// * **Intrinsic:** [`_mm_hsub_ps`]
/// * **Assembly:** `hsubps xmm, xmm`
#[must_use]
#[inline(always)]
#[cfg_attr(docs_rs, doc(cfg(target_feature = "sse3")))]
pub fn sub_horizontal_m128(a: m128, b: m128) -> m128 {
  m128(unsafe { _mm_hsub_ps(a.0, b.0) })
}

/// Copy the low lane of the input to both lanes of the output.
///
/// * **Intrinsic:** [`_mm_movedup_pd`]
/// * **Assembly:** `movddup xmm, xmm`
#[must_use]
#[inline(always)]
#[cfg_attr(docs_rs, doc(cfg(target_feature = "sse3")))]
pub fn duplicate_low_lane_m128d_s(a: m128d) -> m128d {
  m128d(unsafe { _mm_movedup_pd(a.0) })
}

/// Duplicate the odd lanes to the even lanes.
///
/// * **Intrinsic:** [`_mm_movehdup_ps`]
/// * **Assembly:** `movshdup xmm, xmm`
#[must_use]
#[inline(always)]
#[cfg_attr(docs_rs, doc(cfg(target_feature = "sse3")))]
pub fn duplicate_odd_lanes_m128(a: m128) -> m128 {
  m128(unsafe { _mm_movehdup_ps(a.0) })
}

/// Duplicate the odd lanes to the even lanes.
///
/// * **Intrinsic:** [`_mm_moveldup_ps`]
/// * **Assembly:** `movsldup xmm, xmm`
#[must_use]
#[inline(always)]
#[cfg_attr(docs_rs, doc(cfg(target_feature = "sse3")))]
pub fn duplicate_even_lanes_m128(a: m128) -> m128 {
  m128(unsafe { _mm_moveldup_ps(a.0) })
}