Skip to content

Commit 26f591a

Browse files
committed
Extend the tests
1 parent f4df77b commit 26f591a

File tree

1 file changed

+85
-10
lines changed

1 file changed

+85
-10
lines changed

coresimd/powerpc/altivec.rs

+85-10
Original file line numberDiff line numberDiff line change
@@ -750,18 +750,93 @@ mod tests {
750750
use simd::*;
751751
use stdsimd_test::simd_test;
752752

753-
#[simd_test(enable = "altivec")]
754-
unsafe fn vec_perm_u16x8() {
755-
let a: vector_signed_short = u16x8::new(0, 1, 2, 3, 4, 5, 6, 7).into_bits();
756-
let b = u16x8::new(10, 11, 12, 13, 14, 15, 16, 17).into_bits();
757-
758-
let c = u8x16::new(0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
759-
0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17).into_bits();
760-
let d = u16x8::new(0, 10, 1, 11, 2, 12, 3, 13);
761-
762-
assert_eq!(d, vec_perm(a, b, c).into_bits());
753+
macro_rules! test_vec_perm {
754+
{$name:ident, $shorttype:ident, $longtype:ident, [$($a:expr),+], [$($b:expr),+], [$($c:expr),+], [$($d:expr),+]} => {
755+
#[simd_test(enable = "altivec")]
756+
unsafe fn $name() {
757+
let a: $longtype = $shorttype::new($($a),+).into_bits();
758+
let b = $shorttype::new($($b),+).into_bits();
759+
let c = u8x16::new($($c),+).into_bits();
760+
let d = $shorttype::new($($d),+);
761+
762+
assert_eq!(d, vec_perm(a, b, c).into_bits());
763+
}
764+
}
763765
}
764766

767+
test_vec_perm!{test_vec_perm_u8x16,
768+
u8x16, vector_unsigned_char,
769+
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
770+
[100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115],
771+
[0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
772+
0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17],
773+
[0, 1, 100, 101, 2, 3, 102, 103, 4, 5, 104, 105, 6, 7, 106, 107]}
774+
test_vec_perm!{test_vec_perm_i8x16,
775+
i8x16, vector_signed_char,
776+
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
777+
[100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115],
778+
[0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
779+
0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17],
780+
[0, 1, 100, 101, 2, 3, 102, 103, 4, 5, 104, 105, 6, 7, 106, 107]}
781+
test_vec_perm!{test_vec_perm_m8x16,
782+
m8x16, vector_bool_char,
783+
[false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false],
784+
[true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true],
785+
[0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
786+
0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17],
787+
[false, false, true, true, false, false, true, true, false, false, true, true, false, false, true, true]}
788+
789+
test_vec_perm!{test_vec_perm_u16x8,
790+
u16x8, vector_unsigned_short,
791+
[0, 1, 2, 3, 4, 5, 6, 7],
792+
[10, 11, 12, 13, 14, 15, 16, 17],
793+
[0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
794+
0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17],
795+
[0, 10, 1, 11, 2, 12, 3, 13]}
796+
test_vec_perm!{test_vec_perm_i16x8,
797+
i16x8, vector_signed_short,
798+
[0, 1, 2, 3, 4, 5, 6, 7],
799+
[10, 11, 12, 13, 14, 15, 16, 17],
800+
[0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
801+
0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17],
802+
[0, 10, 1, 11, 2, 12, 3, 13]}
803+
test_vec_perm!{test_vec_perm_m16x8,
804+
m16x8, vector_bool_short,
805+
[false, false, false, false, false, false, false, false],
806+
[true, true, true, true, true, true, true, true],
807+
[0x00, 0x01, 0x10, 0x11, 0x02, 0x03, 0x12, 0x13,
808+
0x04, 0x05, 0x14, 0x15, 0x06, 0x07, 0x16, 0x17],
809+
[false, true, false, true, false, true, false, true]}
810+
811+
test_vec_perm!{test_vec_perm_u32x4,
812+
u32x4, vector_unsigned_int,
813+
[0, 1, 2, 3],
814+
[10, 11, 12, 13],
815+
[0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
816+
0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17],
817+
[0, 10, 1, 11]}
818+
test_vec_perm!{test_vec_perm_i32x4,
819+
i32x4, vector_signed_int,
820+
[0, 1, 2, 3],
821+
[10, 11, 12, 13],
822+
[0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
823+
0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17],
824+
[0, 10, 1, 11]}
825+
test_vec_perm!{test_vec_perm_m32x4,
826+
m32x4, vector_bool_int,
827+
[false, false, false, false],
828+
[true, true, true, true],
829+
[0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
830+
0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17],
831+
[false, true, false, true]}
832+
test_vec_perm!{test_vec_perm_f32x4,
833+
f32x4, vector_float,
834+
[0.0, 1.0, 2.0, 3.0],
835+
[1.0, 1.1, 1.2, 1.3],
836+
[0x00, 0x01, 0x02, 0x03, 0x10, 0x11, 0x12, 0x13,
837+
0x04, 0x05, 0x06, 0x07, 0x14, 0x15, 0x16, 0x17],
838+
[0.0, 1.0, 1.0, 1.1]}
839+
765840
#[simd_test(enable = "altivec")]
766841
unsafe fn vec_add_i32x4_i32x4() {
767842
let x = i32x4::new(1, 2, 3, 4);

0 commit comments

Comments
 (0)