Skip to content

Commit 60b45d5

Browse files
eduardosmAmanieu
authored andcommitted
Extend _mm_maddubs_epi16 test to check widening and saturating behavior
1 parent e6027c2 commit 60b45d5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

crates/core_arch/src/x86/ssse3.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,27 @@ mod tests {
568568
let expected = _mm_setr_epi16(130, 24, 192, 194, 158, 175, 66, 120);
569569
let r = _mm_maddubs_epi16(a, b);
570570
assert_eq_m128i(r, expected);
571+
572+
// Test widening and saturation
573+
#[rustfmt::skip]
574+
let a = _mm_setr_epi8(
575+
u8::MAX as i8, u8::MAX as i8,
576+
u8::MAX as i8, u8::MAX as i8,
577+
u8::MAX as i8, u8::MAX as i8,
578+
100, 100, 0, 0,
579+
0, 0, 0, 0, 0, 0,
580+
);
581+
#[rustfmt::skip]
582+
let b = _mm_setr_epi8(
583+
i8::MAX, i8::MAX,
584+
i8::MAX, i8::MIN,
585+
i8::MIN, i8::MIN,
586+
50, 15, 0, 0, 0,
587+
0, 0, 0, 0, 0,
588+
);
589+
let expected = _mm_setr_epi16(i16::MAX, -255, i16::MIN, 6500, 0, 0, 0, 0);
590+
let r = _mm_maddubs_epi16(a, b);
591+
assert_eq_m128i(r, expected);
571592
}
572593

573594
#[simd_test(enable = "ssse3")]

0 commit comments

Comments
 (0)