4 public class SimdTests {
5 public static int test_0_vector16b_operator_neq () {
6 Vector16b a = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
7 Vector16b b = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
16 public static int test_0_vector16b_operator_eq () {
17 Vector16b a = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
18 Vector16b b = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
27 public static int test_0_vector8us_operator_neq () {
28 Vector8us a = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
29 Vector8us b = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
38 public static int test_0_vector8us_operator_eq () {
39 Vector8us a = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
40 Vector8us b = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
49 public static int test_0_set_vector4f_operator_neq () {
50 Vector4f a = new Vector4f(1, 2, 3, 4);
51 Vector4f b = new Vector4f(1, 2, 3, 4);
55 a = new Vector4f(1, 2, float.NaN, 4);
56 b = new Vector4f(1, 2, float.NaN, 4);
57 if (!(a != b)) //NaN is always !=
60 a = new Vector4f(1, 2, float.NaN, 4);
61 b = new Vector4f(1, 2, 10, 4);
65 a = new Vector4f(1, 2, float.PositiveInfinity, 4);
66 b = new Vector4f(1, 2, float.PositiveInfinity, 4);
70 a = new Vector4f(1, 2, 20, 4);
71 b = new Vector4f(1, 2, 30, 4);
78 public static int test_0_set_vector4f_operator_eq () {
79 Vector4f a = new Vector4f(1, 2, 3, 4);
80 Vector4f b = new Vector4f(1, 2, 3, 4);
84 a = new Vector4f(1, 2, float.NaN, 4);
85 b = new Vector4f(1, 2, float.NaN, 4);
89 a = new Vector4f(1, 2, 10, 4);
90 b = new Vector4f(1, 2, float.NaN, 4);
94 a = new Vector4f(1, 2, float.PositiveInfinity, 4);
95 b = new Vector4f(1, 2, float.PositiveInfinity, 4);
101 public static int test_1_set_vector4ui_operator_neq () {
102 Vector4ui a = new Vector4ui(1, 2, 3, 4);
103 Vector4ui b = new Vector4ui(1, 2, 3, 4);
109 public static int test_0_set_vector4ui_operator_neq () {
110 Vector4ui a = new Vector4ui(1, 2, 3, 4);
111 Vector4ui b = new Vector4ui(111, 2, 3, 4);
117 public static int test_0_set_vector4ui_operator_eq () {
118 Vector4ui a = new Vector4ui(1, 2, 3, 4);
119 Vector4ui b = new Vector4ui(1, 2, 3, 4);
125 public static int test_1_set_vector4ui_operator_eq () {
126 Vector4ui a = new Vector4ui(1, 2, 3, 4);
127 Vector4ui b = new Vector4ui(111, 2, 3, 4);
133 public static int test_0_set_vector_small_array () {
134 uint[] array = new uint[3];
137 array.SetVector (new Vector4ui (), 0);
139 } catch (IndexOutOfRangeException) {
144 public static int test_0_set_vector_negative_index () {
145 uint[] array = new uint[4];
148 array.SetVector (new Vector4ui (), -1);
150 } catch (IndexOutOfRangeException) {
155 public static int test_0_set_vector_bounds_error () {
156 uint[] array = new uint[4];
159 array.SetVector (new Vector4ui (), 1);
161 } catch (IndexOutOfRangeException) {
166 public static int test_0_set_vector () {
167 uint[] array = new uint[10];
168 Vector4ui a = new Vector4ui (11, 22, 33, 44);
170 array.SetVector (a, 1);
183 public static int test_0_get_vector_small_array () {
184 uint[] array = new uint[3];
187 Vector4ui res = array.GetVector (0);
189 } catch (IndexOutOfRangeException) {
194 public static int test_0_get_vector_negative_index () {
195 uint[] array = new uint[4];
198 Vector4ui res = array.GetVector (-1);
200 } catch (IndexOutOfRangeException) {
205 public static int test_0_get_vector_bounds_error () {
206 uint[] array = new uint[4];
209 Vector4ui res = array.GetVector (1);
211 } catch (IndexOutOfRangeException) {
216 public static int test_0_get_vector () {
217 uint[] array = new uint[] { 11, 22, 33, 44, 55, 66, 77, 88, 99, 111 };
219 Vector4ui res = array.GetVector (1);
233 public static int test_0_accessor_vecto2l () {
234 Vector2l a = new Vector2l (3, 2);
241 a.X = 500000000000055l;
244 if (a.X != 500000000000055l)
246 if (a.Y != -12345678900l)
251 public static int test_0_accessor_vecto2d () {
252 Vector2d a = new Vector2d (3, 2);
262 if (a.X != 5000000000000)
269 public static int test_0_accessor_vecto4f () {
270 Vector4f a = new Vector4f (1,2,3,4);
297 public static int test_0_accessor_vecto4i () {
298 Vector4i a = new Vector4i (0x70000000, -1, 3, 4);
300 if (a.X != 0x70000000)
320 if (a.W != -44444444)
325 public static int test_0_accessor_vecto4ui () {
326 Vector4ui a = new Vector4ui (0xF0000000, 0xF0000, 3, 4);
328 if (a.X != 0xF0000000)
353 static float use_getter_with_byref (ref Vector4f a) {
357 public static int test_0_accessor_and_byref_var () {
358 Vector4f a = new Vector4f (1, 2, 3, 4);
359 if (use_getter_with_byref (ref a) != 4)
364 public static unsafe int test_0_vector2ul_slr () {
365 Vector2ul a = new Vector2ul (1, 6);
367 Vector2ul c = a >> 1;
375 public static unsafe int test_0_vector2l_cmp_gt () {
376 Vector2l a = new Vector2l (10, 5);
377 Vector2l b = new Vector2l (-1, 5);
379 Vector2l c = Vector2l.CompareGreaterThan (a, b);
388 public static unsafe int test_0_vector2l_cmp_eq () {
389 Vector2l a = new Vector2l (0xFF, 5);
390 Vector2l b = new Vector2l (0xFF000000FFL, 5);
392 Vector2l c = Vector2l.CompareEqual (a, b);
401 public static unsafe int test_0_vector2l_srl () {
402 Vector2l a = new Vector2l (1, 6);
404 Vector2l c = Vector2l.LogicalRightShift (a, 1);
413 public static unsafe int test_0_vector2l_unpack_high () {
414 Vector2l a = new Vector2l (1, 6);
415 Vector2l b = new Vector2l (3, 4);
417 Vector2l c = Vector2l.UnpackHigh (a, b);
426 public static unsafe int test_0_vector2l_unpack_low () {
427 Vector2l a = new Vector2l (1, 6);
428 Vector2l b = new Vector2l (3, 4);
430 Vector2l c = Vector2l.UnpackLow (a, b);
439 public static unsafe int test_0_vector2l_xor () {
440 Vector2l a = new Vector2l (1, 6);
441 Vector2l b = new Vector2l (3, 4);
452 public static unsafe int test_0_vector2l_or () {
453 Vector2l a = new Vector2l (1, 6);
454 Vector2l b = new Vector2l (3, 4);
465 public static unsafe int test_0_vector2l_and () {
466 Vector2l a = new Vector2l (1, 6);
467 Vector2l b = new Vector2l (3, 4);
478 public static unsafe int test_0_vector2l_shl() {
479 Vector2l a = new Vector2l (1, 6);
489 public static unsafe int test_0_vector2l_sub() {
490 Vector2l a = new Vector2l (1, 6);
491 Vector2l b = new Vector2l (3, 4);
502 public static unsafe int test_0_vector2l_add () {
503 Vector2l a = new Vector2l (1, 2);
504 Vector2l b = new Vector2l (3, 4);
515 public static unsafe int test_0_vector2d_dup () {
516 Vector2d a = new Vector2d (3, 2);
518 Vector2d c = Vector2d.Duplicate (a);
527 public static unsafe int test_0_vector2d_cmp_eq () {
528 Vector2d a = new Vector2d (3, 2);
529 Vector2d b = new Vector2d (3, 4);
531 Vector4ui c = (Vector4ui)Vector2d.CompareEqual (a, b);
533 if (c.X != 0xFFFFFFFF)
535 if (c.Y != 0xFFFFFFFF)
544 public static unsafe int test_0_vector2d_unpack_low () {
545 Vector2d a = new Vector2d (1, 2);
546 Vector2d b = new Vector2d (4, 5);
548 Vector2d c = Vector2d.InterleaveLow (a, b);
557 public static unsafe int test_0_vector2d_unpack_high () {
558 Vector2d a = new Vector2d (1, 2);
559 Vector2d b = new Vector2d (4, 5);
561 Vector2d c = Vector2d.InterleaveHigh (a, b);
569 public static unsafe int test_0_vector2d_addsub () {
570 Vector2d a = new Vector2d (1, 2);
571 Vector2d b = new Vector2d (4, 1);
573 Vector2d c = Vector2d.AddSub (a, b);
581 public static unsafe int test_0_vector2d_hsub () {
582 Vector2d a = new Vector2d (1, 2);
583 Vector2d b = new Vector2d (4, 1);
585 Vector2d c = Vector2d.HorizontalSub (a, b);
594 public static unsafe int test_0_vector2d_hadd () {
595 Vector2d a = new Vector2d (1, 2);
596 Vector2d b = new Vector2d (4, 0);
598 Vector2d c = Vector2d.HorizontalAdd (a, b);
607 public static unsafe int test_0_vector2d_min () {
608 Vector2d a = new Vector2d (1, 2);
609 Vector2d b = new Vector2d (4, 0);
611 Vector2d c = Vector2d.Min (a, b);
620 public static unsafe int test_0_vector2d_max () {
621 Vector2d a = new Vector2d (1, 2);
622 Vector2d b = new Vector2d (4, 0);
624 Vector2d c = Vector2d.Max (a, b);
634 public static unsafe int test_0_vector2d_andnot () {
635 Vector2d a = new Vector2d (1, 2);
636 Vector2d b = new Vector2d (3, 4);
638 Vector4ui c = (Vector4ui)Vector2d.AndNot (a, b);
639 Vector4ui ta = (Vector4ui)a;
640 Vector4ui tb = (Vector4ui)b;
642 if (c.X != (~ta.X & tb.X))
644 if (c.Y != (~ta.Y & tb.Y))
646 if (c.Z != (~ta.Z & tb.Z))
648 if (c.W != (~ta.W & tb.W))
653 public static unsafe int test_0_vector2d_div () {
654 Vector2d a = new Vector2d (1, 2);
655 Vector2d b = new Vector2d (4, 5);
666 public static unsafe int test_0_vector2d_mul () {
667 Vector2d a = new Vector2d (1, 2);
668 Vector2d b = new Vector2d (3, 5);
678 public static unsafe int test_0_vector2d_sub () {
679 Vector2d a = new Vector2d (1, 2);
680 Vector2d b = new Vector2d (3, 5);
690 public static unsafe int test_0_vector2d_add () {
691 Vector2d a = new Vector2d (1, 2);
692 Vector2d b = new Vector2d (3, 4);
702 public static unsafe int test_0_vector2d_xor () {
703 Vector2d a = new Vector2d (1, 2);
704 Vector2d b = new Vector2d (3, 4);
706 Vector4ui c = (Vector4ui)(a ^ b);
707 Vector4ui ta = (Vector4ui)a;
708 Vector4ui tb = (Vector4ui)b;
710 if (c.X != (ta.X ^ tb.X))
712 if (c.Y != (ta.Y ^ tb.Y))
714 if (c.Z != (ta.Z ^ tb.Z))
716 if (c.W != (ta.W ^ tb.W))
721 public static unsafe int test_0_vector2d_or () {
722 Vector2d a = new Vector2d (1, 2);
723 Vector2d b = new Vector2d (3, 4);
725 Vector4ui c = (Vector4ui)(a | b);
726 Vector4ui ta = (Vector4ui)a;
727 Vector4ui tb = (Vector4ui)b;
729 if (c.X != (ta.X | tb.X))
731 if (c.Y != (ta.Y | tb.Y))
733 if (c.Z != (ta.Z | tb.Z))
735 if (c.W != (ta.W | tb.W))
740 public static unsafe int test_0_vector2d_and () {
741 Vector2d a = new Vector2d (1, 2);
742 Vector2d b = new Vector2d (3, 4);
744 Vector4ui c = (Vector4ui)(a & 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_vector8s_pack_signed_sat () {
760 Vector8s a = new Vector8s (-200, 200, 3, 0, 5, 6, 5, 4);
761 Vector8s b = new Vector8s (9, 2, 1, 2, 3, 6, 5, 6);
763 Vector16sb c = Vector8s.PackWithSignedSaturation (a, b);
773 public static unsafe int test_vector16sb_sub_sat () {
774 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
775 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
777 Vector16sb c = Vector16sb.SubtractWithSaturation (a, b);
798 public static unsafe int test_vector16sb_add_sat () {
799 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
800 Vector16sb b = new Vector16sb (100, -100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
802 Vector16sb c = Vector16sb.AddWithSaturation (a, b);
823 public static unsafe int test_vector16sb_cmp_gt () {
824 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
825 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
827 Vector16sb c = Vector16sb.CompareGreaterThan (a, b);
847 public static int test_0_vector4ui_pack_with_sat () {
848 Vector4ui a = new Vector4ui (0xF0000000,0xF0000,3,4);
849 Vector4ui b = new Vector4ui (5,6,7,8);
851 Vector8us c = Vector4ui.SignedPackWithUnsignedSaturation (a, b);
872 public static int test_0_vector8us_pack_with_sat () {
873 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
874 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
875 Vector16b c = Vector8us.SignedPackWithUnsignedSaturation (a, b);
890 public static int test_0_vector8us_mul_high () {
891 Vector8us a = new Vector8us (0xFF00, 2, 3, 0, 5, 6, 5, 4);
892 Vector8us b = new Vector8us (0xFF00, 2, 1, 2, 3, 6, 5, 6);
893 Vector8us c = Vector8us.MultiplyStoreHigh (a, b);
914 public static int test_0_vector8us_cmpeq () {
915 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
916 Vector8us b = new Vector8us (9, 2, 1, 2, 3, 6, 5, 6);
917 Vector8us c = Vector8us.CompareEqual (a, b);
939 public static int test_0_vector4ui_cmpeq () {
940 Vector4ui a = new Vector4ui (6,1,6,3);
941 Vector4ui b = new Vector4ui (3,4,6,7);
942 Vector4ui c = Vector4ui.CompareEqual (a, b);
948 if (c.Z != 0xFFFFFFFF)
955 public static int test_0_vector4ui_shuffle () {
956 Vector4ui a = new Vector4ui (1,2,3,4);
957 Vector4ui c = Vector4ui.Shuffle (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
970 public static int test_0_vector4ui_min () {
971 Vector4ui a = new Vector4ui (6,1,6,3);
972 Vector4ui b = new Vector4ui (3,4,6,7);
973 Vector4ui c = Vector4ui.Min (a, b);
986 public static int test_0_vector4ui_max () {
987 Vector4ui a = new Vector4ui (6,1,6,3);
988 Vector4ui b = new Vector4ui (3,4,6,7);
989 Vector4ui c = Vector4ui.Max (a, b);
1002 public static int vector16b_cmpeq () {
1003 Vector16b a = new Vector16b (1,0,9,0,0,0,0,0,0,0,0,0,0,0,0,1);
1004 Vector16b b = new Vector16b (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
1005 Vector16b c = Vector16b.CompareEqual (a, b);
1043 public static int vector16b_sum_abs_diff () {
1044 Vector16b a = new Vector16b (100,20,20,20,0,0,0,0,0,0,0,0,0,0, 0, 0);
1045 Vector16sb b = new Vector16sb (0, 10,10,10,0,0,0,0,0,0,0,0,0,0,10,10);
1046 Vector8us c = Vector16b.SumOfAbsoluteDifferences (a, b);
1068 public static int test_0_vector16b_extract_mask () {
1069 Vector16b a = new Vector16b (0xF0,0,0xF0,0,0,0,0xF0,0xAA,0x0F,0,0xFF,0,0,0,0,0);
1070 int c = Vector16b.ExtractByteMask (a);
1077 public static int test_0_vector16b_min () {
1078 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
1079 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1080 Vector16b c = Vector16b.Min (a, b);
1117 public static int test_0_vector16b_max () {
1118 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
1119 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1120 Vector16b c = Vector16b.Max (a, b);
1156 public static int test_0_vector16b_avg () {
1157 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1158 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1159 Vector16b c = Vector16b.Average (a, b);
1197 static unsafe Vector8us bad_method_regression_2 (Vector16b va, Vector16b vb) {
1198 Vector8us res = new Vector8us ();
1199 byte *a = (byte*)&va;
1200 byte *b = (byte*)&vb;
1203 for (int i = 0; i < 8; ++i)
1204 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
1205 res.V0 = (ushort)tmp;
1208 for (int i = 0; i < 8; ++i)
1209 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
1210 res.V4 = (ushort)tmp;
1214 /*This bug was caused the simplifier not taking notice of LDADDR on the remaining blocks.*/
1215 public static int test_2_local_simplifier_regression_other_blocks () {
1216 Vector16b a = new Vector16b (1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
1217 Vector16b b = new Vector16b (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
1218 Vector8us res = bad_method_regression_2 (a,b);
1219 return (int)res.V0 + res.V4;
1222 static unsafe Vector8us bad_method_regression (Vector16b va, Vector16b vb) {
1223 Vector8us res = new Vector8us ();
1224 byte *a = (byte*)&va;
1225 byte *b = (byte*)&vb;
1226 *((ushort*)&res) = 10;
1237 /*This bug was caused the simplifier not taking notice of LDADDR on the first block.*/
1238 public static int test_10_local_simplifier_regression_first_block () {
1239 Vector16b a = new Vector16b ();
1240 Vector16b b = new Vector16b ();
1241 Vector8us res = bad_method_regression (a,b);
1245 public static int test_0_vecto8us_shuffle_low () {
1246 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1247 Vector8us c = Vector8us.ShuffleLow (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1268 public static int test_0_vecto8us_shuffle_high () {
1269 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1270 Vector8us c = Vector8us.ShuffleHigh (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1292 public static int test_0_vecto8us_max () {
1293 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1294 Vector8us b = new Vector8us (9, 1, 1, 2, 9, 6, 5, 1000);
1295 Vector8us c = Vector8us.Max (a, b);
1317 public static int test_0_vecto8us_min () {
1318 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
1319 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1320 Vector8us c = Vector8us.Min (a, b);
1341 public static int test_0_vecto8us_avg () {
1342 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1343 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1344 Vector8us c = Vector8us.Average (a, b);
1365 static void store_helper (ref Vector4f x) {
1367 k = new Vector4f(9,9,9,9);
1371 public static int test_0_vector4f_byref_store ()
1374 k = new Vector4f(1,2,3,4);
1375 store_helper (ref k);
1381 public static int test_0_vector4f_init_array_element ()
1383 Vector4f[] v = new Vector4f[1];
1384 v[0] = new Vector4f(9,9,9,9);
1390 public static int test_0_vector4f_dup_high () {
1391 Vector4f a = new Vector4f (1, 2, 3, 4);
1392 Vector4f c = Vector4f.DuplicateHigh(a);
1405 public static int test_0_vector4f_dup_low () {
1406 Vector4f a = new Vector4f (1, 2, 3, 4);
1407 Vector4f c = Vector4f.DuplicateLow (a);
1421 public static int test_0_vector4f_interleave_high () {
1422 Vector4f a = new Vector4f (1, 2, 3, 4);
1423 Vector4f b = new Vector4f (5, 6, 7, 8);
1424 Vector4f c = Vector4f.InterleaveHigh (a, b);
1437 public static int test_0_vector4f_interleave_low () {
1438 Vector4f a = new Vector4f (1, 2, 3, 4);
1439 Vector4f b = new Vector4f (5, 6, 7, 8);
1440 Vector4f c = Vector4f.InterleaveLow (a, b);
1453 public static int test_0_vector4f_rcp () {
1454 Vector4f a = new Vector4f (1, 2, 4, 8);
1455 Vector4f c = Vector4f.Reciprocal (a);
1457 //Test with ranges due to the terrible precision.
1458 if (c.X < (1 - 0.01f) || c.X > (1 + 0.01f))
1460 if (c.Y < (0.5 - 0.01f) || c.Y > (0.5 + 0.01f))
1462 if (c.Z < (0.25 - 0.01f) || c.Z > (0.25 + 0.01f))
1464 if (c.W < (0.125 - 0.01f) || c.W > (0.125 + 0.01f))
1469 public static int test_0_vector4f_xor () {
1470 Vector4f a = new Vector4f (1, 2, 3, 4);
1471 Vector4f b = new Vector4f (1, 3, 3, 8);
1474 if (((Vector4ui)c).X != 0)
1476 if (((Vector4ui)c).Y != 0x400000)
1478 if (((Vector4ui)c).Z != 0)
1480 if (((Vector4ui)c).W != 0x1800000)
1485 public static int test_0_vector4f_or () {
1486 Vector4f a = new Vector4f (1, 2, 3, 4);
1487 Vector4f b = new Vector4f (1, 3, 3, 8);
1490 if (((Vector4ui)c).X != 0x3F800000)
1492 if (((Vector4ui)c).Y != 0x40400000)
1494 if (((Vector4ui)c).Z != 0x40400000)
1496 if (((Vector4ui)c).W != 0x41800000)
1500 public static int test_0_vector4f_andn () {
1501 Vector4f a = new Vector4f (1, 2, 3, 4);
1502 Vector4f b = new Vector4f (1, 3, 3, 8);
1503 Vector4f c = Vector4f.AndNot (a ,b);
1505 if (((Vector4ui)c).X != 0)
1507 if (((Vector4ui)c).Y != 0x400000)
1509 if (((Vector4ui)c).Z != 0)
1511 if (((Vector4ui)c).W != 0x1000000)
1516 public static int test_0_vector4f_and () {
1517 Vector4f a = new Vector4f (1, 2, 3, 4);
1518 Vector4f b = new Vector4f (1, 3, 3, 8);
1521 if (((Vector4ui)c).X != 0x3F800000)
1523 if (((Vector4ui)c).Y != 0x40000000)
1525 if (((Vector4ui)c).Z != 0x40400000)
1527 if (((Vector4ui)c).W != 0x40000000)
1532 public static int test_0_vector4f_cmpord () {
1533 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1534 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1535 Vector4f c = Vector4f.CompareOrdered (a, b);
1537 if (((Vector4ui)c).X != 0)
1539 if (((Vector4ui)c).Y != 0)
1541 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1543 if (((Vector4ui)c).W != 0xFFFFFFFF)
1548 public static int test_0_vector4f_cmpnle () {
1549 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1550 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1551 Vector4f c = Vector4f.CompareNotLessEqual (a, b);
1553 if (((Vector4ui)c).X != 0xFFFFFFFF)
1555 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1557 if (((Vector4ui)c).Z != 0)
1559 if (((Vector4ui)c).W != 0)
1564 public static int test_0_vector4f_cmpnlt () {
1565 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1566 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1567 Vector4f c = Vector4f.CompareNotLessThan (a, b);
1569 if (((Vector4ui)c).X != 0xFFFFFFFF)
1571 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1573 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1575 if (((Vector4ui)c).W != 0)
1580 public static int test_0_vector4f_cmpneq () {
1581 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1582 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1583 Vector4f c = Vector4f.CompareNotEqual (a, b);
1585 if (((Vector4ui)c).X != 0xFFFFFFFF)
1587 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1589 if (((Vector4ui)c).Z != 0)
1591 if (((Vector4ui)c).W != 0xFFFFFFFF)
1596 public static int test_0_vector4f_cmpunord () {
1597 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1598 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1599 Vector4f c = Vector4f.CompareUnordered (a, b);
1601 if (((Vector4ui)c).X != 0xFFFFFFFF)
1603 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1605 if (((Vector4ui)c).Z != 0)
1607 if (((Vector4ui)c).W != 0)
1612 public static int test_0_vector4f_cmple () {
1613 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1614 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1615 Vector4f c = Vector4f.CompareLessEqual (a, b);
1617 if (((Vector4ui)c).X != 0)
1619 if (((Vector4ui)c).Y != 0)
1621 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1623 if (((Vector4ui)c).W != 0xFFFFFFFF)
1628 public static int test_0_vector4f_cmplt () {
1629 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1630 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1631 Vector4f c = Vector4f.CompareLessThan (a, b);
1633 if (((Vector4ui)c).X != 0)
1635 if (((Vector4ui)c).Y != 0)
1637 if (((Vector4ui)c).Z != 0)
1639 if (((Vector4ui)c).W != 0xFFFFFFFF)
1644 public static int test_0_vector4f_cmpeq () {
1645 Vector4f a = new Vector4f (float.NaN, 2, 3, 6);
1646 Vector4f b = new Vector4f (1, float.NaN, 3, 4);
1647 Vector4f c = Vector4f.CompareEqual (a, b);
1649 if (((Vector4ui)c).X != 0)
1651 if (((Vector4ui)c).Y != 0)
1653 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1655 if (((Vector4ui)c).W != 0)
1660 public static int test_0_vector4ui_sar () {
1661 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1663 Vector4ui c = Vector4ui.ArithmeticRightShift (a, 2);
1665 if (c.X != 0xFC000000)
1676 public static int test_0_vector4ui_unpack_high () {
1677 Vector4ui a = new Vector4ui (1,2,3,4);
1678 Vector4ui b = new Vector4ui (5,6,7,8);
1680 Vector4ui c = Vector4ui.UnpackHigh(a, b);
1693 public static int test_0_vector4ui_unpack_low () {
1694 Vector4ui a = new Vector4ui (1,2,3,4);
1695 Vector4ui b = new Vector4ui (5,6,7,8);
1697 Vector4ui c = Vector4ui.UnpackLow (a, b);
1710 public static int test_0_vector4ui_xor () {
1711 Vector4ui a = new Vector4ui (1,2,3,4);
1712 Vector4ui b = new Vector4ui (7,5,3,1);
1714 Vector4ui c = a ^ b;
1727 public static int test_0_vector4ui_or () {
1728 Vector4ui a = new Vector4ui (1,2,3,4);
1729 Vector4ui b = new Vector4ui (7,5,3,1);
1731 Vector4ui c = a | b;
1743 public static int test_0_vector4ui_and () {
1744 Vector4ui a = new Vector4ui (1,2,3,4);
1745 Vector4ui b = new Vector4ui (7,5,3,1);
1747 Vector4ui c = a & b;
1760 public static int test_0_vector4ui_shr () {
1761 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1763 Vector4ui c = a >> 2;
1765 if (c.X != 0x3C000000)
1776 public static int test_0_vector4ui_shl () {
1777 Vector4ui a = new Vector4ui (10,20,3,40);
1779 Vector4ui c = a << 2;
1792 public static int test_0_vector4ui_mul () {
1793 Vector4ui a = new Vector4ui (0x8888,20,3,40);
1794 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1796 Vector4ui c = a * b;
1798 if (c.X != 0xffff7800)
1808 public static int test_0_vector4ui_sub () {
1809 Vector4ui a = new Vector4ui (1,20,3,40);
1810 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1812 Vector4ui c = a - b;
1814 if (c.X != 0xff0101)
1825 public static int test_0_vector4ui_add () {
1826 Vector4ui a = new Vector4ui (0xFF00FF00u,2,3,4);
1827 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1829 Vector4ui c = a + b;
1831 if (c.X != 0xfe01fe00)
1843 static int test_0_vector4ui_accessors () {
1844 Vector4ui a = new Vector4ui (1,2,3,4);
1870 static int test_0_vector8us_sub_sat () {
1871 Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
1872 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1873 Vector8us c = Vector8us.SubtractWithSaturation (a, b);
1894 static int test_0_vector8us_add_sat () {
1895 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1896 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1897 Vector8us c = Vector8us.AddWithSaturation (a, b);
1918 static int test_0_vector8us_unpack_low () {
1919 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1920 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
1921 Vector8us c = Vector8us.UnpackLow (a, b);
1943 static int test_0_vector8us_shift_left () {
1944 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1946 Vector8us c = a << amt;
1957 static int test_0_vector8us_shift_right_arithmetic () {
1958 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1960 Vector8us c = Vector8us.ArithmeticRightShift (a, amt);
1971 static int test_0_vector8us_shift_variable_offset () {
1973 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1975 Vector8us c = b >> off;
1992 static int test_0_vector8us_shift_operand_is_live_after_op () {
1993 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1995 Vector8us c = b >> 2;
2011 static int test_0_vector8us_shr_constant () {
2012 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
2013 Vector8us c = a >> 2;
2024 static int test_0_vector8us_mul () {
2025 Vector8us a = new Vector8us (0x0F00,4,5,6,7,8,9,10);
2026 Vector8us b = new Vector8us (0x0888,1,2,3,4,5,6,8);
2028 Vector8us c = a * b;
2038 static int test_0_vector8us_add () {
2039 Vector8us a = new Vector8us (0xFF00,4,5,6,7,8,9,10);
2040 Vector8us b = new Vector8us (0x8888,1,2,3,4,5,6,8);
2042 Vector8us c = a + b;
2053 static int test_0_vector8us_sub () {
2054 Vector8us a = new Vector8us (3,4,5,6,7,8,9,10);
2055 Vector8us b = new Vector8us (10,1,2,3,4,5,6,8);
2057 Vector8us c = a - b;
2069 static int test_0_vector8us_accessors () {
2070 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
2118 static int test_0_vector16b_unpack_high () {
2119 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2120 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2121 Vector16b c = Vector16b.UnpackHigh (a, b);
2142 static int test_0_vector16b_unpack_low () {
2143 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2144 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2145 Vector16b c = Vector16b.UnpackLow (a, b);
2166 static int test_0_vector16b_sub_sat () {
2167 Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2168 Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2169 Vector16b c = Vector16b.SubtractWithSaturation (a, b);
2180 static int test_0_vector16b_add_sat () {
2181 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2182 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2183 Vector16b c = Vector16b.AddWithSaturation (a, b);
2194 static int test_0_vector16b_add_ovf () {
2195 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2196 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2197 Vector16b c = a + b;
2208 static int test_0_vector16b_accessors () {
2209 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2296 public static int test_0_accessors () {
2297 Vector4f a = new Vector4f (1, 2, 3, 4);
2309 public static int test_0_packed_add_with_stack_tmp () {
2310 Vector4f a = new Vector4f (1, 2, 3, 4);
2311 Vector4f b = new Vector4f (5, 6, 7, 8);
2312 Vector4f c = new Vector4f (-1, -3, -4, -5);
2313 Vector4f d = a + b + c;
2325 public static int test_0_simple_packed_add () {
2326 Vector4f a = new Vector4f (1, 2, 3, 4);
2327 Vector4f b = new Vector4f (5, 6, 7, 8);
2341 public static int test_0_simple_packed_sub () {
2342 Vector4f a = new Vector4f (1, 2, 3, 4);
2343 Vector4f b = new Vector4f (5, 6, 7, 8);
2356 public static int test_0_simple_packed_mul () {
2357 Vector4f a = new Vector4f (1, 2, 3, 4);
2358 Vector4f b = new Vector4f (5, 6, 7, 8);
2371 public static int test_0_simple_packed_div () {
2372 Vector4f a = new Vector4f (2, 2, 3, 4);
2373 Vector4f b = new Vector4f (20, 10, 33, 12);
2386 public static int test_0_simple_packed_sqrt () {
2387 Vector4f a = new Vector4f (16, 4, 9, 25);
2388 a = Vector4f.Sqrt (a);
2400 public static int test_0_simple_packed_invsqrt () {
2401 Vector4f a = new Vector4f (16, 4, 100, 25);
2402 //this function has VERY low precision
2403 a = Vector4f.InvSqrt (a);
2404 if (a.X < (1/4f - 0.01f) || a.X > (1/4f + 0.01f))
2406 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
2408 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
2410 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
2415 public static int test_0_simple_packed_min () {
2416 Vector4f a = new Vector4f (16, -4, 9, 25);
2417 Vector4f b = new Vector4f (5, 3, 9, 0);
2418 Vector4f c = Vector4f.Min (a, b);
2430 public static int test_0_simple_packed_max () {
2431 Vector4f a = new Vector4f (16, -4, 9, 25);
2432 Vector4f b = new Vector4f (5, 3, 9, 0);
2433 Vector4f c = Vector4f.Max (a, b);
2445 public static int test_0_simple_packed_hadd () {
2446 Vector4f a = new Vector4f (5, 5, 6, 6);
2447 Vector4f b = new Vector4f (7, 7, 8, 8);
2448 Vector4f c = Vector4f.HorizontalAdd (a, b);
2460 public static int test_0_simple_packed_hsub () {
2461 Vector4f a = new Vector4f (5, 2, 6, 1);
2462 Vector4f b = new Vector4f (7, 0, 8, 3);
2463 Vector4f c = Vector4f.HorizontalSub (a, b);
2475 public static int test_0_simple_packed_addsub () {
2476 Vector4f a = new Vector4f (5, 2, 6, 1);
2477 Vector4f b = new Vector4f (7, 0, 8, 3);
2478 Vector4f c = Vector4f.AddSub (a, b);
2490 public static int test_0_simple_packed_shuffle () {
2491 Vector4f a = new Vector4f (1, 2, 3, 4);
2492 a = Vector4f.Shuffle(a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2504 public static int test_0_packed_shuffle_with_reg_pressure () {
2505 Vector4f v = new Vector4f (1, 2, 3, 4);
2506 Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
2507 if (ff) v = v + v -v ;
2509 Vector4f r0 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2510 Vector4f r1 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2511 Vector4f x = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2512 Vector4f r2 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2513 Vector4f r3 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2521 Vector4f result = r0 + r1 + r2 + r3;
2531 if (result.Y != result.Y)
2536 public static int test_24_regs_pressure_a () {
2537 Vector4f a = new Vector4f (1, 2, 3, 4);
2545 public static int test_54_regs_pressure_b () {
2546 Vector4f a = new Vector4f (1, 2, 3, 4);
2550 Vector4f e = a + b + c;
2551 Vector4f f = d - b + a - c;
2552 Vector4f g = a - d * f - c + b;
2553 Vector4f h = a * b - c + e;
2554 Vector4f i = h - g - f - e - d - c - b - a;
2555 Vector4f j = a + b + c + d + e + f + g + h + i;
2560 public static int test_3_single_block_var_is_properly_promoted () {
2561 Vector4f a = new Vector4f (4, 5, 6, 7);
2565 Vector4f b = new Vector4f (1, 2, 3, 4);
2576 static float float_val = 45f;
2578 public static int test_0_sse2_opt_and_simd_intrinsic_proper_regalloc () {
2579 Vector4f v = new Vector4f (1, 2, 3, 4);
2580 float f = float_val;
2589 public static int Main () {
2590 return TestDriver.RunTests (typeof (SimdTests));