4 public class SimdTests {
6 static void InitByRef (out Vector4i v) {
9 throw new Exception ("ddd");
12 static int test_0_vector4i_one_element_ctor_with_byref ()
27 static int test_0_vector2d_one_element_ctor () {
28 Vector2d a = new Vector2d (99);
36 static int test_0_vector2ul_one_element_ctor () {
37 Vector2ul a = new Vector2ul (99);
46 static int test_0_vector2l_one_element_ctor () {
47 Vector2l a = new Vector2l (99);
56 static int test_0_vector4f_one_element_ctor () {
57 Vector4f a = new Vector4f (99);
70 static int test_0_vector4ui_one_element_ctor () {
71 Vector4ui a = new Vector4ui (99);
84 static int test_0_vector4i_one_element_ctor () {
85 Vector4i a = new Vector4i (99);
98 static int test_0_vector8us_one_element_ctor () {
99 Vector8us a = new Vector8us (99);
120 static int test_0_vector8s_one_element_ctor () {
121 Vector8s a = new Vector8s (99);
142 static int test_0_vector16sb_one_element_ctor () {
143 Vector16sb a = new Vector16sb (99);
180 static int test_0_vector16b_one_element_ctor () {
181 Vector16b a = new Vector16b (99);
218 public static unsafe int test_0_sizeof_returns_16_2d ()
220 double[] array = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
221 fixed (double *ptr = &array [0]) {
222 Vector2d *f = (Vector2d*)ptr;
228 if (a.X != 1 || a.Y != 2)
230 if (b.X != 3 || b.Y != 4)
232 if (c.X != 5 || c.Y != 6)
234 if (d.X != 7 || d.Y != 8)
240 public static unsafe int test_0_sizeof_returns_16_4f ()
242 float[] array = new float[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
243 fixed (float *ptr = &array [0]) {
244 Vector4f *f = (Vector4f*)ptr;
250 if (a.X != 1 || a.W != 4)
252 if (b.X != 5 || b.W != 8)
254 if (c.X != 9 || c.W != 12)
256 if (d.X != 13 || d.W != 16)
262 public static unsafe int test_0_sizeof_returns_16_8d ()
264 short[] array = new short[40];
265 for (int i = 0; i < 40; ++i)
266 array [i] = (short) (i + 1);
268 fixed (short *ptr = &array [0]) {
269 Vector8s *f = (Vector8s*)ptr;
275 if (a.V0 != 1 || a.V7 != 8)
277 if (b.V0 != 9 || b.V7 != 16)
279 if (c.V0 != 17 || c.V7 != 24)
281 if (d.V0 != 25 || d.V7 != 32)
287 public static unsafe int test_0_sizeof_returns_16_16b ()
289 byte[] array = new byte[80];
290 for (int i = 0; i < 80; ++i)
291 array [i] = (byte) (i + 1);
293 fixed (byte *ptr = &array [0]) {
294 Vector16b *f = (Vector16b*)ptr;
300 if (a.V0 != 1 || a.V15 != 16)
302 if (b.V0 != 17 || b.V15 != 32)
304 if (c.V0 != 33 || c.V15 != 48)
306 if (d.V0 != 49 || d.V15 != 64)
311 public static int test_0_bug_462457 ()
313 Vector4f sum = new Vector4f(0,0,0,0);
314 Vector4f add = new Vector4f(1.0F,1.0F,1.0F,1.0F);
316 for (int i = 0; i < 10; ++i)
324 public static int test_0_vector16b_operator_neq () {
325 Vector16b a = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
326 Vector16b b = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
335 public static int test_0_vector16b_operator_eq () {
336 Vector16b a = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
337 Vector16b b = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
346 public static int test_0_vector8us_operator_neq () {
347 Vector8us a = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
348 Vector8us b = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
357 public static int test_0_vector8us_operator_eq () {
358 Vector8us a = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
359 Vector8us b = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
368 public static int test_0_set_vector4f_operator_neq () {
369 Vector4f a = new Vector4f(1, 2, 3, 4);
370 Vector4f b = new Vector4f(1, 2, 3, 4);
374 a = new Vector4f(1, 2, float.NaN, 4);
375 b = new Vector4f(1, 2, float.NaN, 4);
376 if (!(a != b)) //NaN is always !=
379 a = new Vector4f(1, 2, float.NaN, 4);
380 b = new Vector4f(1, 2, 10, 4);
384 a = new Vector4f(1, 2, float.PositiveInfinity, 4);
385 b = new Vector4f(1, 2, float.PositiveInfinity, 4);
389 a = new Vector4f(1, 2, 20, 4);
390 b = new Vector4f(1, 2, 30, 4);
397 public static int test_0_set_vector4f_operator_eq () {
398 Vector4f a = new Vector4f(1, 2, 3, 4);
399 Vector4f b = new Vector4f(1, 2, 3, 4);
403 a = new Vector4f(1, 2, float.NaN, 4);
404 b = new Vector4f(1, 2, float.NaN, 4);
408 a = new Vector4f(1, 2, 10, 4);
409 b = new Vector4f(1, 2, float.NaN, 4);
413 a = new Vector4f(1, 2, float.PositiveInfinity, 4);
414 b = new Vector4f(1, 2, float.PositiveInfinity, 4);
420 public static int test_1_set_vector4ui_operator_neq () {
421 Vector4ui a = new Vector4ui(1, 2, 3, 4);
422 Vector4ui b = new Vector4ui(1, 2, 3, 4);
428 public static int test_0_set_vector4ui_operator_neq () {
429 Vector4ui a = new Vector4ui(1, 2, 3, 4);
430 Vector4ui b = new Vector4ui(111, 2, 3, 4);
436 public static int test_0_set_vector4ui_operator_eq () {
437 Vector4ui a = new Vector4ui(1, 2, 3, 4);
438 Vector4ui b = new Vector4ui(1, 2, 3, 4);
444 public static int test_1_set_vector4ui_operator_eq () {
445 Vector4ui a = new Vector4ui(1, 2, 3, 4);
446 Vector4ui b = new Vector4ui(111, 2, 3, 4);
452 public static int test_0_set_vector_small_array () {
453 uint[] array = new uint[3];
456 array.SetVector (new Vector4ui (), 0);
458 } catch (IndexOutOfRangeException) {
463 public static int test_0_set_vector_negative_index () {
464 uint[] array = new uint[4];
467 array.SetVector (new Vector4ui (), -1);
469 } catch (IndexOutOfRangeException) {
474 public static int test_0_set_vector_bounds_error () {
475 uint[] array = new uint[4];
478 array.SetVector (new Vector4ui (), 1);
480 } catch (IndexOutOfRangeException) {
485 public static int test_0_set_vector () {
486 uint[] array = new uint[10];
487 Vector4ui a = new Vector4ui (11, 22, 33, 44);
489 array.SetVector (a, 1);
502 public static int test_0_get_vector_small_array () {
503 uint[] array = new uint[3];
506 Vector4ui res = array.GetVector (0);
508 } catch (IndexOutOfRangeException) {
513 public static int test_0_get_vector_negative_index () {
514 uint[] array = new uint[4];
517 Vector4ui res = array.GetVector (-1);
519 } catch (IndexOutOfRangeException) {
524 public static int test_0_get_vector_bounds_error () {
525 uint[] array = new uint[4];
528 Vector4ui res = array.GetVector (1);
530 } catch (IndexOutOfRangeException) {
535 public static int test_0_get_vector () {
536 uint[] array = new uint[] { 11, 22, 33, 44, 55, 66, 77, 88, 99, 111 };
538 Vector4ui res = array.GetVector (1);
552 public static int test_0_accessor_vecto2l () {
553 Vector2l a = new Vector2l (3, 2);
560 a.X = 500000000000055l;
563 if (a.X != 500000000000055l)
565 if (a.Y != -12345678900l)
570 public static int test_0_accessor_vecto2d () {
571 Vector2d a = new Vector2d (3, 2);
581 if (a.X != 5000000000000)
588 public static int test_0_accessor_vecto4f () {
589 Vector4f a = new Vector4f (1,2,3,4);
616 public static int test_0_accessor_vecto4i () {
617 Vector4i a = new Vector4i (0x70000000, -1, 3, 4);
619 if (a.X != 0x70000000)
639 if (a.W != -44444444)
644 public static int test_0_accessor_vecto4ui () {
645 Vector4ui a = new Vector4ui (0xF0000000, 0xF0000, 3, 4);
647 if (a.X != 0xF0000000)
672 static float use_getter_with_byref (ref Vector4f a) {
676 public static int test_0_accessor_and_byref_var () {
677 Vector4f a = new Vector4f (1, 2, 3, 4);
678 if (use_getter_with_byref (ref a) != 4)
683 public static unsafe int test_0_vector2ul_slr () {
684 Vector2ul a = new Vector2ul (1, 6);
686 Vector2ul c = a >> 1;
694 public static unsafe int test_0_vector2l_cmp_gt () {
695 Vector2l a = new Vector2l (10, 5);
696 Vector2l b = new Vector2l (-1, 5);
698 Vector2l c = a.CompareGreaterThan (b);
707 public static unsafe int test_0_vector2l_cmp_eq () {
708 Vector2l a = new Vector2l (0xFF, 5);
709 Vector2l b = new Vector2l (0xFF000000FFL, 5);
711 Vector2l c = a.CompareEqual (b);
720 public static unsafe int test_0_vector2l_srl () {
721 Vector2l a = new Vector2l (1, 6);
723 Vector2l c = a.LogicalRightShift (1);
732 public static unsafe int test_0_vector2l_unpack_high () {
733 Vector2l a = new Vector2l (1, 6);
734 Vector2l b = new Vector2l (3, 4);
736 Vector2l c = a.UnpackHigh (b);
745 public static unsafe int test_0_vector2l_unpack_low () {
746 Vector2l a = new Vector2l (1, 6);
747 Vector2l b = new Vector2l (3, 4);
749 Vector2l c = a.UnpackLow (b);
758 public static unsafe int test_0_vector2l_xor () {
759 Vector2l a = new Vector2l (1, 6);
760 Vector2l b = new Vector2l (3, 4);
771 public static unsafe int test_0_vector2l_or () {
772 Vector2l a = new Vector2l (1, 6);
773 Vector2l b = new Vector2l (3, 4);
784 public static unsafe int test_0_vector2l_and () {
785 Vector2l a = new Vector2l (1, 6);
786 Vector2l b = new Vector2l (3, 4);
797 public static unsafe int test_0_vector2l_shl() {
798 Vector2l a = new Vector2l (1, 6);
808 public static unsafe int test_0_vector2l_sub() {
809 Vector2l a = new Vector2l (1, 6);
810 Vector2l b = new Vector2l (3, 4);
821 public static unsafe int test_0_vector2l_add () {
822 Vector2l a = new Vector2l (1, 2);
823 Vector2l b = new Vector2l (3, 4);
834 public static unsafe int test_0_vector2d_dup () {
835 Vector2d a = new Vector2d (3, 2);
837 Vector2d c = a.Duplicate ();
846 public static unsafe int test_0_vector2d_cmp_eq () {
847 Vector2d a = new Vector2d (3, 2);
848 Vector2d b = new Vector2d (3, 4);
850 Vector4ui c = (Vector4ui)a.CompareEqual (b);
852 if (c.X != 0xFFFFFFFF)
854 if (c.Y != 0xFFFFFFFF)
863 public static unsafe int test_0_vector2d_unpack_low () {
864 Vector2d a = new Vector2d (1, 2);
865 Vector2d b = new Vector2d (4, 5);
867 Vector2d c = a.InterleaveLow (b);
876 public static unsafe int test_0_vector2d_unpack_high () {
877 Vector2d a = new Vector2d (1, 2);
878 Vector2d b = new Vector2d (4, 5);
880 Vector2d c = a.InterleaveHigh (b);
888 public static unsafe int test_0_vector2d_addsub () {
889 Vector2d a = new Vector2d (1, 2);
890 Vector2d b = new Vector2d (4, 1);
892 Vector2d c = a.AddSub (b);
900 public static unsafe int test_0_vector2d_hsub () {
901 Vector2d a = new Vector2d (1, 2);
902 Vector2d b = new Vector2d (4, 1);
904 Vector2d c = a.HorizontalSub (b);
913 public static unsafe int test_0_vector2d_hadd () {
914 Vector2d a = new Vector2d (1, 2);
915 Vector2d b = new Vector2d (4, 0);
917 Vector2d c = a.HorizontalAdd (b);
926 public static unsafe int test_0_vector2d_min () {
927 Vector2d a = new Vector2d (1, 2);
928 Vector2d b = new Vector2d (4, 0);
930 Vector2d c = a.Min (b);
939 public static unsafe int test_0_vector2d_max () {
940 Vector2d a = new Vector2d (1, 2);
941 Vector2d b = new Vector2d (4, 0);
943 Vector2d c = a.Max (b);
953 public static unsafe int test_0_vector2d_andnot () {
954 Vector2d a = new Vector2d (1, 2);
955 Vector2d b = new Vector2d (3, 4);
957 Vector4ui c = (Vector4ui)a.AndNot (b);
958 Vector4ui ta = (Vector4ui)a;
959 Vector4ui tb = (Vector4ui)b;
961 if (c.X != (~ta.X & tb.X))
963 if (c.Y != (~ta.Y & tb.Y))
965 if (c.Z != (~ta.Z & tb.Z))
967 if (c.W != (~ta.W & tb.W))
972 public static unsafe int test_0_vector2d_div () {
973 Vector2d a = new Vector2d (1, 2);
974 Vector2d b = new Vector2d (4, 5);
985 public static unsafe int test_0_vector2d_mul () {
986 Vector2d a = new Vector2d (1, 2);
987 Vector2d b = new Vector2d (3, 5);
997 public static unsafe int test_0_vector2d_sub () {
998 Vector2d a = new Vector2d (1, 2);
999 Vector2d b = new Vector2d (3, 5);
1009 public static unsafe int test_0_vector2d_add () {
1010 Vector2d a = new Vector2d (1, 2);
1011 Vector2d b = new Vector2d (3, 4);
1021 public static unsafe int test_0_vector2d_xor () {
1022 Vector2d a = new Vector2d (1, 2);
1023 Vector2d b = new Vector2d (3, 4);
1025 Vector4ui c = (Vector4ui)(a ^ b);
1026 Vector4ui ta = (Vector4ui)a;
1027 Vector4ui tb = (Vector4ui)b;
1029 if (c.X != (ta.X ^ tb.X))
1031 if (c.Y != (ta.Y ^ tb.Y))
1033 if (c.Z != (ta.Z ^ tb.Z))
1035 if (c.W != (ta.W ^ tb.W))
1040 public static unsafe int test_0_vector2d_or () {
1041 Vector2d a = new Vector2d (1, 2);
1042 Vector2d b = new Vector2d (3, 4);
1044 Vector4ui c = (Vector4ui)(a | b);
1045 Vector4ui ta = (Vector4ui)a;
1046 Vector4ui tb = (Vector4ui)b;
1048 if (c.X != (ta.X | tb.X))
1050 if (c.Y != (ta.Y | tb.Y))
1052 if (c.Z != (ta.Z | tb.Z))
1054 if (c.W != (ta.W | tb.W))
1059 public static unsafe int test_0_vector2d_and () {
1060 Vector2d a = new Vector2d (1, 2);
1061 Vector2d b = new Vector2d (3, 4);
1063 Vector4ui c = (Vector4ui)(a & b);
1064 Vector4ui ta = (Vector4ui)a;
1065 Vector4ui tb = (Vector4ui)b;
1067 if (c.X != (ta.X & tb.X))
1069 if (c.Y != (ta.Y & tb.Y))
1071 if (c.Z != (ta.Z & tb.Z))
1073 if (c.W != (ta.W & tb.W))
1078 public static unsafe int test_vector8s_pack_signed_sat () {
1079 Vector8s a = new Vector8s (-200, 200, 3, 0, 5, 6, 5, 4);
1080 Vector8s b = new Vector8s (9, 2, 1, 2, 3, 6, 5, 6);
1082 Vector16sb c = a.PackWithSignedSaturation (b);
1092 public static unsafe int test_vector16sb_sub_sat () {
1093 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1094 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
1096 Vector16sb c = a.SubtractWithSaturation (b);
1117 public static unsafe int test_vector16sb_add_sat () {
1118 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1119 Vector16sb b = new Vector16sb (100, -100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
1121 Vector16sb c = a.AddWithSaturation (b);
1142 public static unsafe int test_vector16sb_cmp_gt () {
1143 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1144 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
1146 Vector16sb c = a.CompareGreaterThan (b);
1166 public static int test_0_vector4ui_pack_with_sat () {
1167 Vector4ui a = new Vector4ui (0xF0000000,0xF0000,3,4);
1168 Vector4ui b = new Vector4ui (5,6,7,8);
1170 Vector8us c = a.SignedPackWithUnsignedSaturation (b);
1191 public static int test_0_vector8us_pack_with_sat () {
1192 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1193 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
1194 Vector16b c = a.SignedPackWithUnsignedSaturation (b);
1209 public static int test_0_vector8us_mul_high () {
1210 Vector8us a = new Vector8us (0xFF00, 2, 3, 0, 5, 6, 5, 4);
1211 Vector8us b = new Vector8us (0xFF00, 2, 1, 2, 3, 6, 5, 6);
1212 Vector8us c = a.MultiplyStoreHigh (b);
1233 public static int test_0_vector8us_cmpeq () {
1234 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
1235 Vector8us b = new Vector8us (9, 2, 1, 2, 3, 6, 5, 6);
1236 Vector8us c = a.CompareEqual (b);
1258 public static int test_0_vector4ui_cmpeq () {
1259 Vector4ui a = new Vector4ui (6,1,6,3);
1260 Vector4ui b = new Vector4ui (3,4,6,7);
1261 Vector4ui c = a.CompareEqual (b);
1267 if (c.Z != 0xFFFFFFFF)
1274 public static int test_0_vector4ui_shuffle () {
1275 Vector4ui a = new Vector4ui (1,2,3,4);
1276 Vector4ui c = a.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1289 public static int test_0_vector4ui_min () {
1290 Vector4ui a = new Vector4ui (6,1,6,3);
1291 Vector4ui b = new Vector4ui (3,4,6,7);
1292 Vector4ui c = a.Min (b);
1305 public static int test_0_vector4ui_max () {
1306 Vector4ui a = new Vector4ui (6,1,6,3);
1307 Vector4ui b = new Vector4ui (3,4,6,7);
1308 Vector4ui c = a.Max (b);
1321 public static int vector16b_cmpeq () {
1322 Vector16b a = new Vector16b (1,0,9,0,0,0,0,0,0,0,0,0,0,0,0,1);
1323 Vector16b b = new Vector16b (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
1324 Vector16b c = a.CompareEqual (b);
1362 public static int vector16b_sum_abs_diff () {
1363 Vector16b a = new Vector16b (100,20,20,20,0,0,0,0,0,0,0,0,0,0, 0, 0);
1364 Vector16sb b = new Vector16sb (0, 10,10,10,0,0,0,0,0,0,0,0,0,0,10,10);
1365 Vector8us c = a.SumOfAbsoluteDifferences (b);
1387 public static int test_0_vector16b_extract_mask () {
1388 Vector16b a = new Vector16b (0xF0,0,0xF0,0,0,0,0xF0,0xAA,0x0F,0,0xFF,0,0,0,0,0);
1389 int c = a.ExtractByteMask ();
1396 public static int test_0_vector16b_min () {
1397 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
1398 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1399 Vector16b c = a.Min (b);
1436 public static int test_0_vector16b_max () {
1437 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
1438 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1439 Vector16b c = a.Max (b);
1475 public static int test_0_vector16b_avg () {
1476 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1477 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1478 Vector16b c = a.Average (b);
1516 static unsafe Vector8us bad_method_regression_2 (Vector16b va, Vector16b vb) {
1517 Vector8us res = new Vector8us ();
1518 byte *a = (byte*)&va;
1519 byte *b = (byte*)&vb;
1522 for (int i = 0; i < 8; ++i)
1523 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
1524 res.V0 = (ushort)tmp;
1527 for (int i = 0; i < 8; ++i)
1528 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
1529 res.V4 = (ushort)tmp;
1533 /*This bug was caused the simplifier not taking notice of LDADDR on the remaining blocks.*/
1534 public static int test_2_local_simplifier_regression_other_blocks () {
1535 Vector16b a = new Vector16b (1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
1536 Vector16b b = new Vector16b (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
1537 Vector8us res = bad_method_regression_2 (a,b);
1538 return (int)res.V0 + res.V4;
1541 static unsafe Vector8us bad_method_regression (Vector16b va, Vector16b vb) {
1542 Vector8us res = new Vector8us ();
1543 byte *a = (byte*)&va;
1544 byte *b = (byte*)&vb;
1545 *((ushort*)&res) = 10;
1556 /*This bug was caused the simplifier not taking notice of LDADDR on the first block.*/
1557 public static int test_10_local_simplifier_regression_first_block () {
1558 Vector16b a = new Vector16b ();
1559 Vector16b b = new Vector16b ();
1560 Vector8us res = bad_method_regression (a,b);
1564 public static int test_0_vecto8us_shuffle_low () {
1565 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1566 Vector8us c = a.ShuffleLow (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1587 public static int test_0_vecto8us_shuffle_high () {
1588 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1589 Vector8us c = a.ShuffleHigh (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1611 public static int test_0_vecto8us_max () {
1612 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1613 Vector8us b = new Vector8us (9, 1, 1, 2, 9, 6, 5, 1000);
1614 Vector8us c = a.Max (b);
1636 public static int test_0_vecto8us_min () {
1637 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
1638 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1639 Vector8us c = a.Min (b);
1660 public static int test_0_vecto8us_avg () {
1661 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1662 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1663 Vector8us c = a.Average (b);
1684 static void store_helper (ref Vector4f x) {
1686 k = new Vector4f(9,9,9,9);
1690 public static int test_0_vector4f_byref_store ()
1693 k = new Vector4f(1,2,3,4);
1694 store_helper (ref k);
1700 public static int test_0_vector4f_init_array_element ()
1702 Vector4f[] v = new Vector4f[1];
1703 v[0] = new Vector4f(9,9,9,9);
1709 public static int test_0_vector4f_dup_high () {
1710 Vector4f a = new Vector4f (1, 2, 3, 4);
1711 Vector4f c = a.DuplicateHigh();
1724 public static int test_0_vector4f_dup_low () {
1725 Vector4f a = new Vector4f (1, 2, 3, 4);
1726 Vector4f c = a.DuplicateLow ();
1740 public static int test_0_vector4f_interleave_high () {
1741 Vector4f a = new Vector4f (1, 2, 3, 4);
1742 Vector4f b = new Vector4f (5, 6, 7, 8);
1743 Vector4f c = a.InterleaveHigh (b);
1756 public static int test_0_vector4f_interleave_low () {
1757 Vector4f a = new Vector4f (1, 2, 3, 4);
1758 Vector4f b = new Vector4f (5, 6, 7, 8);
1759 Vector4f c = a.InterleaveLow (b);
1772 public static int test_0_vector4f_rcp () {
1773 Vector4f a = new Vector4f (1, 2, 4, 8);
1774 Vector4f c = a.Reciprocal ();
1776 //Test with ranges due to the terrible precision.
1777 if (c.X < (1 - 0.01f) || c.X > (1 + 0.01f))
1779 if (c.Y < (0.5 - 0.01f) || c.Y > (0.5 + 0.01f))
1781 if (c.Z < (0.25 - 0.01f) || c.Z > (0.25 + 0.01f))
1783 if (c.W < (0.125 - 0.01f) || c.W > (0.125 + 0.01f))
1788 public static int test_0_vector4f_xor () {
1789 Vector4f a = new Vector4f (1, 2, 3, 4);
1790 Vector4f b = new Vector4f (1, 3, 3, 8);
1793 if (((Vector4ui)c).X != 0)
1795 if (((Vector4ui)c).Y != 0x400000)
1797 if (((Vector4ui)c).Z != 0)
1799 if (((Vector4ui)c).W != 0x1800000)
1804 public static int test_0_vector4f_or () {
1805 Vector4f a = new Vector4f (1, 2, 3, 4);
1806 Vector4f b = new Vector4f (1, 3, 3, 8);
1809 if (((Vector4ui)c).X != 0x3F800000)
1811 if (((Vector4ui)c).Y != 0x40400000)
1813 if (((Vector4ui)c).Z != 0x40400000)
1815 if (((Vector4ui)c).W != 0x41800000)
1819 public static int test_0_vector4f_andn () {
1820 Vector4f a = new Vector4f (1, 2, 3, 4);
1821 Vector4f b = new Vector4f (1, 3, 3, 8);
1822 Vector4f c = a.AndNot (b);
1824 if (((Vector4ui)c).X != 0)
1826 if (((Vector4ui)c).Y != 0x400000)
1828 if (((Vector4ui)c).Z != 0)
1830 if (((Vector4ui)c).W != 0x1000000)
1835 public static int test_0_vector4f_and () {
1836 Vector4f a = new Vector4f (1, 2, 3, 4);
1837 Vector4f b = new Vector4f (1, 3, 3, 8);
1840 if (((Vector4ui)c).X != 0x3F800000)
1842 if (((Vector4ui)c).Y != 0x40000000)
1844 if (((Vector4ui)c).Z != 0x40400000)
1846 if (((Vector4ui)c).W != 0x40000000)
1851 public static int test_0_vector4f_cmpord () {
1852 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1853 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1854 Vector4f c = a.CompareOrdered (b);
1856 if (((Vector4ui)c).X != 0)
1858 if (((Vector4ui)c).Y != 0)
1860 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1862 if (((Vector4ui)c).W != 0xFFFFFFFF)
1867 public static int test_0_vector4f_cmpnle () {
1868 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1869 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1870 Vector4f c = a.CompareNotLessEqual (b);
1872 if (((Vector4ui)c).X != 0xFFFFFFFF)
1874 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1876 if (((Vector4ui)c).Z != 0)
1878 if (((Vector4ui)c).W != 0)
1883 public static int test_0_vector4f_cmpnlt () {
1884 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1885 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1886 Vector4f c = a.CompareNotLessThan (b);
1888 if (((Vector4ui)c).X != 0xFFFFFFFF)
1890 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1892 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1894 if (((Vector4ui)c).W != 0)
1899 public static int test_0_vector4f_cmpneq () {
1900 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1901 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1902 Vector4f c = a.CompareNotEqual (b);
1904 if (((Vector4ui)c).X != 0xFFFFFFFF)
1906 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1908 if (((Vector4ui)c).Z != 0)
1910 if (((Vector4ui)c).W != 0xFFFFFFFF)
1915 public static int test_0_vector4f_cmpunord () {
1916 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1917 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1918 Vector4f c = a.CompareUnordered (b);
1920 if (((Vector4ui)c).X != 0xFFFFFFFF)
1922 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1924 if (((Vector4ui)c).Z != 0)
1926 if (((Vector4ui)c).W != 0)
1931 public static int test_0_vector4f_cmple () {
1932 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1933 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1934 Vector4f c = a.CompareLessEqual (b);
1936 if (((Vector4ui)c).X != 0)
1938 if (((Vector4ui)c).Y != 0)
1940 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1942 if (((Vector4ui)c).W != 0xFFFFFFFF)
1947 public static int test_0_vector4f_cmplt () {
1948 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1949 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1950 Vector4f c = a.CompareLessThan (b);
1952 if (((Vector4ui)c).X != 0)
1954 if (((Vector4ui)c).Y != 0)
1956 if (((Vector4ui)c).Z != 0)
1958 if (((Vector4ui)c).W != 0xFFFFFFFF)
1963 public static int test_0_vector4f_cmpeq () {
1964 Vector4f a = new Vector4f (float.NaN, 2, 3, 6);
1965 Vector4f b = new Vector4f (1, float.NaN, 3, 4);
1966 Vector4f c = a.CompareEqual (b);
1968 if (((Vector4ui)c).X != 0)
1970 if (((Vector4ui)c).Y != 0)
1972 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1974 if (((Vector4ui)c).W != 0)
1979 public static int test_0_vector4ui_sar () {
1980 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1982 Vector4ui c = a.ArithmeticRightShift (2);
1984 if (c.X != 0xFC000000)
1995 public static int test_0_vector4ui_unpack_high () {
1996 Vector4ui a = new Vector4ui (1,2,3,4);
1997 Vector4ui b = new Vector4ui (5,6,7,8);
1999 Vector4ui c = a.UnpackHigh(b);
2012 public static int test_0_vector4ui_unpack_low () {
2013 Vector4ui a = new Vector4ui (1,2,3,4);
2014 Vector4ui b = new Vector4ui (5,6,7,8);
2016 Vector4ui c = a.UnpackLow (b);
2029 public static int test_0_vector4ui_xor () {
2030 Vector4ui a = new Vector4ui (1,2,3,4);
2031 Vector4ui b = new Vector4ui (7,5,3,1);
2033 Vector4ui c = a ^ b;
2046 public static int test_0_vector4ui_or () {
2047 Vector4ui a = new Vector4ui (1,2,3,4);
2048 Vector4ui b = new Vector4ui (7,5,3,1);
2050 Vector4ui c = a | b;
2062 public static int test_0_vector4ui_and () {
2063 Vector4ui a = new Vector4ui (1,2,3,4);
2064 Vector4ui b = new Vector4ui (7,5,3,1);
2066 Vector4ui c = a & b;
2079 public static int test_0_vector4ui_shr () {
2080 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
2082 Vector4ui c = a >> 2;
2084 if (c.X != 0x3C000000)
2095 public static int test_0_vector4ui_shl () {
2096 Vector4ui a = new Vector4ui (10,20,3,40);
2098 Vector4ui c = a << 2;
2111 public static int test_0_vector4ui_mul () {
2112 Vector4ui a = new Vector4ui (0x8888,20,3,40);
2113 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
2115 Vector4ui c = a * b;
2117 if (c.X != 0xffff7800)
2127 public static int test_0_vector4ui_sub () {
2128 Vector4ui a = new Vector4ui (1,20,3,40);
2129 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
2131 Vector4ui c = a - b;
2133 if (c.X != 0xff0101)
2144 public static int test_0_vector4ui_add () {
2145 Vector4ui a = new Vector4ui (0xFF00FF00u,2,3,4);
2146 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
2148 Vector4ui c = a + b;
2150 if (c.X != 0xfe01fe00)
2162 static int test_0_vector4ui_accessors () {
2163 Vector4ui a = new Vector4ui (1,2,3,4);
2189 static int test_0_vector8us_sub_sat () {
2190 Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
2191 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
2192 Vector8us c = a.SubtractWithSaturation (b);
2213 static int test_0_vector8us_add_sat () {
2214 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
2215 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
2216 Vector8us c = a.AddWithSaturation (b);
2237 static int test_0_vector8us_unpack_low () {
2238 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
2239 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
2240 Vector8us c = a.UnpackLow (b);
2262 static int test_0_vector8us_shift_left () {
2263 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
2265 Vector8us c = a << amt;
2276 static int test_0_vector8us_shift_right_arithmetic () {
2277 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
2279 Vector8us c = a.ArithmeticRightShift (amt);
2290 static int test_0_vector8us_shift_variable_offset () {
2292 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
2294 Vector8us c = b >> off;
2311 static int test_0_vector8us_shift_operand_is_live_after_op () {
2312 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
2314 Vector8us c = b >> 2;
2330 static int test_0_vector8us_shr_constant () {
2331 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
2332 Vector8us c = a >> 2;
2343 static int test_0_vector8us_mul () {
2344 Vector8us a = new Vector8us (0x0F00,4,5,6,7,8,9,10);
2345 Vector8us b = new Vector8us (0x0888,1,2,3,4,5,6,8);
2347 Vector8us c = a * b;
2357 static int test_0_vector8us_add () {
2358 Vector8us a = new Vector8us (0xFF00,4,5,6,7,8,9,10);
2359 Vector8us b = new Vector8us (0x8888,1,2,3,4,5,6,8);
2361 Vector8us c = a + b;
2372 static int test_0_vector8us_sub () {
2373 Vector8us a = new Vector8us (3,4,5,6,7,8,9,10);
2374 Vector8us b = new Vector8us (10,1,2,3,4,5,6,8);
2376 Vector8us c = a - b;
2388 static int test_0_vector8us_accessors () {
2389 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
2437 static int test_0_vector16b_unpack_high () {
2438 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2439 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2440 Vector16b c = a.UnpackHigh (b);
2461 static int test_0_vector16b_unpack_low () {
2462 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2463 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2464 Vector16b c = a.UnpackLow (b);
2485 static int test_0_vector16b_sub_sat () {
2486 Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2487 Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2488 Vector16b c = a.SubtractWithSaturation (b);
2499 static int test_0_vector16b_add_sat () {
2500 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2501 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2502 Vector16b c = a.AddWithSaturation (b);
2513 static int test_0_vector16b_add_ovf () {
2514 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2515 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2516 Vector16b c = a + b;
2527 static int test_0_vector16b_accessors () {
2528 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2615 public static int test_0_accessors () {
2616 Vector4f a = new Vector4f (1, 2, 3, 4);
2628 public static int test_0_packed_add_with_stack_tmp () {
2629 Vector4f a = new Vector4f (1, 2, 3, 4);
2630 Vector4f b = new Vector4f (5, 6, 7, 8);
2631 Vector4f c = new Vector4f (-1, -3, -4, -5);
2632 Vector4f d = a + b + c;
2644 public static int test_0_simple_packed_add () {
2645 Vector4f a = new Vector4f (1, 2, 3, 4);
2646 Vector4f b = new Vector4f (5, 6, 7, 8);
2660 public static int test_0_simple_packed_sub () {
2661 Vector4f a = new Vector4f (1, 2, 3, 4);
2662 Vector4f b = new Vector4f (5, 6, 7, 8);
2675 public static int test_0_simple_packed_mul () {
2676 Vector4f a = new Vector4f (1, 2, 3, 4);
2677 Vector4f b = new Vector4f (5, 6, 7, 8);
2690 public static int test_0_simple_packed_div () {
2691 Vector4f a = new Vector4f (2, 2, 3, 4);
2692 Vector4f b = new Vector4f (20, 10, 33, 12);
2705 public static int test_0_simple_packed_sqrt () {
2706 Vector4f a = new Vector4f (16, 4, 9, 25);
2719 public static int test_0_simple_packed_invsqrt () {
2720 Vector4f a = new Vector4f (16, 4, 100, 25);
2721 //this function has VERY low precision
2723 if (a.X < (1/4f - 0.01f) || a.X > (1/4f + 0.01f))
2725 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
2727 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
2729 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
2734 public static int test_0_simple_packed_min () {
2735 Vector4f a = new Vector4f (16, -4, 9, 25);
2736 Vector4f b = new Vector4f (5, 3, 9, 0);
2737 Vector4f c = a.Min (b);
2749 public static int test_0_simple_packed_max () {
2750 Vector4f a = new Vector4f (16, -4, 9, 25);
2751 Vector4f b = new Vector4f (5, 3, 9, 0);
2752 Vector4f c = a.Max (b);
2764 public static int test_0_simple_packed_hadd () {
2765 Vector4f a = new Vector4f (5, 5, 6, 6);
2766 Vector4f b = new Vector4f (7, 7, 8, 8);
2767 Vector4f c = a.HorizontalAdd (b);
2779 public static int test_0_simple_packed_hsub () {
2780 Vector4f a = new Vector4f (5, 2, 6, 1);
2781 Vector4f b = new Vector4f (7, 0, 8, 3);
2782 Vector4f c = a.HorizontalSub (b);
2794 public static int test_0_simple_packed_addsub () {
2795 Vector4f a = new Vector4f (5, 2, 6, 1);
2796 Vector4f b = new Vector4f (7, 0, 8, 3);
2797 Vector4f c = a.AddSub (b);
2809 public static int test_0_simple_packed_shuffle () {
2810 Vector4f a = new Vector4f (1, 2, 3, 4);
2811 a = a.Shuffle(ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2823 public static int test_0_packed_shuffle_with_reg_pressure () {
2824 Vector4f v = new Vector4f (1, 2, 3, 4);
2825 Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
2826 if (ff) v = v + v -v ;
2828 Vector4f r0 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2829 Vector4f r1 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2830 Vector4f x = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2831 Vector4f r2 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2832 Vector4f r3 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2840 Vector4f result = r0 + r1 + r2 + r3;
2850 if (result.Y != result.Y)
2855 public static int test_24_regs_pressure_a () {
2856 Vector4f a = new Vector4f (1, 2, 3, 4);
2864 public static int test_54_regs_pressure_b () {
2865 Vector4f a = new Vector4f (1, 2, 3, 4);
2869 Vector4f e = a + b + c;
2870 Vector4f f = d - b + a - c;
2871 Vector4f g = a - d * f - c + b;
2872 Vector4f h = a * b - c + e;
2873 Vector4f i = h - g - f - e - d - c - b - a;
2874 Vector4f j = a + b + c + d + e + f + g + h + i;
2879 public static int test_3_single_block_var_is_properly_promoted () {
2880 Vector4f a = new Vector4f (4, 5, 6, 7);
2884 Vector4f b = new Vector4f (1, 2, 3, 4);
2895 static float float_val = 45f;
2897 public static int test_0_sse2_opt_and_simd_intrinsic_proper_regalloc () {
2898 Vector4f v = new Vector4f (1, 2, 3, 4);
2899 float f = float_val;
2908 public static int Main () {
2909 return TestDriver.RunTests (typeof (SimdTests));