4 public class SimdTests {
6 public static unsafe int test_0_vector2d_dup () {
7 Vector2d a = new Vector2d (3, 2);
9 Vector2d c = Vector2d.Duplicate (a);
18 public static unsafe int test_0_vector2d_cmp_eq () {
19 Vector2d a = new Vector2d (3, 2);
20 Vector2d b = new Vector2d (3, 4);
22 Vector4ui c = (Vector4ui)Vector2d.CompareEqual (a, b);
24 if (c.X != 0xFFFFFFFF)
26 if (c.Y != 0xFFFFFFFF)
35 public static unsafe int test_0_vector2d_unpack_low () {
36 Vector2d a = new Vector2d (1, 2);
37 Vector2d b = new Vector2d (4, 5);
39 Vector2d c = Vector2d.InterleaveLow (a, b);
48 public static unsafe int test_0_vector2d_unpack_high () {
49 Vector2d a = new Vector2d (1, 2);
50 Vector2d b = new Vector2d (4, 5);
52 Vector2d c = Vector2d.InterleaveHigh (a, b);
60 public static unsafe int test_0_vector2d_addsub () {
61 Vector2d a = new Vector2d (1, 2);
62 Vector2d b = new Vector2d (4, 1);
64 Vector2d c = Vector2d.AddSub (a, b);
72 public static unsafe int test_0_vector2d_hsub () {
73 Vector2d a = new Vector2d (1, 2);
74 Vector2d b = new Vector2d (4, 1);
76 Vector2d c = Vector2d.HorizontalSub (a, b);
85 public static unsafe int test_0_vector2d_hadd () {
86 Vector2d a = new Vector2d (1, 2);
87 Vector2d b = new Vector2d (4, 0);
89 Vector2d c = Vector2d.HorizontalAdd (a, b);
98 public static unsafe int test_0_vector2d_min () {
99 Vector2d a = new Vector2d (1, 2);
100 Vector2d b = new Vector2d (4, 0);
102 Vector2d c = Vector2d.Min (a, b);
111 public static unsafe int test_0_vector2d_max () {
112 Vector2d a = new Vector2d (1, 2);
113 Vector2d b = new Vector2d (4, 0);
115 Vector2d c = Vector2d.Max (a, b);
125 public static unsafe int test_0_vector2d_andnot () {
126 Vector2d a = new Vector2d (1, 2);
127 Vector2d b = new Vector2d (3, 4);
129 Vector4ui c = (Vector4ui)Vector2d.AndNot (a, b);
133 if (c.Y != 1074266112)
142 public static unsafe int test_0_vector2d_div () {
143 Vector2d a = new Vector2d (1, 2);
144 Vector2d b = new Vector2d (4, 5);
155 public static unsafe int test_0_vector2d_mul () {
156 Vector2d a = new Vector2d (1, 2);
157 Vector2d b = new Vector2d (3, 5);
167 public static unsafe int test_0_vector2d_sub () {
168 Vector2d a = new Vector2d (1, 2);
169 Vector2d b = new Vector2d (3, 5);
179 public static unsafe int test_0_vector2d_add () {
180 Vector2d a = new Vector2d (1, 2);
181 Vector2d b = new Vector2d (3, 4);
191 public static unsafe int test_0_vector2d_xor () {
192 Vector2d a = new Vector2d (1, 2);
193 Vector2d b = new Vector2d (3, 4);
195 Vector4ui c = (Vector4ui)(a ^ b);
199 if (c.Y != 2146959360)
208 public static unsafe int test_0_vector2d_or () {
209 Vector2d a = new Vector2d (1, 2);
210 Vector2d b = new Vector2d (3, 4);
212 Vector4ui c = (Vector4ui)(a | b);
216 if (c.Y != 2146959360)
220 if (c.W != 1074790400)
225 public static unsafe int test_0_vector2d_and () {
226 Vector2d a = new Vector2d (1, 2);
227 Vector2d b = new Vector2d (3, 4);
229 Vector4ui c = (Vector4ui)(a & b);
237 if (c.W != 1073741824)
242 public static unsafe int test_vector8s_pack_signed_sat () {
243 Vector8s a = new Vector8s (-200, 200, 3, 0, 5, 6, 5, 4);
244 Vector8s b = new Vector8s (9, 2, 1, 2, 3, 6, 5, 6);
246 Vector16sb c = Vector8s.PackWithSignedSaturation (a, b);
256 public static unsafe int test_vector16sb_sub_sat () {
257 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
258 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
260 Vector16sb c = Vector16sb.SubWithSaturation (a, b);
281 public static unsafe int test_vector16sb_add_sat () {
282 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
283 Vector16sb b = new Vector16sb (100, -100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
285 Vector16sb c = Vector16sb.AddWithSaturation (a, b);
306 public static unsafe int test_vector16sb_cmp_gt () {
307 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
308 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
310 Vector16sb c = Vector16sb.CompareGreaterThan (a, b);
330 public static int test_0_vector4ui_pack_with_sat () {
331 Vector4ui a = new Vector4ui (0xF0000000,0xF0000,3,4);
332 Vector4ui b = new Vector4ui (5,6,7,8);
334 Vector8us c = Vector4ui.SignedPackWithUnsignedSaturation (a, b);
355 public static int test_0_vector8us_pack_with_sat () {
356 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
357 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
358 Vector16b c = Vector8us.SignedPackWithUnsignedSaturation (a, b);
373 public static int test_0_vector8us_mul_high () {
374 Vector8us a = new Vector8us (0xFF00, 2, 3, 0, 5, 6, 5, 4);
375 Vector8us b = new Vector8us (0xFF00, 2, 1, 2, 3, 6, 5, 6);
376 Vector8us c = Vector8us.MultiplyStoreHigh (a, b);
397 public static int test_0_vector8us_cmpeq () {
398 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
399 Vector8us b = new Vector8us (9, 2, 1, 2, 3, 6, 5, 6);
400 Vector8us c = Vector8us.CompareEqual (a, b);
422 public static int test_0_vector4ui_cmpeq () {
423 Vector4ui a = new Vector4ui (6,1,6,3);
424 Vector4ui b = new Vector4ui (3,4,6,7);
425 Vector4ui c = Vector4ui.CompareEqual (a, b);
431 if (c.Z != 0xFFFFFFFF)
438 public static int test_0_vector4ui_shuffle () {
439 Vector4ui a = new Vector4ui (1,2,3,4);
440 Vector4ui c = Vector4ui.Shuffle (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
453 public static int test_0_vector4ui_extract_mask () {
454 Vector4ui a = new Vector4ui (0xFF00FF00,0x0F0FAA99,0,0);
455 int c = Vector4ui.ExtractByteMask (a);
462 public static int test_0_vector4ui_min () {
463 Vector4ui a = new Vector4ui (6,1,6,3);
464 Vector4ui b = new Vector4ui (3,4,6,7);
465 Vector4ui c = Vector4ui.Min (a, b);
478 public static int test_0_vector4ui_max () {
479 Vector4ui a = new Vector4ui (6,1,6,3);
480 Vector4ui b = new Vector4ui (3,4,6,7);
481 Vector4ui c = Vector4ui.Max (a, b);
494 public static int vector16b_cmpeq () {
495 Vector16b a = new Vector16b (1,0,9,0,0,0,0,0,0,0,0,0,0,0,0,1);
496 Vector16b b = new Vector16b (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
497 Vector16b c = Vector16b.CompareEqual (a, b);
535 public static int vector16b_sum_abs_diff () {
536 Vector16b a = new Vector16b (100,20,20,20,0,0,0,0,0,0,0,0,0,0, 0, 0);
537 Vector16sb b = new Vector16sb (0, 10,10,10,0,0,0,0,0,0,0,0,0,0,10,10);
538 Vector8us c = Vector16b.SumOfAbsoluteDifferences (a, b);
560 public static int test_0_vector16b_extract_mask () {
561 Vector16b a = new Vector16b (0xF0,0,0xF0,0,0,0,0xF0,0xAA,0x0F,0,0xFF,0,0,0,0,0);
562 int c = Vector16b.ExtractByteMask (a);
569 public static int test_0_vector16b_min () {
570 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
571 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
572 Vector16b c = Vector16b.Min (a, b);
609 public static int test_0_vector16b_max () {
610 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
611 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
612 Vector16b c = Vector16b.Max (a, b);
648 public static int test_0_vector16b_avg () {
649 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
650 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
651 Vector16b c = Vector16b.Average (a, b);
689 static unsafe Vector8us bad_method_regression_2 (Vector16b va, Vector16b vb) {
690 Vector8us res = new Vector8us ();
691 byte *a = (byte*)&va;
692 byte *b = (byte*)&vb;
695 for (int i = 0; i < 8; ++i)
696 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
697 res.V0 = (ushort)tmp;
700 for (int i = 0; i < 8; ++i)
701 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
702 res.V4 = (ushort)tmp;
706 /*This bug was caused the simplifier not taking notice of LDADDR on the remaining blocks.*/
707 public static int test_2_local_simplifier_regression_other_blocks () {
708 Vector16b a = new Vector16b (1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
709 Vector16b b = new Vector16b (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
710 Vector8us res = bad_method_regression_2 (a,b);
711 return (int)res.V0 + res.V4;
714 static unsafe Vector8us bad_method_regression (Vector16b va, Vector16b vb) {
715 Vector8us res = new Vector8us ();
716 byte *a = (byte*)&va;
717 byte *b = (byte*)&vb;
718 *((ushort*)&res) = 10;
729 /*This bug was caused the simplifier not taking notice of LDADDR on the first block.*/
730 public static int test_10_local_simplifier_regression_first_block () {
731 Vector16b a = new Vector16b ();
732 Vector16b b = new Vector16b ();
733 Vector8us res = bad_method_regression (a,b);
738 public static int test_0_vecto8us_extract_mask () {
739 Vector8us a = new Vector8us (0xF0F0, 0x700F, 0xAABB, 0x0000, 0x00F0, 0xF0F0, 0, 0);
740 int c = Vector8us.ExtractByteMask (a);
747 public static int test_0_vecto8us_shuffle_low () {
748 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
749 Vector8us c = Vector8us.ShuffleLow (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
770 public static int test_0_vecto8us_shuffle_high () {
771 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
772 Vector8us c = Vector8us.ShuffleHigh (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
794 public static int test_0_vecto8us_max () {
795 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
796 Vector8us b = new Vector8us (9, 1, 1, 2, 9, 6, 5, 1000);
797 Vector8us c = Vector8us.Max (a, b);
819 public static int test_0_vecto8us_min () {
820 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
821 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
822 Vector8us c = Vector8us.Min (a, b);
843 public static int test_0_vecto8us_avg () {
844 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
845 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
846 Vector8us c = Vector8us.Average (a, b);
867 static void store_helper (ref Vector4f x) {
869 k = new Vector4f(9,9,9,9);
873 public static int test_0_vector4f_byref_store ()
876 k = new Vector4f(1,2,3,4);
877 store_helper (ref k);
883 public static int test_0_vector4f_init_array_element ()
885 Vector4f[] v = new Vector4f[1];
886 v[0] = new Vector4f(9,9,9,9);
892 public static int test_0_vector4f_dup_high () {
893 Vector4f a = new Vector4f (1, 2, 3, 4);
894 Vector4f c = Vector4f.DuplicateHigh(a);
907 public static int test_0_vector4f_dup_low () {
908 Vector4f a = new Vector4f (1, 2, 3, 4);
909 Vector4f c = Vector4f.DuplicateLow (a);
923 public static int test_0_vector4f_interleave_high () {
924 Vector4f a = new Vector4f (1, 2, 3, 4);
925 Vector4f b = new Vector4f (5, 6, 7, 8);
926 Vector4f c = Vector4f.InterleaveHigh (a, b);
939 public static int test_0_vector4f_interleave_low () {
940 Vector4f a = new Vector4f (1, 2, 3, 4);
941 Vector4f b = new Vector4f (5, 6, 7, 8);
942 Vector4f c = Vector4f.InterleaveLow (a, b);
955 public static int test_0_vector4f_rcp () {
956 Vector4f a = new Vector4f (1, 2, 4, 8);
957 Vector4f c = Vector4f.Reciprocal (a);
959 //Test with ranges due to the terrible precision.
960 if (c.X < (1 - 0.01f) || c.X > (1 + 0.01f))
962 if (c.Y < (0.5 - 0.01f) || c.Y > (0.5 + 0.01f))
964 if (c.Z < (0.25 - 0.01f) || c.Z > (0.25 + 0.01f))
966 if (c.W < (0.125 - 0.01f) || c.W > (0.125 + 0.01f))
971 public static int test_0_vector4f_xor () {
972 Vector4f a = new Vector4f (1, 2, 3, 4);
973 Vector4f b = new Vector4f (1, 3, 3, 8);
976 if (((Vector4ui)c).X != 0)
978 if (((Vector4ui)c).Y != 0x400000)
980 if (((Vector4ui)c).Z != 0)
982 if (((Vector4ui)c).W != 0x1800000)
987 public static int test_0_vector4f_or () {
988 Vector4f a = new Vector4f (1, 2, 3, 4);
989 Vector4f b = new Vector4f (1, 3, 3, 8);
992 if (((Vector4ui)c).X != 0x3F800000)
994 if (((Vector4ui)c).Y != 0x40400000)
996 if (((Vector4ui)c).Z != 0x40400000)
998 if (((Vector4ui)c).W != 0x41800000)
1002 public static int test_0_vector4f_andn () {
1003 Vector4f a = new Vector4f (1, 2, 3, 4);
1004 Vector4f b = new Vector4f (1, 3, 3, 8);
1005 Vector4f c = Vector4f.AndNot (a ,b);
1007 if (((Vector4ui)c).X != 0)
1009 if (((Vector4ui)c).Y != 0x400000)
1011 if (((Vector4ui)c).Z != 0)
1013 if (((Vector4ui)c).W != 0x1000000)
1018 public static int test_0_vector4f_and () {
1019 Vector4f a = new Vector4f (1, 2, 3, 4);
1020 Vector4f b = new Vector4f (1, 3, 3, 8);
1023 if (((Vector4ui)c).X != 0x3F800000)
1025 if (((Vector4ui)c).Y != 0x40000000)
1027 if (((Vector4ui)c).Z != 0x40400000)
1029 if (((Vector4ui)c).W != 0x40000000)
1034 public static int test_0_vector4f_cmpord () {
1035 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1036 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1037 Vector4f c = Vector4f.CompareOrdered (a, b);
1039 if (((Vector4ui)c).X != 0)
1041 if (((Vector4ui)c).Y != 0)
1043 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1045 if (((Vector4ui)c).W != 0xFFFFFFFF)
1050 public static int test_0_vector4f_cmpnle () {
1051 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1052 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1053 Vector4f c = Vector4f.CompareNotLessEqual (a, b);
1055 if (((Vector4ui)c).X != 0xFFFFFFFF)
1057 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1059 if (((Vector4ui)c).Z != 0)
1061 if (((Vector4ui)c).W != 0)
1066 public static int test_0_vector4f_cmpnlt () {
1067 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1068 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1069 Vector4f c = Vector4f.CompareNotLessThan (a, b);
1071 if (((Vector4ui)c).X != 0xFFFFFFFF)
1073 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1075 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1077 if (((Vector4ui)c).W != 0)
1082 public static int test_0_vector4f_cmpneq () {
1083 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1084 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1085 Vector4f c = Vector4f.CompareNotEqual (a, b);
1087 if (((Vector4ui)c).X != 0xFFFFFFFF)
1089 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1091 if (((Vector4ui)c).Z != 0)
1093 if (((Vector4ui)c).W != 0xFFFFFFFF)
1098 public static int test_0_vector4f_cmpunord () {
1099 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1100 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1101 Vector4f c = Vector4f.CompareUnordered (a, b);
1103 if (((Vector4ui)c).X != 0xFFFFFFFF)
1105 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1107 if (((Vector4ui)c).Z != 0)
1109 if (((Vector4ui)c).W != 0)
1114 public static int test_0_vector4f_cmple () {
1115 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1116 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1117 Vector4f c = Vector4f.CompareLessEqual (a, b);
1119 if (((Vector4ui)c).X != 0)
1121 if (((Vector4ui)c).Y != 0)
1123 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1125 if (((Vector4ui)c).W != 0xFFFFFFFF)
1130 public static int test_0_vector4f_cmplt () {
1131 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1132 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1133 Vector4f c = Vector4f.CompareLessThan (a, b);
1135 if (((Vector4ui)c).X != 0)
1137 if (((Vector4ui)c).Y != 0)
1139 if (((Vector4ui)c).Z != 0)
1141 if (((Vector4ui)c).W != 0xFFFFFFFF)
1146 public static int test_0_vector4f_cmpeq () {
1147 Vector4f a = new Vector4f (float.NaN, 2, 3, 6);
1148 Vector4f b = new Vector4f (1, float.NaN, 3, 4);
1149 Vector4f c = Vector4f.CompareEqual (a, b);
1151 if (((Vector4ui)c).X != 0)
1153 if (((Vector4ui)c).Y != 0)
1155 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1157 if (((Vector4ui)c).W != 0)
1162 public static int test_0_vector4ui_sar () {
1163 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1165 Vector4ui c = Vector4ui.ShiftRightArithmetic (a, 2);
1167 if (c.X != 0xFC000000)
1178 public static int test_0_vector4ui_unpack_high () {
1179 Vector4ui a = new Vector4ui (1,2,3,4);
1180 Vector4ui b = new Vector4ui (5,6,7,8);
1182 Vector4ui c = Vector4ui.UnpackHigh(a, b);
1195 public static int test_0_vector4ui_unpack_low () {
1196 Vector4ui a = new Vector4ui (1,2,3,4);
1197 Vector4ui b = new Vector4ui (5,6,7,8);
1199 Vector4ui c = Vector4ui.UnpackLow (a, b);
1212 public static int test_0_vector4ui_xor () {
1213 Vector4ui a = new Vector4ui (1,2,3,4);
1214 Vector4ui b = new Vector4ui (7,5,3,1);
1216 Vector4ui c = a ^ b;
1229 public static int test_0_vector4ui_or () {
1230 Vector4ui a = new Vector4ui (1,2,3,4);
1231 Vector4ui b = new Vector4ui (7,5,3,1);
1233 Vector4ui c = a | b;
1245 public static int test_0_vector4ui_and () {
1246 Vector4ui a = new Vector4ui (1,2,3,4);
1247 Vector4ui b = new Vector4ui (7,5,3,1);
1249 Vector4ui c = a & b;
1262 public static int test_0_vector4ui_shr () {
1263 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1265 Vector4ui c = a >> 2;
1267 if (c.X != 0x3C000000)
1278 public static int test_0_vector4ui_shl () {
1279 Vector4ui a = new Vector4ui (10,20,3,40);
1281 Vector4ui c = a << 2;
1294 public static int test_0_vector4ui_mul () {
1295 Vector4ui a = new Vector4ui (0x8888,20,3,40);
1296 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1298 Vector4ui c = a * b;
1300 if (c.X != 0xffff7800)
1310 public static int test_0_vector4ui_sub () {
1311 Vector4ui a = new Vector4ui (1,20,3,40);
1312 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1314 Vector4ui c = a - b;
1316 if (c.X != 0xff0101)
1327 public static int test_0_vector4ui_add () {
1328 Vector4ui a = new Vector4ui (0xFF00FF00u,2,3,4);
1329 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1331 Vector4ui c = a + b;
1333 if (c.X != 0xfe01fe00)
1345 static int test_0_vector4ui_accessors () {
1346 Vector4ui a = new Vector4ui (1,2,3,4);
1372 static int test_0_vector8us_sub_sat () {
1373 Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
1374 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1375 Vector8us c = Vector8us.SubWithSaturation (a, b);
1396 static int test_0_vector8us_add_sat () {
1397 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1398 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1399 Vector8us c = Vector8us.AddWithSaturation (a, b);
1420 static int test_0_vector8us_unpack_low () {
1421 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1422 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
1423 Vector8us c = Vector8us.UnpackLow (a, b);
1445 static int test_0_vector8us_shift_left () {
1446 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1448 Vector8us c = a << amt;
1459 static int test_0_vector8us_shift_right_arithmetic () {
1460 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1462 Vector8us c = Vector8us.ShiftRightArithmetic (a, amt);
1473 static int test_0_vector8us_shift_variable_offset () {
1475 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1477 Vector8us c = b >> off;
1494 static int test_0_vector8us_shift_operand_is_live_after_op () {
1495 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1497 Vector8us c = b >> 2;
1513 static int test_0_vector8us_shr_constant () {
1514 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1515 Vector8us c = a >> 2;
1526 static int test_0_vector8us_mul () {
1527 Vector8us a = new Vector8us (0x0F00,4,5,6,7,8,9,10);
1528 Vector8us b = new Vector8us (0x0888,1,2,3,4,5,6,8);
1530 Vector8us c = a * b;
1540 static int test_0_vector8us_add () {
1541 Vector8us a = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1542 Vector8us b = new Vector8us (0x8888,1,2,3,4,5,6,8);
1544 Vector8us c = a + b;
1555 static int test_0_vector8us_sub () {
1556 Vector8us a = new Vector8us (3,4,5,6,7,8,9,10);
1557 Vector8us b = new Vector8us (10,1,2,3,4,5,6,8);
1559 Vector8us c = a - b;
1571 static int test_0_vector8us_accessors () {
1572 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1620 static int test_0_vector16b_unpack_high () {
1621 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1622 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1623 Vector16b c = Vector16b.UnpackHigh (a, b);
1644 static int test_0_vector16b_unpack_low () {
1645 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1646 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1647 Vector16b c = Vector16b.UnpackLow (a, b);
1668 static int test_0_vector16b_sub_sat () {
1669 Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1670 Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1671 Vector16b c = Vector16b.SubWithSaturation (a, b);
1682 static int test_0_vector16b_add_sat () {
1683 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1684 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1685 Vector16b c = Vector16b.AddWithSaturation (a, b);
1696 static int test_0_vector16b_add_ovf () {
1697 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1698 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1699 Vector16b c = a + b;
1710 static int test_0_vector16b_accessors () {
1711 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1798 public static int test_0_accessors () {
1799 Vector4f a = new Vector4f (1, 2, 3, 4);
1811 public static int test_0_packed_add_with_stack_tmp () {
1812 Vector4f a = new Vector4f (1, 2, 3, 4);
1813 Vector4f b = new Vector4f (5, 6, 7, 8);
1814 Vector4f c = new Vector4f (-1, -3, -4, -5);
1815 Vector4f d = a + b + c;
1827 public static int test_0_simple_packed_add () {
1828 Vector4f a = new Vector4f (1, 2, 3, 4);
1829 Vector4f b = new Vector4f (5, 6, 7, 8);
1843 public static int test_0_simple_packed_sub () {
1844 Vector4f a = new Vector4f (1, 2, 3, 4);
1845 Vector4f b = new Vector4f (5, 6, 7, 8);
1858 public static int test_0_simple_packed_mul () {
1859 Vector4f a = new Vector4f (1, 2, 3, 4);
1860 Vector4f b = new Vector4f (5, 6, 7, 8);
1873 public static int test_0_simple_packed_div () {
1874 Vector4f a = new Vector4f (2, 2, 3, 4);
1875 Vector4f b = new Vector4f (20, 10, 33, 12);
1888 public static int test_0_simple_packed_sqrt () {
1889 Vector4f a = new Vector4f (16, 4, 9, 25);
1890 a = Vector4f.Sqrt (a);
1902 public static int test_0_simple_packed_invsqrt () {
1903 Vector4f a = new Vector4f (16, 4, 100, 25);
1904 //this function has VERY low precision
1905 a = Vector4f.InvSqrt (a);
1906 if (a.X < (1/4f - 0.01f) || a.X > (1/4f + 0.01f))
1908 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
1910 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
1912 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
1917 public static int test_0_simple_packed_min () {
1918 Vector4f a = new Vector4f (16, -4, 9, 25);
1919 Vector4f b = new Vector4f (5, 3, 9, 0);
1920 Vector4f c = Vector4f.Min (a, b);
1932 public static int test_0_simple_packed_max () {
1933 Vector4f a = new Vector4f (16, -4, 9, 25);
1934 Vector4f b = new Vector4f (5, 3, 9, 0);
1935 Vector4f c = Vector4f.Max (a, b);
1947 public static int test_0_simple_packed_hadd () {
1948 Vector4f a = new Vector4f (5, 5, 6, 6);
1949 Vector4f b = new Vector4f (7, 7, 8, 8);
1950 Vector4f c = Vector4f.HorizontalAdd (a, b);
1962 public static int test_0_simple_packed_hsub () {
1963 Vector4f a = new Vector4f (5, 2, 6, 1);
1964 Vector4f b = new Vector4f (7, 0, 8, 3);
1965 Vector4f c = Vector4f.HorizontalSub (a, b);
1977 public static int test_0_simple_packed_addsub () {
1978 Vector4f a = new Vector4f (5, 2, 6, 1);
1979 Vector4f b = new Vector4f (7, 0, 8, 3);
1980 Vector4f c = Vector4f.AddSub (a, b);
1992 public static int test_0_simple_packed_shuffle () {
1993 Vector4f a = new Vector4f (1, 2, 3, 4);
1994 a = Vector4f.Shuffle(a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2006 public static int test_0_packed_shuffle_with_reg_pressure () {
2007 Vector4f v = new Vector4f (1, 2, 3, 4);
2008 Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
2009 if (ff) v = v + v -v ;
2011 Vector4f r0 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2012 Vector4f r1 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2013 Vector4f x = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2014 Vector4f r2 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2015 Vector4f r3 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2023 Vector4f result = r0 + r1 + r2 + r3;
2033 if (result.Y != result.Y)
2038 public static int test_24_regs_pressure_a () {
2039 Vector4f a = new Vector4f (1, 2, 3, 4);
2047 public static int test_54_regs_pressure_b () {
2048 Vector4f a = new Vector4f (1, 2, 3, 4);
2052 Vector4f e = a + b + c;
2053 Vector4f f = d - b + a - c;
2054 Vector4f g = a - d * f - c + b;
2055 Vector4f h = a * b - c + e;
2056 Vector4f i = h - g - f - e - d - c - b - a;
2057 Vector4f j = a + b + c + d + e + f + g + h + i;
2062 public static int test_3_single_block_var_is_properly_promoted () {
2063 Vector4f a = new Vector4f (4, 5, 6, 7);
2067 Vector4f b = new Vector4f (1, 2, 3, 4);
2078 static float float_val = 45f;
2080 public static int test_0_sse2_opt_and_simd_intrinsic_proper_regalloc () {
2081 Vector4f v = new Vector4f (1, 2, 3, 4);
2082 float f = float_val;
2091 public static int Main () {
2092 return TestDriver.RunTests (typeof (SimdTests));