4 public class SimdTests {
5 static float use_getter_with_byref (ref Vector4f a) {
9 public static int test_0_accessor_and_byref_var () {
10 Vector4f a = new Vector4f (1, 2, 3, 4);
11 if (use_getter_with_byref (ref a) != 4)
16 public static unsafe int test_0_vector2ul_slr () {
17 Vector2ul a = new Vector2ul (1, 6);
27 public static unsafe int test_0_vector2l_cmp_gt () {
28 Vector2l a = new Vector2l (10, 5);
29 Vector2l b = new Vector2l (-1, 5);
31 Vector2l c = Vector2l.CompareGreaterThan (a, b);
40 public static unsafe int test_0_vector2l_cmp_eq () {
41 Vector2l a = new Vector2l (0xFF, 5);
42 Vector2l b = new Vector2l (0xFF000000FFL, 5);
44 Vector2l c = Vector2l.CompareEqual (a, b);
53 public static unsafe int test_0_vector2l_srl () {
54 Vector2l a = new Vector2l (1, 6);
56 Vector2l c = Vector2l.ShiftRightLogic (a, 1);
65 public static unsafe int test_0_vector2l_unpack_high () {
66 Vector2l a = new Vector2l (1, 6);
67 Vector2l b = new Vector2l (3, 4);
69 Vector2l c = Vector2l.UnpackHigh (a, b);
78 public static unsafe int test_0_vector2l_unpack_low () {
79 Vector2l a = new Vector2l (1, 6);
80 Vector2l b = new Vector2l (3, 4);
82 Vector2l c = Vector2l.UnpackLow (a, b);
91 public static unsafe int test_0_vector2l_xor () {
92 Vector2l a = new Vector2l (1, 6);
93 Vector2l b = new Vector2l (3, 4);
104 public static unsafe int test_0_vector2l_or () {
105 Vector2l a = new Vector2l (1, 6);
106 Vector2l b = new Vector2l (3, 4);
117 public static unsafe int test_0_vector2l_and () {
118 Vector2l a = new Vector2l (1, 6);
119 Vector2l b = new Vector2l (3, 4);
130 public static unsafe int test_0_vector2l_shl() {
131 Vector2l a = new Vector2l (1, 6);
141 public static unsafe int test_0_vector2l_sub() {
142 Vector2l a = new Vector2l (1, 6);
143 Vector2l b = new Vector2l (3, 4);
154 public static unsafe int test_0_vector2l_add () {
155 Vector2l a = new Vector2l (1, 2);
156 Vector2l b = new Vector2l (3, 4);
167 public static unsafe int test_0_vector2d_dup () {
168 Vector2d a = new Vector2d (3, 2);
170 Vector2d c = Vector2d.Duplicate (a);
179 public static unsafe int test_0_vector2d_cmp_eq () {
180 Vector2d a = new Vector2d (3, 2);
181 Vector2d b = new Vector2d (3, 4);
183 Vector4ui c = (Vector4ui)Vector2d.CompareEqual (a, b);
185 if (c.X != 0xFFFFFFFF)
187 if (c.Y != 0xFFFFFFFF)
196 public static unsafe int test_0_vector2d_unpack_low () {
197 Vector2d a = new Vector2d (1, 2);
198 Vector2d b = new Vector2d (4, 5);
200 Vector2d c = Vector2d.InterleaveLow (a, b);
209 public static unsafe int test_0_vector2d_unpack_high () {
210 Vector2d a = new Vector2d (1, 2);
211 Vector2d b = new Vector2d (4, 5);
213 Vector2d c = Vector2d.InterleaveHigh (a, b);
221 public static unsafe int test_0_vector2d_addsub () {
222 Vector2d a = new Vector2d (1, 2);
223 Vector2d b = new Vector2d (4, 1);
225 Vector2d c = Vector2d.AddSub (a, b);
233 public static unsafe int test_0_vector2d_hsub () {
234 Vector2d a = new Vector2d (1, 2);
235 Vector2d b = new Vector2d (4, 1);
237 Vector2d c = Vector2d.HorizontalSub (a, b);
246 public static unsafe int test_0_vector2d_hadd () {
247 Vector2d a = new Vector2d (1, 2);
248 Vector2d b = new Vector2d (4, 0);
250 Vector2d c = Vector2d.HorizontalAdd (a, b);
259 public static unsafe int test_0_vector2d_min () {
260 Vector2d a = new Vector2d (1, 2);
261 Vector2d b = new Vector2d (4, 0);
263 Vector2d c = Vector2d.Min (a, b);
272 public static unsafe int test_0_vector2d_max () {
273 Vector2d a = new Vector2d (1, 2);
274 Vector2d b = new Vector2d (4, 0);
276 Vector2d c = Vector2d.Max (a, b);
286 public static unsafe int test_0_vector2d_andnot () {
287 Vector2d a = new Vector2d (1, 2);
288 Vector2d b = new Vector2d (3, 4);
290 Vector4ui c = (Vector4ui)Vector2d.AndNot (a, b);
294 if (c.Y != 1074266112)
303 public static unsafe int test_0_vector2d_div () {
304 Vector2d a = new Vector2d (1, 2);
305 Vector2d b = new Vector2d (4, 5);
316 public static unsafe int test_0_vector2d_mul () {
317 Vector2d a = new Vector2d (1, 2);
318 Vector2d b = new Vector2d (3, 5);
328 public static unsafe int test_0_vector2d_sub () {
329 Vector2d a = new Vector2d (1, 2);
330 Vector2d b = new Vector2d (3, 5);
340 public static unsafe int test_0_vector2d_add () {
341 Vector2d a = new Vector2d (1, 2);
342 Vector2d b = new Vector2d (3, 4);
352 public static unsafe int test_0_vector2d_xor () {
353 Vector2d a = new Vector2d (1, 2);
354 Vector2d b = new Vector2d (3, 4);
356 Vector4ui c = (Vector4ui)(a ^ b);
360 if (c.Y != 2146959360)
369 public static unsafe int test_0_vector2d_or () {
370 Vector2d a = new Vector2d (1, 2);
371 Vector2d b = new Vector2d (3, 4);
373 Vector4ui c = (Vector4ui)(a | b);
377 if (c.Y != 2146959360)
381 if (c.W != 1074790400)
386 public static unsafe int test_0_vector2d_and () {
387 Vector2d a = new Vector2d (1, 2);
388 Vector2d b = new Vector2d (3, 4);
390 Vector4ui c = (Vector4ui)(a & b);
398 if (c.W != 1073741824)
403 public static unsafe int test_vector8s_pack_signed_sat () {
404 Vector8s a = new Vector8s (-200, 200, 3, 0, 5, 6, 5, 4);
405 Vector8s b = new Vector8s (9, 2, 1, 2, 3, 6, 5, 6);
407 Vector16sb c = Vector8s.PackWithSignedSaturation (a, b);
417 public static unsafe int test_vector16sb_sub_sat () {
418 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
419 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
421 Vector16sb c = Vector16sb.SubWithSaturation (a, b);
442 public static unsafe int test_vector16sb_add_sat () {
443 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
444 Vector16sb b = new Vector16sb (100, -100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
446 Vector16sb c = Vector16sb.AddWithSaturation (a, b);
467 public static unsafe int test_vector16sb_cmp_gt () {
468 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
469 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
471 Vector16sb c = Vector16sb.CompareGreaterThan (a, b);
491 public static int test_0_vector4ui_pack_with_sat () {
492 Vector4ui a = new Vector4ui (0xF0000000,0xF0000,3,4);
493 Vector4ui b = new Vector4ui (5,6,7,8);
495 Vector8us c = Vector4ui.SignedPackWithUnsignedSaturation (a, b);
516 public static int test_0_vector8us_pack_with_sat () {
517 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
518 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
519 Vector16b c = Vector8us.SignedPackWithUnsignedSaturation (a, b);
534 public static int test_0_vector8us_mul_high () {
535 Vector8us a = new Vector8us (0xFF00, 2, 3, 0, 5, 6, 5, 4);
536 Vector8us b = new Vector8us (0xFF00, 2, 1, 2, 3, 6, 5, 6);
537 Vector8us c = Vector8us.MultiplyStoreHigh (a, b);
558 public static int test_0_vector8us_cmpeq () {
559 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
560 Vector8us b = new Vector8us (9, 2, 1, 2, 3, 6, 5, 6);
561 Vector8us c = Vector8us.CompareEqual (a, b);
583 public static int test_0_vector4ui_cmpeq () {
584 Vector4ui a = new Vector4ui (6,1,6,3);
585 Vector4ui b = new Vector4ui (3,4,6,7);
586 Vector4ui c = Vector4ui.CompareEqual (a, b);
592 if (c.Z != 0xFFFFFFFF)
599 public static int test_0_vector4ui_shuffle () {
600 Vector4ui a = new Vector4ui (1,2,3,4);
601 Vector4ui c = Vector4ui.Shuffle (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
614 public static int test_0_vector4ui_extract_mask () {
615 Vector4ui a = new Vector4ui (0xFF00FF00,0x0F0FAA99,0,0);
616 int c = Vector4ui.ExtractByteMask (a);
623 public static int test_0_vector4ui_min () {
624 Vector4ui a = new Vector4ui (6,1,6,3);
625 Vector4ui b = new Vector4ui (3,4,6,7);
626 Vector4ui c = Vector4ui.Min (a, b);
639 public static int test_0_vector4ui_max () {
640 Vector4ui a = new Vector4ui (6,1,6,3);
641 Vector4ui b = new Vector4ui (3,4,6,7);
642 Vector4ui c = Vector4ui.Max (a, b);
655 public static int vector16b_cmpeq () {
656 Vector16b a = new Vector16b (1,0,9,0,0,0,0,0,0,0,0,0,0,0,0,1);
657 Vector16b b = new Vector16b (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
658 Vector16b c = Vector16b.CompareEqual (a, b);
696 public static int vector16b_sum_abs_diff () {
697 Vector16b a = new Vector16b (100,20,20,20,0,0,0,0,0,0,0,0,0,0, 0, 0);
698 Vector16sb b = new Vector16sb (0, 10,10,10,0,0,0,0,0,0,0,0,0,0,10,10);
699 Vector8us c = Vector16b.SumOfAbsoluteDifferences (a, b);
721 public static int test_0_vector16b_extract_mask () {
722 Vector16b a = new Vector16b (0xF0,0,0xF0,0,0,0,0xF0,0xAA,0x0F,0,0xFF,0,0,0,0,0);
723 int c = Vector16b.ExtractByteMask (a);
730 public static int test_0_vector16b_min () {
731 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
732 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
733 Vector16b c = Vector16b.Min (a, b);
770 public static int test_0_vector16b_max () {
771 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
772 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
773 Vector16b c = Vector16b.Max (a, b);
809 public static int test_0_vector16b_avg () {
810 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
811 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
812 Vector16b c = Vector16b.Average (a, b);
850 static unsafe Vector8us bad_method_regression_2 (Vector16b va, Vector16b vb) {
851 Vector8us res = new Vector8us ();
852 byte *a = (byte*)&va;
853 byte *b = (byte*)&vb;
856 for (int i = 0; i < 8; ++i)
857 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
858 res.V0 = (ushort)tmp;
861 for (int i = 0; i < 8; ++i)
862 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
863 res.V4 = (ushort)tmp;
867 /*This bug was caused the simplifier not taking notice of LDADDR on the remaining blocks.*/
868 public static int test_2_local_simplifier_regression_other_blocks () {
869 Vector16b a = new Vector16b (1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
870 Vector16b b = new Vector16b (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
871 Vector8us res = bad_method_regression_2 (a,b);
872 return (int)res.V0 + res.V4;
875 static unsafe Vector8us bad_method_regression (Vector16b va, Vector16b vb) {
876 Vector8us res = new Vector8us ();
877 byte *a = (byte*)&va;
878 byte *b = (byte*)&vb;
879 *((ushort*)&res) = 10;
890 /*This bug was caused the simplifier not taking notice of LDADDR on the first block.*/
891 public static int test_10_local_simplifier_regression_first_block () {
892 Vector16b a = new Vector16b ();
893 Vector16b b = new Vector16b ();
894 Vector8us res = bad_method_regression (a,b);
899 public static int test_0_vecto8us_extract_mask () {
900 Vector8us a = new Vector8us (0xF0F0, 0x700F, 0xAABB, 0x0000, 0x00F0, 0xF0F0, 0, 0);
901 int c = Vector8us.ExtractByteMask (a);
908 public static int test_0_vecto8us_shuffle_low () {
909 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
910 Vector8us c = Vector8us.ShuffleLow (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
931 public static int test_0_vecto8us_shuffle_high () {
932 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
933 Vector8us c = Vector8us.ShuffleHigh (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
955 public static int test_0_vecto8us_max () {
956 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
957 Vector8us b = new Vector8us (9, 1, 1, 2, 9, 6, 5, 1000);
958 Vector8us c = Vector8us.Max (a, b);
980 public static int test_0_vecto8us_min () {
981 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
982 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
983 Vector8us c = Vector8us.Min (a, b);
1004 public static int test_0_vecto8us_avg () {
1005 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1006 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1007 Vector8us c = Vector8us.Average (a, b);
1028 static void store_helper (ref Vector4f x) {
1030 k = new Vector4f(9,9,9,9);
1034 public static int test_0_vector4f_byref_store ()
1037 k = new Vector4f(1,2,3,4);
1038 store_helper (ref k);
1044 public static int test_0_vector4f_init_array_element ()
1046 Vector4f[] v = new Vector4f[1];
1047 v[0] = new Vector4f(9,9,9,9);
1053 public static int test_0_vector4f_dup_high () {
1054 Vector4f a = new Vector4f (1, 2, 3, 4);
1055 Vector4f c = Vector4f.DuplicateHigh(a);
1068 public static int test_0_vector4f_dup_low () {
1069 Vector4f a = new Vector4f (1, 2, 3, 4);
1070 Vector4f c = Vector4f.DuplicateLow (a);
1084 public static int test_0_vector4f_interleave_high () {
1085 Vector4f a = new Vector4f (1, 2, 3, 4);
1086 Vector4f b = new Vector4f (5, 6, 7, 8);
1087 Vector4f c = Vector4f.InterleaveHigh (a, b);
1100 public static int test_0_vector4f_interleave_low () {
1101 Vector4f a = new Vector4f (1, 2, 3, 4);
1102 Vector4f b = new Vector4f (5, 6, 7, 8);
1103 Vector4f c = Vector4f.InterleaveLow (a, b);
1116 public static int test_0_vector4f_rcp () {
1117 Vector4f a = new Vector4f (1, 2, 4, 8);
1118 Vector4f c = Vector4f.Reciprocal (a);
1120 //Test with ranges due to the terrible precision.
1121 if (c.X < (1 - 0.01f) || c.X > (1 + 0.01f))
1123 if (c.Y < (0.5 - 0.01f) || c.Y > (0.5 + 0.01f))
1125 if (c.Z < (0.25 - 0.01f) || c.Z > (0.25 + 0.01f))
1127 if (c.W < (0.125 - 0.01f) || c.W > (0.125 + 0.01f))
1132 public static int test_0_vector4f_xor () {
1133 Vector4f a = new Vector4f (1, 2, 3, 4);
1134 Vector4f b = new Vector4f (1, 3, 3, 8);
1137 if (((Vector4ui)c).X != 0)
1139 if (((Vector4ui)c).Y != 0x400000)
1141 if (((Vector4ui)c).Z != 0)
1143 if (((Vector4ui)c).W != 0x1800000)
1148 public static int test_0_vector4f_or () {
1149 Vector4f a = new Vector4f (1, 2, 3, 4);
1150 Vector4f b = new Vector4f (1, 3, 3, 8);
1153 if (((Vector4ui)c).X != 0x3F800000)
1155 if (((Vector4ui)c).Y != 0x40400000)
1157 if (((Vector4ui)c).Z != 0x40400000)
1159 if (((Vector4ui)c).W != 0x41800000)
1163 public static int test_0_vector4f_andn () {
1164 Vector4f a = new Vector4f (1, 2, 3, 4);
1165 Vector4f b = new Vector4f (1, 3, 3, 8);
1166 Vector4f c = Vector4f.AndNot (a ,b);
1168 if (((Vector4ui)c).X != 0)
1170 if (((Vector4ui)c).Y != 0x400000)
1172 if (((Vector4ui)c).Z != 0)
1174 if (((Vector4ui)c).W != 0x1000000)
1179 public static int test_0_vector4f_and () {
1180 Vector4f a = new Vector4f (1, 2, 3, 4);
1181 Vector4f b = new Vector4f (1, 3, 3, 8);
1184 if (((Vector4ui)c).X != 0x3F800000)
1186 if (((Vector4ui)c).Y != 0x40000000)
1188 if (((Vector4ui)c).Z != 0x40400000)
1190 if (((Vector4ui)c).W != 0x40000000)
1195 public static int test_0_vector4f_cmpord () {
1196 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1197 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1198 Vector4f c = Vector4f.CompareOrdered (a, b);
1200 if (((Vector4ui)c).X != 0)
1202 if (((Vector4ui)c).Y != 0)
1204 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1206 if (((Vector4ui)c).W != 0xFFFFFFFF)
1211 public static int test_0_vector4f_cmpnle () {
1212 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1213 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1214 Vector4f c = Vector4f.CompareNotLessEqual (a, b);
1216 if (((Vector4ui)c).X != 0xFFFFFFFF)
1218 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1220 if (((Vector4ui)c).Z != 0)
1222 if (((Vector4ui)c).W != 0)
1227 public static int test_0_vector4f_cmpnlt () {
1228 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1229 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1230 Vector4f c = Vector4f.CompareNotLessThan (a, b);
1232 if (((Vector4ui)c).X != 0xFFFFFFFF)
1234 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1236 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1238 if (((Vector4ui)c).W != 0)
1243 public static int test_0_vector4f_cmpneq () {
1244 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1245 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1246 Vector4f c = Vector4f.CompareNotEqual (a, b);
1248 if (((Vector4ui)c).X != 0xFFFFFFFF)
1250 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1252 if (((Vector4ui)c).Z != 0)
1254 if (((Vector4ui)c).W != 0xFFFFFFFF)
1259 public static int test_0_vector4f_cmpunord () {
1260 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1261 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1262 Vector4f c = Vector4f.CompareUnordered (a, b);
1264 if (((Vector4ui)c).X != 0xFFFFFFFF)
1266 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1268 if (((Vector4ui)c).Z != 0)
1270 if (((Vector4ui)c).W != 0)
1275 public static int test_0_vector4f_cmple () {
1276 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1277 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1278 Vector4f c = Vector4f.CompareLessEqual (a, b);
1280 if (((Vector4ui)c).X != 0)
1282 if (((Vector4ui)c).Y != 0)
1284 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1286 if (((Vector4ui)c).W != 0xFFFFFFFF)
1291 public static int test_0_vector4f_cmplt () {
1292 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1293 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1294 Vector4f c = Vector4f.CompareLessThan (a, b);
1296 if (((Vector4ui)c).X != 0)
1298 if (((Vector4ui)c).Y != 0)
1300 if (((Vector4ui)c).Z != 0)
1302 if (((Vector4ui)c).W != 0xFFFFFFFF)
1307 public static int test_0_vector4f_cmpeq () {
1308 Vector4f a = new Vector4f (float.NaN, 2, 3, 6);
1309 Vector4f b = new Vector4f (1, float.NaN, 3, 4);
1310 Vector4f c = Vector4f.CompareEqual (a, b);
1312 if (((Vector4ui)c).X != 0)
1314 if (((Vector4ui)c).Y != 0)
1316 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1318 if (((Vector4ui)c).W != 0)
1323 public static int test_0_vector4ui_sar () {
1324 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1326 Vector4ui c = Vector4ui.ShiftRightArithmetic (a, 2);
1328 if (c.X != 0xFC000000)
1339 public static int test_0_vector4ui_unpack_high () {
1340 Vector4ui a = new Vector4ui (1,2,3,4);
1341 Vector4ui b = new Vector4ui (5,6,7,8);
1343 Vector4ui c = Vector4ui.UnpackHigh(a, b);
1356 public static int test_0_vector4ui_unpack_low () {
1357 Vector4ui a = new Vector4ui (1,2,3,4);
1358 Vector4ui b = new Vector4ui (5,6,7,8);
1360 Vector4ui c = Vector4ui.UnpackLow (a, b);
1373 public static int test_0_vector4ui_xor () {
1374 Vector4ui a = new Vector4ui (1,2,3,4);
1375 Vector4ui b = new Vector4ui (7,5,3,1);
1377 Vector4ui c = a ^ b;
1390 public static int test_0_vector4ui_or () {
1391 Vector4ui a = new Vector4ui (1,2,3,4);
1392 Vector4ui b = new Vector4ui (7,5,3,1);
1394 Vector4ui c = a | b;
1406 public static int test_0_vector4ui_and () {
1407 Vector4ui a = new Vector4ui (1,2,3,4);
1408 Vector4ui b = new Vector4ui (7,5,3,1);
1410 Vector4ui c = a & b;
1423 public static int test_0_vector4ui_shr () {
1424 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1426 Vector4ui c = a >> 2;
1428 if (c.X != 0x3C000000)
1439 public static int test_0_vector4ui_shl () {
1440 Vector4ui a = new Vector4ui (10,20,3,40);
1442 Vector4ui c = a << 2;
1455 public static int test_0_vector4ui_mul () {
1456 Vector4ui a = new Vector4ui (0x8888,20,3,40);
1457 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1459 Vector4ui c = a * b;
1461 if (c.X != 0xffff7800)
1471 public static int test_0_vector4ui_sub () {
1472 Vector4ui a = new Vector4ui (1,20,3,40);
1473 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1475 Vector4ui c = a - b;
1477 if (c.X != 0xff0101)
1488 public static int test_0_vector4ui_add () {
1489 Vector4ui a = new Vector4ui (0xFF00FF00u,2,3,4);
1490 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1492 Vector4ui c = a + b;
1494 if (c.X != 0xfe01fe00)
1506 static int test_0_vector4ui_accessors () {
1507 Vector4ui a = new Vector4ui (1,2,3,4);
1533 static int test_0_vector8us_sub_sat () {
1534 Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
1535 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1536 Vector8us c = Vector8us.SubWithSaturation (a, b);
1557 static int test_0_vector8us_add_sat () {
1558 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1559 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1560 Vector8us c = Vector8us.AddWithSaturation (a, b);
1581 static int test_0_vector8us_unpack_low () {
1582 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1583 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
1584 Vector8us c = Vector8us.UnpackLow (a, b);
1606 static int test_0_vector8us_shift_left () {
1607 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1609 Vector8us c = a << amt;
1620 static int test_0_vector8us_shift_right_arithmetic () {
1621 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1623 Vector8us c = Vector8us.ShiftRightArithmetic (a, amt);
1634 static int test_0_vector8us_shift_variable_offset () {
1636 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1638 Vector8us c = b >> off;
1655 static int test_0_vector8us_shift_operand_is_live_after_op () {
1656 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1658 Vector8us c = b >> 2;
1674 static int test_0_vector8us_shr_constant () {
1675 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1676 Vector8us c = a >> 2;
1687 static int test_0_vector8us_mul () {
1688 Vector8us a = new Vector8us (0x0F00,4,5,6,7,8,9,10);
1689 Vector8us b = new Vector8us (0x0888,1,2,3,4,5,6,8);
1691 Vector8us c = a * b;
1701 static int test_0_vector8us_add () {
1702 Vector8us a = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1703 Vector8us b = new Vector8us (0x8888,1,2,3,4,5,6,8);
1705 Vector8us c = a + b;
1716 static int test_0_vector8us_sub () {
1717 Vector8us a = new Vector8us (3,4,5,6,7,8,9,10);
1718 Vector8us b = new Vector8us (10,1,2,3,4,5,6,8);
1720 Vector8us c = a - b;
1732 static int test_0_vector8us_accessors () {
1733 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1781 static int test_0_vector16b_unpack_high () {
1782 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1783 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1784 Vector16b c = Vector16b.UnpackHigh (a, b);
1805 static int test_0_vector16b_unpack_low () {
1806 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1807 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1808 Vector16b c = Vector16b.UnpackLow (a, b);
1829 static int test_0_vector16b_sub_sat () {
1830 Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1831 Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1832 Vector16b c = Vector16b.SubWithSaturation (a, b);
1843 static int test_0_vector16b_add_sat () {
1844 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1845 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1846 Vector16b c = Vector16b.AddWithSaturation (a, b);
1857 static int test_0_vector16b_add_ovf () {
1858 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1859 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1860 Vector16b c = a + b;
1871 static int test_0_vector16b_accessors () {
1872 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1959 public static int test_0_accessors () {
1960 Vector4f a = new Vector4f (1, 2, 3, 4);
1972 public static int test_0_packed_add_with_stack_tmp () {
1973 Vector4f a = new Vector4f (1, 2, 3, 4);
1974 Vector4f b = new Vector4f (5, 6, 7, 8);
1975 Vector4f c = new Vector4f (-1, -3, -4, -5);
1976 Vector4f d = a + b + c;
1988 public static int test_0_simple_packed_add () {
1989 Vector4f a = new Vector4f (1, 2, 3, 4);
1990 Vector4f b = new Vector4f (5, 6, 7, 8);
2004 public static int test_0_simple_packed_sub () {
2005 Vector4f a = new Vector4f (1, 2, 3, 4);
2006 Vector4f b = new Vector4f (5, 6, 7, 8);
2019 public static int test_0_simple_packed_mul () {
2020 Vector4f a = new Vector4f (1, 2, 3, 4);
2021 Vector4f b = new Vector4f (5, 6, 7, 8);
2034 public static int test_0_simple_packed_div () {
2035 Vector4f a = new Vector4f (2, 2, 3, 4);
2036 Vector4f b = new Vector4f (20, 10, 33, 12);
2049 public static int test_0_simple_packed_sqrt () {
2050 Vector4f a = new Vector4f (16, 4, 9, 25);
2051 a = Vector4f.Sqrt (a);
2063 public static int test_0_simple_packed_invsqrt () {
2064 Vector4f a = new Vector4f (16, 4, 100, 25);
2065 //this function has VERY low precision
2066 a = Vector4f.InvSqrt (a);
2067 if (a.X < (1/4f - 0.01f) || a.X > (1/4f + 0.01f))
2069 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
2071 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
2073 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
2078 public static int test_0_simple_packed_min () {
2079 Vector4f a = new Vector4f (16, -4, 9, 25);
2080 Vector4f b = new Vector4f (5, 3, 9, 0);
2081 Vector4f c = Vector4f.Min (a, b);
2093 public static int test_0_simple_packed_max () {
2094 Vector4f a = new Vector4f (16, -4, 9, 25);
2095 Vector4f b = new Vector4f (5, 3, 9, 0);
2096 Vector4f c = Vector4f.Max (a, b);
2108 public static int test_0_simple_packed_hadd () {
2109 Vector4f a = new Vector4f (5, 5, 6, 6);
2110 Vector4f b = new Vector4f (7, 7, 8, 8);
2111 Vector4f c = Vector4f.HorizontalAdd (a, b);
2123 public static int test_0_simple_packed_hsub () {
2124 Vector4f a = new Vector4f (5, 2, 6, 1);
2125 Vector4f b = new Vector4f (7, 0, 8, 3);
2126 Vector4f c = Vector4f.HorizontalSub (a, b);
2138 public static int test_0_simple_packed_addsub () {
2139 Vector4f a = new Vector4f (5, 2, 6, 1);
2140 Vector4f b = new Vector4f (7, 0, 8, 3);
2141 Vector4f c = Vector4f.AddSub (a, b);
2153 public static int test_0_simple_packed_shuffle () {
2154 Vector4f a = new Vector4f (1, 2, 3, 4);
2155 a = Vector4f.Shuffle(a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2167 public static int test_0_packed_shuffle_with_reg_pressure () {
2168 Vector4f v = new Vector4f (1, 2, 3, 4);
2169 Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
2170 if (ff) v = v + v -v ;
2172 Vector4f r0 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2173 Vector4f r1 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2174 Vector4f x = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2175 Vector4f r2 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2176 Vector4f r3 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2184 Vector4f result = r0 + r1 + r2 + r3;
2194 if (result.Y != result.Y)
2199 public static int test_24_regs_pressure_a () {
2200 Vector4f a = new Vector4f (1, 2, 3, 4);
2208 public static int test_54_regs_pressure_b () {
2209 Vector4f a = new Vector4f (1, 2, 3, 4);
2213 Vector4f e = a + b + c;
2214 Vector4f f = d - b + a - c;
2215 Vector4f g = a - d * f - c + b;
2216 Vector4f h = a * b - c + e;
2217 Vector4f i = h - g - f - e - d - c - b - a;
2218 Vector4f j = a + b + c + d + e + f + g + h + i;
2223 public static int test_3_single_block_var_is_properly_promoted () {
2224 Vector4f a = new Vector4f (4, 5, 6, 7);
2228 Vector4f b = new Vector4f (1, 2, 3, 4);
2239 static float float_val = 45f;
2241 public static int test_0_sse2_opt_and_simd_intrinsic_proper_regalloc () {
2242 Vector4f v = new Vector4f (1, 2, 3, 4);
2243 float f = float_val;
2252 public static int Main () {
2253 return TestDriver.RunTests (typeof (SimdTests));