4 public class SimdTests {
5 public static unsafe int test_0_sizeof_returns_16_2d ()
7 double[] array = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
8 fixed (double *ptr = &array [0]) {
9 Vector2d *f = (Vector2d*)ptr;
15 if (a.X != 1 || a.Y != 2)
17 if (b.X != 3 || b.Y != 4)
19 if (c.X != 5 || c.Y != 6)
21 if (d.X != 7 || d.Y != 8)
27 public static unsafe int test_0_sizeof_returns_16_4f ()
29 float[] array = new float[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
30 fixed (float *ptr = &array [0]) {
31 Vector4f *f = (Vector4f*)ptr;
37 if (a.X != 1 || a.W != 4)
39 if (b.X != 5 || b.W != 8)
41 if (c.X != 9 || c.W != 12)
43 if (d.X != 13 || d.W != 16)
49 public static unsafe int test_0_sizeof_returns_16_8d ()
51 short[] array = new short[40];
52 for (int i = 0; i < 40; ++i)
53 array [i] = (short) (i + 1);
55 fixed (short *ptr = &array [0]) {
56 Vector8s *f = (Vector8s*)ptr;
62 if (a.V0 != 1 || a.V7 != 8)
64 if (b.V0 != 9 || b.V7 != 16)
66 if (c.V0 != 17 || c.V7 != 24)
68 if (d.V0 != 25 || d.V7 != 32)
74 public static unsafe int test_0_sizeof_returns_16_16b ()
76 byte[] array = new byte[80];
77 for (int i = 0; i < 80; ++i)
78 array [i] = (byte) (i + 1);
80 fixed (byte *ptr = &array [0]) {
81 Vector16b *f = (Vector16b*)ptr;
87 if (a.V0 != 1 || a.V15 != 16)
89 if (b.V0 != 17 || b.V15 != 32)
91 if (c.V0 != 33 || c.V15 != 48)
93 if (d.V0 != 49 || d.V15 != 64)
98 public static int test_0_bug_462457 ()
100 Vector4f sum = new Vector4f(0,0,0,0);
101 Vector4f add = new Vector4f(1.0F,1.0F,1.0F,1.0F);
103 for (int i = 0; i < 10; ++i)
111 public static int test_0_vector16b_operator_neq () {
112 Vector16b a = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
113 Vector16b b = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
122 public static int test_0_vector16b_operator_eq () {
123 Vector16b a = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
124 Vector16b b = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
133 public static int test_0_vector8us_operator_neq () {
134 Vector8us a = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
135 Vector8us b = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
144 public static int test_0_vector8us_operator_eq () {
145 Vector8us a = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
146 Vector8us b = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
155 public static int test_0_set_vector4f_operator_neq () {
156 Vector4f a = new Vector4f(1, 2, 3, 4);
157 Vector4f b = new Vector4f(1, 2, 3, 4);
161 a = new Vector4f(1, 2, float.NaN, 4);
162 b = new Vector4f(1, 2, float.NaN, 4);
163 if (!(a != b)) //NaN is always !=
166 a = new Vector4f(1, 2, float.NaN, 4);
167 b = new Vector4f(1, 2, 10, 4);
171 a = new Vector4f(1, 2, float.PositiveInfinity, 4);
172 b = new Vector4f(1, 2, float.PositiveInfinity, 4);
176 a = new Vector4f(1, 2, 20, 4);
177 b = new Vector4f(1, 2, 30, 4);
184 public static int test_0_set_vector4f_operator_eq () {
185 Vector4f a = new Vector4f(1, 2, 3, 4);
186 Vector4f b = new Vector4f(1, 2, 3, 4);
190 a = new Vector4f(1, 2, float.NaN, 4);
191 b = new Vector4f(1, 2, float.NaN, 4);
195 a = new Vector4f(1, 2, 10, 4);
196 b = new Vector4f(1, 2, float.NaN, 4);
200 a = new Vector4f(1, 2, float.PositiveInfinity, 4);
201 b = new Vector4f(1, 2, float.PositiveInfinity, 4);
207 public static int test_1_set_vector4ui_operator_neq () {
208 Vector4ui a = new Vector4ui(1, 2, 3, 4);
209 Vector4ui b = new Vector4ui(1, 2, 3, 4);
215 public static int test_0_set_vector4ui_operator_neq () {
216 Vector4ui a = new Vector4ui(1, 2, 3, 4);
217 Vector4ui b = new Vector4ui(111, 2, 3, 4);
223 public static int test_0_set_vector4ui_operator_eq () {
224 Vector4ui a = new Vector4ui(1, 2, 3, 4);
225 Vector4ui b = new Vector4ui(1, 2, 3, 4);
231 public static int test_1_set_vector4ui_operator_eq () {
232 Vector4ui a = new Vector4ui(1, 2, 3, 4);
233 Vector4ui b = new Vector4ui(111, 2, 3, 4);
239 public static int test_0_set_vector_small_array () {
240 uint[] array = new uint[3];
243 array.SetVector (new Vector4ui (), 0);
245 } catch (IndexOutOfRangeException) {
250 public static int test_0_set_vector_negative_index () {
251 uint[] array = new uint[4];
254 array.SetVector (new Vector4ui (), -1);
256 } catch (IndexOutOfRangeException) {
261 public static int test_0_set_vector_bounds_error () {
262 uint[] array = new uint[4];
265 array.SetVector (new Vector4ui (), 1);
267 } catch (IndexOutOfRangeException) {
272 public static int test_0_set_vector () {
273 uint[] array = new uint[10];
274 Vector4ui a = new Vector4ui (11, 22, 33, 44);
276 array.SetVector (a, 1);
289 public static int test_0_get_vector_small_array () {
290 uint[] array = new uint[3];
293 Vector4ui res = array.GetVector (0);
295 } catch (IndexOutOfRangeException) {
300 public static int test_0_get_vector_negative_index () {
301 uint[] array = new uint[4];
304 Vector4ui res = array.GetVector (-1);
306 } catch (IndexOutOfRangeException) {
311 public static int test_0_get_vector_bounds_error () {
312 uint[] array = new uint[4];
315 Vector4ui res = array.GetVector (1);
317 } catch (IndexOutOfRangeException) {
322 public static int test_0_get_vector () {
323 uint[] array = new uint[] { 11, 22, 33, 44, 55, 66, 77, 88, 99, 111 };
325 Vector4ui res = array.GetVector (1);
339 public static int test_0_accessor_vecto2l () {
340 Vector2l a = new Vector2l (3, 2);
347 a.X = 500000000000055l;
350 if (a.X != 500000000000055l)
352 if (a.Y != -12345678900l)
357 public static int test_0_accessor_vecto2d () {
358 Vector2d a = new Vector2d (3, 2);
368 if (a.X != 5000000000000)
375 public static int test_0_accessor_vecto4f () {
376 Vector4f a = new Vector4f (1,2,3,4);
403 public static int test_0_accessor_vecto4i () {
404 Vector4i a = new Vector4i (0x70000000, -1, 3, 4);
406 if (a.X != 0x70000000)
426 if (a.W != -44444444)
431 public static int test_0_accessor_vecto4ui () {
432 Vector4ui a = new Vector4ui (0xF0000000, 0xF0000, 3, 4);
434 if (a.X != 0xF0000000)
459 static float use_getter_with_byref (ref Vector4f a) {
463 public static int test_0_accessor_and_byref_var () {
464 Vector4f a = new Vector4f (1, 2, 3, 4);
465 if (use_getter_with_byref (ref a) != 4)
470 public static unsafe int test_0_vector2ul_slr () {
471 Vector2ul a = new Vector2ul (1, 6);
473 Vector2ul c = a >> 1;
481 public static unsafe int test_0_vector2l_cmp_gt () {
482 Vector2l a = new Vector2l (10, 5);
483 Vector2l b = new Vector2l (-1, 5);
485 Vector2l c = a.CompareGreaterThan (b);
494 public static unsafe int test_0_vector2l_cmp_eq () {
495 Vector2l a = new Vector2l (0xFF, 5);
496 Vector2l b = new Vector2l (0xFF000000FFL, 5);
498 Vector2l c = a.CompareEqual (b);
507 public static unsafe int test_0_vector2l_srl () {
508 Vector2l a = new Vector2l (1, 6);
510 Vector2l c = a.LogicalRightShift (1);
519 public static unsafe int test_0_vector2l_unpack_high () {
520 Vector2l a = new Vector2l (1, 6);
521 Vector2l b = new Vector2l (3, 4);
523 Vector2l c = a.UnpackHigh (b);
532 public static unsafe int test_0_vector2l_unpack_low () {
533 Vector2l a = new Vector2l (1, 6);
534 Vector2l b = new Vector2l (3, 4);
536 Vector2l c = a.UnpackLow (b);
545 public static unsafe int test_0_vector2l_xor () {
546 Vector2l a = new Vector2l (1, 6);
547 Vector2l b = new Vector2l (3, 4);
558 public static unsafe int test_0_vector2l_or () {
559 Vector2l a = new Vector2l (1, 6);
560 Vector2l b = new Vector2l (3, 4);
571 public static unsafe int test_0_vector2l_and () {
572 Vector2l a = new Vector2l (1, 6);
573 Vector2l b = new Vector2l (3, 4);
584 public static unsafe int test_0_vector2l_shl() {
585 Vector2l a = new Vector2l (1, 6);
595 public static unsafe int test_0_vector2l_sub() {
596 Vector2l a = new Vector2l (1, 6);
597 Vector2l b = new Vector2l (3, 4);
608 public static unsafe int test_0_vector2l_add () {
609 Vector2l a = new Vector2l (1, 2);
610 Vector2l b = new Vector2l (3, 4);
621 public static unsafe int test_0_vector2d_dup () {
622 Vector2d a = new Vector2d (3, 2);
624 Vector2d c = a.Duplicate ();
633 public static unsafe int test_0_vector2d_cmp_eq () {
634 Vector2d a = new Vector2d (3, 2);
635 Vector2d b = new Vector2d (3, 4);
637 Vector4ui c = (Vector4ui)a.CompareEqual (b);
639 if (c.X != 0xFFFFFFFF)
641 if (c.Y != 0xFFFFFFFF)
650 public static unsafe int test_0_vector2d_unpack_low () {
651 Vector2d a = new Vector2d (1, 2);
652 Vector2d b = new Vector2d (4, 5);
654 Vector2d c = a.InterleaveLow (b);
663 public static unsafe int test_0_vector2d_unpack_high () {
664 Vector2d a = new Vector2d (1, 2);
665 Vector2d b = new Vector2d (4, 5);
667 Vector2d c = a.InterleaveHigh (b);
675 public static unsafe int test_0_vector2d_addsub () {
676 Vector2d a = new Vector2d (1, 2);
677 Vector2d b = new Vector2d (4, 1);
679 Vector2d c = a.AddSub (b);
687 public static unsafe int test_0_vector2d_hsub () {
688 Vector2d a = new Vector2d (1, 2);
689 Vector2d b = new Vector2d (4, 1);
691 Vector2d c = a.HorizontalSub (b);
700 public static unsafe int test_0_vector2d_hadd () {
701 Vector2d a = new Vector2d (1, 2);
702 Vector2d b = new Vector2d (4, 0);
704 Vector2d c = a.HorizontalAdd (b);
713 public static unsafe int test_0_vector2d_min () {
714 Vector2d a = new Vector2d (1, 2);
715 Vector2d b = new Vector2d (4, 0);
717 Vector2d c = a.Min (b);
726 public static unsafe int test_0_vector2d_max () {
727 Vector2d a = new Vector2d (1, 2);
728 Vector2d b = new Vector2d (4, 0);
730 Vector2d c = a.Max (b);
740 public static unsafe int test_0_vector2d_andnot () {
741 Vector2d a = new Vector2d (1, 2);
742 Vector2d b = new Vector2d (3, 4);
744 Vector4ui c = (Vector4ui)a.AndNot (b);
745 Vector4ui ta = (Vector4ui)a;
746 Vector4ui tb = (Vector4ui)b;
748 if (c.X != (~ta.X & tb.X))
750 if (c.Y != (~ta.Y & tb.Y))
752 if (c.Z != (~ta.Z & tb.Z))
754 if (c.W != (~ta.W & tb.W))
759 public static unsafe int test_0_vector2d_div () {
760 Vector2d a = new Vector2d (1, 2);
761 Vector2d b = new Vector2d (4, 5);
772 public static unsafe int test_0_vector2d_mul () {
773 Vector2d a = new Vector2d (1, 2);
774 Vector2d b = new Vector2d (3, 5);
784 public static unsafe int test_0_vector2d_sub () {
785 Vector2d a = new Vector2d (1, 2);
786 Vector2d b = new Vector2d (3, 5);
796 public static unsafe int test_0_vector2d_add () {
797 Vector2d a = new Vector2d (1, 2);
798 Vector2d b = new Vector2d (3, 4);
808 public static unsafe int test_0_vector2d_xor () {
809 Vector2d a = new Vector2d (1, 2);
810 Vector2d b = new Vector2d (3, 4);
812 Vector4ui c = (Vector4ui)(a ^ b);
813 Vector4ui ta = (Vector4ui)a;
814 Vector4ui tb = (Vector4ui)b;
816 if (c.X != (ta.X ^ tb.X))
818 if (c.Y != (ta.Y ^ tb.Y))
820 if (c.Z != (ta.Z ^ tb.Z))
822 if (c.W != (ta.W ^ tb.W))
827 public static unsafe int test_0_vector2d_or () {
828 Vector2d a = new Vector2d (1, 2);
829 Vector2d b = new Vector2d (3, 4);
831 Vector4ui c = (Vector4ui)(a | b);
832 Vector4ui ta = (Vector4ui)a;
833 Vector4ui tb = (Vector4ui)b;
835 if (c.X != (ta.X | tb.X))
837 if (c.Y != (ta.Y | tb.Y))
839 if (c.Z != (ta.Z | tb.Z))
841 if (c.W != (ta.W | tb.W))
846 public static unsafe int test_0_vector2d_and () {
847 Vector2d a = new Vector2d (1, 2);
848 Vector2d b = new Vector2d (3, 4);
850 Vector4ui c = (Vector4ui)(a & b);
851 Vector4ui ta = (Vector4ui)a;
852 Vector4ui tb = (Vector4ui)b;
854 if (c.X != (ta.X & tb.X))
856 if (c.Y != (ta.Y & tb.Y))
858 if (c.Z != (ta.Z & tb.Z))
860 if (c.W != (ta.W & tb.W))
865 public static unsafe int test_vector8s_pack_signed_sat () {
866 Vector8s a = new Vector8s (-200, 200, 3, 0, 5, 6, 5, 4);
867 Vector8s b = new Vector8s (9, 2, 1, 2, 3, 6, 5, 6);
869 Vector16sb c = a.PackWithSignedSaturation (b);
879 public static unsafe int test_vector16sb_sub_sat () {
880 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
881 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
883 Vector16sb c = a.SubtractWithSaturation (b);
904 public static unsafe int test_vector16sb_add_sat () {
905 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
906 Vector16sb b = new Vector16sb (100, -100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
908 Vector16sb c = a.AddWithSaturation (b);
929 public static unsafe int test_vector16sb_cmp_gt () {
930 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
931 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
933 Vector16sb c = a.CompareGreaterThan (b);
953 public static int test_0_vector4ui_pack_with_sat () {
954 Vector4ui a = new Vector4ui (0xF0000000,0xF0000,3,4);
955 Vector4ui b = new Vector4ui (5,6,7,8);
957 Vector8us c = a.SignedPackWithUnsignedSaturation (b);
978 public static int test_0_vector8us_pack_with_sat () {
979 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
980 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
981 Vector16b c = a.SignedPackWithUnsignedSaturation (b);
996 public static int test_0_vector8us_mul_high () {
997 Vector8us a = new Vector8us (0xFF00, 2, 3, 0, 5, 6, 5, 4);
998 Vector8us b = new Vector8us (0xFF00, 2, 1, 2, 3, 6, 5, 6);
999 Vector8us c = a.MultiplyStoreHigh (b);
1020 public static int test_0_vector8us_cmpeq () {
1021 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
1022 Vector8us b = new Vector8us (9, 2, 1, 2, 3, 6, 5, 6);
1023 Vector8us c = a.CompareEqual (b);
1045 public static int test_0_vector4ui_cmpeq () {
1046 Vector4ui a = new Vector4ui (6,1,6,3);
1047 Vector4ui b = new Vector4ui (3,4,6,7);
1048 Vector4ui c = a.CompareEqual (b);
1054 if (c.Z != 0xFFFFFFFF)
1061 public static int test_0_vector4ui_shuffle () {
1062 Vector4ui a = new Vector4ui (1,2,3,4);
1063 Vector4ui c = a.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1076 public static int test_0_vector4ui_min () {
1077 Vector4ui a = new Vector4ui (6,1,6,3);
1078 Vector4ui b = new Vector4ui (3,4,6,7);
1079 Vector4ui c = a.Min (b);
1092 public static int test_0_vector4ui_max () {
1093 Vector4ui a = new Vector4ui (6,1,6,3);
1094 Vector4ui b = new Vector4ui (3,4,6,7);
1095 Vector4ui c = a.Max (b);
1108 public static int vector16b_cmpeq () {
1109 Vector16b a = new Vector16b (1,0,9,0,0,0,0,0,0,0,0,0,0,0,0,1);
1110 Vector16b b = new Vector16b (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
1111 Vector16b c = a.CompareEqual (b);
1149 public static int vector16b_sum_abs_diff () {
1150 Vector16b a = new Vector16b (100,20,20,20,0,0,0,0,0,0,0,0,0,0, 0, 0);
1151 Vector16sb b = new Vector16sb (0, 10,10,10,0,0,0,0,0,0,0,0,0,0,10,10);
1152 Vector8us c = a.SumOfAbsoluteDifferences (b);
1174 public static int test_0_vector16b_extract_mask () {
1175 Vector16b a = new Vector16b (0xF0,0,0xF0,0,0,0,0xF0,0xAA,0x0F,0,0xFF,0,0,0,0,0);
1176 int c = a.ExtractByteMask ();
1183 public static int test_0_vector16b_min () {
1184 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
1185 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1186 Vector16b c = a.Min (b);
1223 public static int test_0_vector16b_max () {
1224 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
1225 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1226 Vector16b c = a.Max (b);
1262 public static int test_0_vector16b_avg () {
1263 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1264 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1265 Vector16b c = a.Average (b);
1303 static unsafe Vector8us bad_method_regression_2 (Vector16b va, Vector16b vb) {
1304 Vector8us res = new Vector8us ();
1305 byte *a = (byte*)&va;
1306 byte *b = (byte*)&vb;
1309 for (int i = 0; i < 8; ++i)
1310 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
1311 res.V0 = (ushort)tmp;
1314 for (int i = 0; i < 8; ++i)
1315 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
1316 res.V4 = (ushort)tmp;
1320 /*This bug was caused the simplifier not taking notice of LDADDR on the remaining blocks.*/
1321 public static int test_2_local_simplifier_regression_other_blocks () {
1322 Vector16b a = new Vector16b (1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
1323 Vector16b b = new Vector16b (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
1324 Vector8us res = bad_method_regression_2 (a,b);
1325 return (int)res.V0 + res.V4;
1328 static unsafe Vector8us bad_method_regression (Vector16b va, Vector16b vb) {
1329 Vector8us res = new Vector8us ();
1330 byte *a = (byte*)&va;
1331 byte *b = (byte*)&vb;
1332 *((ushort*)&res) = 10;
1343 /*This bug was caused the simplifier not taking notice of LDADDR on the first block.*/
1344 public static int test_10_local_simplifier_regression_first_block () {
1345 Vector16b a = new Vector16b ();
1346 Vector16b b = new Vector16b ();
1347 Vector8us res = bad_method_regression (a,b);
1351 public static int test_0_vecto8us_shuffle_low () {
1352 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1353 Vector8us c = a.ShuffleLow (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1374 public static int test_0_vecto8us_shuffle_high () {
1375 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1376 Vector8us c = a.ShuffleHigh (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1398 public static int test_0_vecto8us_max () {
1399 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1400 Vector8us b = new Vector8us (9, 1, 1, 2, 9, 6, 5, 1000);
1401 Vector8us c = a.Max (b);
1423 public static int test_0_vecto8us_min () {
1424 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
1425 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1426 Vector8us c = a.Min (b);
1447 public static int test_0_vecto8us_avg () {
1448 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1449 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1450 Vector8us c = a.Average (b);
1471 static void store_helper (ref Vector4f x) {
1473 k = new Vector4f(9,9,9,9);
1477 public static int test_0_vector4f_byref_store ()
1480 k = new Vector4f(1,2,3,4);
1481 store_helper (ref k);
1487 public static int test_0_vector4f_init_array_element ()
1489 Vector4f[] v = new Vector4f[1];
1490 v[0] = new Vector4f(9,9,9,9);
1496 public static int test_0_vector4f_dup_high () {
1497 Vector4f a = new Vector4f (1, 2, 3, 4);
1498 Vector4f c = a.DuplicateHigh();
1511 public static int test_0_vector4f_dup_low () {
1512 Vector4f a = new Vector4f (1, 2, 3, 4);
1513 Vector4f c = a.DuplicateLow ();
1527 public static int test_0_vector4f_interleave_high () {
1528 Vector4f a = new Vector4f (1, 2, 3, 4);
1529 Vector4f b = new Vector4f (5, 6, 7, 8);
1530 Vector4f c = a.InterleaveHigh (b);
1543 public static int test_0_vector4f_interleave_low () {
1544 Vector4f a = new Vector4f (1, 2, 3, 4);
1545 Vector4f b = new Vector4f (5, 6, 7, 8);
1546 Vector4f c = a.InterleaveLow (b);
1559 public static int test_0_vector4f_rcp () {
1560 Vector4f a = new Vector4f (1, 2, 4, 8);
1561 Vector4f c = a.Reciprocal ();
1563 //Test with ranges due to the terrible precision.
1564 if (c.X < (1 - 0.01f) || c.X > (1 + 0.01f))
1566 if (c.Y < (0.5 - 0.01f) || c.Y > (0.5 + 0.01f))
1568 if (c.Z < (0.25 - 0.01f) || c.Z > (0.25 + 0.01f))
1570 if (c.W < (0.125 - 0.01f) || c.W > (0.125 + 0.01f))
1575 public static int test_0_vector4f_xor () {
1576 Vector4f a = new Vector4f (1, 2, 3, 4);
1577 Vector4f b = new Vector4f (1, 3, 3, 8);
1580 if (((Vector4ui)c).X != 0)
1582 if (((Vector4ui)c).Y != 0x400000)
1584 if (((Vector4ui)c).Z != 0)
1586 if (((Vector4ui)c).W != 0x1800000)
1591 public static int test_0_vector4f_or () {
1592 Vector4f a = new Vector4f (1, 2, 3, 4);
1593 Vector4f b = new Vector4f (1, 3, 3, 8);
1596 if (((Vector4ui)c).X != 0x3F800000)
1598 if (((Vector4ui)c).Y != 0x40400000)
1600 if (((Vector4ui)c).Z != 0x40400000)
1602 if (((Vector4ui)c).W != 0x41800000)
1606 public static int test_0_vector4f_andn () {
1607 Vector4f a = new Vector4f (1, 2, 3, 4);
1608 Vector4f b = new Vector4f (1, 3, 3, 8);
1609 Vector4f c = a.AndNot (b);
1611 if (((Vector4ui)c).X != 0)
1613 if (((Vector4ui)c).Y != 0x400000)
1615 if (((Vector4ui)c).Z != 0)
1617 if (((Vector4ui)c).W != 0x1000000)
1622 public static int test_0_vector4f_and () {
1623 Vector4f a = new Vector4f (1, 2, 3, 4);
1624 Vector4f b = new Vector4f (1, 3, 3, 8);
1627 if (((Vector4ui)c).X != 0x3F800000)
1629 if (((Vector4ui)c).Y != 0x40000000)
1631 if (((Vector4ui)c).Z != 0x40400000)
1633 if (((Vector4ui)c).W != 0x40000000)
1638 public static int test_0_vector4f_cmpord () {
1639 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1640 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1641 Vector4f c = a.CompareOrdered (b);
1643 if (((Vector4ui)c).X != 0)
1645 if (((Vector4ui)c).Y != 0)
1647 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1649 if (((Vector4ui)c).W != 0xFFFFFFFF)
1654 public static int test_0_vector4f_cmpnle () {
1655 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1656 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1657 Vector4f c = a.CompareNotLessEqual (b);
1659 if (((Vector4ui)c).X != 0xFFFFFFFF)
1661 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1663 if (((Vector4ui)c).Z != 0)
1665 if (((Vector4ui)c).W != 0)
1670 public static int test_0_vector4f_cmpnlt () {
1671 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1672 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1673 Vector4f c = a.CompareNotLessThan (b);
1675 if (((Vector4ui)c).X != 0xFFFFFFFF)
1677 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1679 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1681 if (((Vector4ui)c).W != 0)
1686 public static int test_0_vector4f_cmpneq () {
1687 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1688 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1689 Vector4f c = a.CompareNotEqual (b);
1691 if (((Vector4ui)c).X != 0xFFFFFFFF)
1693 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1695 if (((Vector4ui)c).Z != 0)
1697 if (((Vector4ui)c).W != 0xFFFFFFFF)
1702 public static int test_0_vector4f_cmpunord () {
1703 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1704 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1705 Vector4f c = a.CompareUnordered (b);
1707 if (((Vector4ui)c).X != 0xFFFFFFFF)
1709 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1711 if (((Vector4ui)c).Z != 0)
1713 if (((Vector4ui)c).W != 0)
1718 public static int test_0_vector4f_cmple () {
1719 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1720 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1721 Vector4f c = a.CompareLessEqual (b);
1723 if (((Vector4ui)c).X != 0)
1725 if (((Vector4ui)c).Y != 0)
1727 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1729 if (((Vector4ui)c).W != 0xFFFFFFFF)
1734 public static int test_0_vector4f_cmplt () {
1735 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1736 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1737 Vector4f c = a.CompareLessThan (b);
1739 if (((Vector4ui)c).X != 0)
1741 if (((Vector4ui)c).Y != 0)
1743 if (((Vector4ui)c).Z != 0)
1745 if (((Vector4ui)c).W != 0xFFFFFFFF)
1750 public static int test_0_vector4f_cmpeq () {
1751 Vector4f a = new Vector4f (float.NaN, 2, 3, 6);
1752 Vector4f b = new Vector4f (1, float.NaN, 3, 4);
1753 Vector4f c = a.CompareEqual (b);
1755 if (((Vector4ui)c).X != 0)
1757 if (((Vector4ui)c).Y != 0)
1759 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1761 if (((Vector4ui)c).W != 0)
1766 public static int test_0_vector4ui_sar () {
1767 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1769 Vector4ui c = a.ArithmeticRightShift (2);
1771 if (c.X != 0xFC000000)
1782 public static int test_0_vector4ui_unpack_high () {
1783 Vector4ui a = new Vector4ui (1,2,3,4);
1784 Vector4ui b = new Vector4ui (5,6,7,8);
1786 Vector4ui c = a.UnpackHigh(b);
1799 public static int test_0_vector4ui_unpack_low () {
1800 Vector4ui a = new Vector4ui (1,2,3,4);
1801 Vector4ui b = new Vector4ui (5,6,7,8);
1803 Vector4ui c = a.UnpackLow (b);
1816 public static int test_0_vector4ui_xor () {
1817 Vector4ui a = new Vector4ui (1,2,3,4);
1818 Vector4ui b = new Vector4ui (7,5,3,1);
1820 Vector4ui c = a ^ b;
1833 public static int test_0_vector4ui_or () {
1834 Vector4ui a = new Vector4ui (1,2,3,4);
1835 Vector4ui b = new Vector4ui (7,5,3,1);
1837 Vector4ui c = a | b;
1849 public static int test_0_vector4ui_and () {
1850 Vector4ui a = new Vector4ui (1,2,3,4);
1851 Vector4ui b = new Vector4ui (7,5,3,1);
1853 Vector4ui c = a & b;
1866 public static int test_0_vector4ui_shr () {
1867 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1869 Vector4ui c = a >> 2;
1871 if (c.X != 0x3C000000)
1882 public static int test_0_vector4ui_shl () {
1883 Vector4ui a = new Vector4ui (10,20,3,40);
1885 Vector4ui c = a << 2;
1898 public static int test_0_vector4ui_mul () {
1899 Vector4ui a = new Vector4ui (0x8888,20,3,40);
1900 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1902 Vector4ui c = a * b;
1904 if (c.X != 0xffff7800)
1914 public static int test_0_vector4ui_sub () {
1915 Vector4ui a = new Vector4ui (1,20,3,40);
1916 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1918 Vector4ui c = a - b;
1920 if (c.X != 0xff0101)
1931 public static int test_0_vector4ui_add () {
1932 Vector4ui a = new Vector4ui (0xFF00FF00u,2,3,4);
1933 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1935 Vector4ui c = a + b;
1937 if (c.X != 0xfe01fe00)
1949 static int test_0_vector4ui_accessors () {
1950 Vector4ui a = new Vector4ui (1,2,3,4);
1976 static int test_0_vector8us_sub_sat () {
1977 Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
1978 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1979 Vector8us c = a.SubtractWithSaturation (b);
2000 static int test_0_vector8us_add_sat () {
2001 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
2002 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
2003 Vector8us c = a.AddWithSaturation (b);
2024 static int test_0_vector8us_unpack_low () {
2025 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
2026 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
2027 Vector8us c = a.UnpackLow (b);
2049 static int test_0_vector8us_shift_left () {
2050 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
2052 Vector8us c = a << amt;
2063 static int test_0_vector8us_shift_right_arithmetic () {
2064 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
2066 Vector8us c = a.ArithmeticRightShift (amt);
2077 static int test_0_vector8us_shift_variable_offset () {
2079 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
2081 Vector8us c = b >> off;
2098 static int test_0_vector8us_shift_operand_is_live_after_op () {
2099 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
2101 Vector8us c = b >> 2;
2117 static int test_0_vector8us_shr_constant () {
2118 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
2119 Vector8us c = a >> 2;
2130 static int test_0_vector8us_mul () {
2131 Vector8us a = new Vector8us (0x0F00,4,5,6,7,8,9,10);
2132 Vector8us b = new Vector8us (0x0888,1,2,3,4,5,6,8);
2134 Vector8us c = a * b;
2144 static int test_0_vector8us_add () {
2145 Vector8us a = new Vector8us (0xFF00,4,5,6,7,8,9,10);
2146 Vector8us b = new Vector8us (0x8888,1,2,3,4,5,6,8);
2148 Vector8us c = a + b;
2159 static int test_0_vector8us_sub () {
2160 Vector8us a = new Vector8us (3,4,5,6,7,8,9,10);
2161 Vector8us b = new Vector8us (10,1,2,3,4,5,6,8);
2163 Vector8us c = a - b;
2175 static int test_0_vector8us_accessors () {
2176 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
2224 static int test_0_vector16b_unpack_high () {
2225 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2226 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2227 Vector16b c = a.UnpackHigh (b);
2248 static int test_0_vector16b_unpack_low () {
2249 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2250 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2251 Vector16b c = a.UnpackLow (b);
2272 static int test_0_vector16b_sub_sat () {
2273 Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2274 Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2275 Vector16b c = a.SubtractWithSaturation (b);
2286 static int test_0_vector16b_add_sat () {
2287 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2288 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2289 Vector16b c = a.AddWithSaturation (b);
2300 static int test_0_vector16b_add_ovf () {
2301 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2302 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2303 Vector16b c = a + b;
2314 static int test_0_vector16b_accessors () {
2315 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2402 public static int test_0_accessors () {
2403 Vector4f a = new Vector4f (1, 2, 3, 4);
2415 public static int test_0_packed_add_with_stack_tmp () {
2416 Vector4f a = new Vector4f (1, 2, 3, 4);
2417 Vector4f b = new Vector4f (5, 6, 7, 8);
2418 Vector4f c = new Vector4f (-1, -3, -4, -5);
2419 Vector4f d = a + b + c;
2431 public static int test_0_simple_packed_add () {
2432 Vector4f a = new Vector4f (1, 2, 3, 4);
2433 Vector4f b = new Vector4f (5, 6, 7, 8);
2447 public static int test_0_simple_packed_sub () {
2448 Vector4f a = new Vector4f (1, 2, 3, 4);
2449 Vector4f b = new Vector4f (5, 6, 7, 8);
2462 public static int test_0_simple_packed_mul () {
2463 Vector4f a = new Vector4f (1, 2, 3, 4);
2464 Vector4f b = new Vector4f (5, 6, 7, 8);
2477 public static int test_0_simple_packed_div () {
2478 Vector4f a = new Vector4f (2, 2, 3, 4);
2479 Vector4f b = new Vector4f (20, 10, 33, 12);
2492 public static int test_0_simple_packed_sqrt () {
2493 Vector4f a = new Vector4f (16, 4, 9, 25);
2506 public static int test_0_simple_packed_invsqrt () {
2507 Vector4f a = new Vector4f (16, 4, 100, 25);
2508 //this function has VERY low precision
2510 if (a.X < (1/4f - 0.01f) || a.X > (1/4f + 0.01f))
2512 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
2514 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
2516 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
2521 public static int test_0_simple_packed_min () {
2522 Vector4f a = new Vector4f (16, -4, 9, 25);
2523 Vector4f b = new Vector4f (5, 3, 9, 0);
2524 Vector4f c = a.Min (b);
2536 public static int test_0_simple_packed_max () {
2537 Vector4f a = new Vector4f (16, -4, 9, 25);
2538 Vector4f b = new Vector4f (5, 3, 9, 0);
2539 Vector4f c = a.Max (b);
2551 public static int test_0_simple_packed_hadd () {
2552 Vector4f a = new Vector4f (5, 5, 6, 6);
2553 Vector4f b = new Vector4f (7, 7, 8, 8);
2554 Vector4f c = a.HorizontalAdd (b);
2566 public static int test_0_simple_packed_hsub () {
2567 Vector4f a = new Vector4f (5, 2, 6, 1);
2568 Vector4f b = new Vector4f (7, 0, 8, 3);
2569 Vector4f c = a.HorizontalSub (b);
2581 public static int test_0_simple_packed_addsub () {
2582 Vector4f a = new Vector4f (5, 2, 6, 1);
2583 Vector4f b = new Vector4f (7, 0, 8, 3);
2584 Vector4f c = a.AddSub (b);
2596 public static int test_0_simple_packed_shuffle () {
2597 Vector4f a = new Vector4f (1, 2, 3, 4);
2598 a = a.Shuffle(ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2610 public static int test_0_packed_shuffle_with_reg_pressure () {
2611 Vector4f v = new Vector4f (1, 2, 3, 4);
2612 Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
2613 if (ff) v = v + v -v ;
2615 Vector4f r0 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2616 Vector4f r1 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2617 Vector4f x = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2618 Vector4f r2 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2619 Vector4f r3 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2627 Vector4f result = r0 + r1 + r2 + r3;
2637 if (result.Y != result.Y)
2642 public static int test_24_regs_pressure_a () {
2643 Vector4f a = new Vector4f (1, 2, 3, 4);
2651 public static int test_54_regs_pressure_b () {
2652 Vector4f a = new Vector4f (1, 2, 3, 4);
2656 Vector4f e = a + b + c;
2657 Vector4f f = d - b + a - c;
2658 Vector4f g = a - d * f - c + b;
2659 Vector4f h = a * b - c + e;
2660 Vector4f i = h - g - f - e - d - c - b - a;
2661 Vector4f j = a + b + c + d + e + f + g + h + i;
2666 public static int test_3_single_block_var_is_properly_promoted () {
2667 Vector4f a = new Vector4f (4, 5, 6, 7);
2671 Vector4f b = new Vector4f (1, 2, 3, 4);
2682 static float float_val = 45f;
2684 public static int test_0_sse2_opt_and_simd_intrinsic_proper_regalloc () {
2685 Vector4f v = new Vector4f (1, 2, 3, 4);
2686 float f = float_val;
2695 public static int Main () {
2696 return TestDriver.RunTests (typeof (SimdTests));