Skip to content

Commit f7f2a23

Browse files
p32blognzlbg
authored andcommitted
Add _mm_minpos_epu16
1 parent 19b2aed commit f7f2a23

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

src/x86/sse41.rs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -768,10 +768,26 @@ pub unsafe fn _mm_round_ss(a: f32x4, b: f32x4, rounding: i32) -> f32x4 {
768768
constify_imm4!(rounding, call)
769769
}
770770

771-
/// Find minimal u16 element in vector.
772-
/// Place it in the first element of resulting vector and it's index
773-
/// in second element (formally bits [16..18] inclusive).
774-
/// All other elements are set to zero.
771+
/// Finds the minimum u16 in the u16x8 vector, returning it in the first
772+
/// position of the result vector along with its index in the second position;
773+
/// all other elements are set to zero.
774+
///
775+
/// \headerfile <x86intrin.h>
776+
///
777+
/// This intrinsic corresponds to the <c> VPHMINPOSUW / PHMINPOSUW </c>
778+
/// instruction.
779+
///
780+
/// Arguments:
781+
///
782+
/// * `a` - A 128-bit vector of type `u16x8`.
783+
///
784+
/// Returns:
785+
///
786+
/// A 128-bit value where:
787+
///
788+
/// * bits `[15:0]` - contain the minimum value found in parameter `a`,
789+
/// * bits `[18:16]` - contain the index of the minimum value
790+
/// * remaining bits are set to `0`.
775791
#[inline(always)]
776792
#[target_feature = "+sse4.1"]
777793
#[cfg_attr(test, assert_instr(phminposuw))]
@@ -801,7 +817,6 @@ pub unsafe fn _mm_mullo_epi32(a: i32x4, b: i32x4) -> i32x4 {
801817
a * b
802818
}
803819

804-
805820
#[allow(improper_ctypes)]
806821
extern "C" {
807822
#[link_name = "llvm.x86.sse41.pblendvb"]
@@ -1216,7 +1231,7 @@ mod tests {
12161231
let e = i64x2::splat(-10);
12171232
assert_eq!(r, e);
12181233
}
1219-
1234+
12201235
#[simd_test = "sse4.1"]
12211236
unsafe fn _mm_cvtepi32_epi64() {
12221237
let a = i32x4::splat(10);
@@ -1558,6 +1573,12 @@ mod tests {
15581573
// Attention, most significant bit in r[2] is treated as a sign bit!
15591574
// 1234567 * 666666 = -1589877210
15601575
let e = i32x4::new(-300, 512, -1589877210, -1409865409);
1576+
1577+
#[simd_test = "sse4.1"]
1578+
unsafe fn _mm_minpos_epu16() {
1579+
let a = u16x8::new(8, 7, 6, 5, 4, 1, 2, 3);
1580+
let r = sse41::_mm_minpos_epu16(a);
1581+
let e = u16x8::splat(0).replace(0, 1).replace(1, 5);
15611582
assert_eq!(r, e);
15621583
}
15631584
}

0 commit comments

Comments
 (0)