sse3: _mm_hadd_ps

This commit is contained in:
gwenn 2017-09-30 12:07:35 +02:00 committed by Andrew Gallant
parent fbd3416f0c
commit 7f84607f16

View file

@ -31,6 +31,15 @@ pub unsafe fn _mm_hadd_pd(a: f64x2, b: f64x2) -> f64x2 {
haddpd(a, b)
}
/// Horizontally add adjacent pairs of single-precision (32-bit)
/// floating-point elements in `a` and `b`, and pack the results.
#[inline(always)]
#[target_feature = "+sse3"]
#[cfg_attr(test, assert_instr(hadd))]
pub unsafe fn _mm_hadd_ps(a: f32x4, b: f32x4) -> f32x4 {
haddps(a, b)
}
/// Load 128-bits of integer data from unaligned memory.
/// This intrinsic may perform better than `_mm_loadu_si128`
/// when the data crosses a cache line boundary.
@ -49,6 +58,8 @@ extern {
fn addsubpd(a: f64x2, b: f64x2) -> f64x2;
#[link_name = "llvm.x86.sse3.hadd.pd"]
fn haddpd(a: f64x2, b: f64x2) -> f64x2;
#[link_name = "llvm.x86.sse3.hadd.ps"]
fn haddps(a: f32x4, b: f32x4) -> f32x4;
#[link_name = "llvm.x86.sse3.ldu.dq"]
fn lddqu(mem_addr: *const i8) -> __m128i;
}
@ -85,6 +96,14 @@ mod tests {
assert_eq!(r, f64x2::new(4.0, -80.0));
}
#[simd_test = "sse3"]
unsafe fn _mm_hadd_ps() {
let a = f32x4::new(-1.0, 5.0, 0.0, -10.0);
let b = f32x4::new(-100.0, 20.0, 0.0, -5.0);
let r = sse3::_mm_hadd_ps(a, b);
assert_eq!(r, f32x4::new(4.0, -10.0, -80.0, -5.0));
}
#[simd_test = "sse3"]
unsafe fn _mm_lddqu_si128() {
let a = i8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);