4 public class SimdTests {
5 public static int test_0_accessor_vecto4f () {
6 Vector4f a = new Vector4f (1,2,3,4);
33 public static int test_0_accessor_vecto4i () {
34 Vector4i a = new Vector4i (0x70000000, -1, 3, 4);
36 if (a.X != 0x70000000)
61 public static int test_0_accessor_vecto4ui () {
62 Vector4ui a = new Vector4ui (0xF0000000, 0xF0000, 3, 4);
64 if (a.X != 0xF0000000)
89 static float use_getter_with_byref (ref Vector4f a) {
93 public static int test_0_accessor_and_byref_var () {
94 Vector4f a = new Vector4f (1, 2, 3, 4);
95 if (use_getter_with_byref (ref a) != 4)
100 public static unsafe int test_0_vector2ul_slr () {
101 Vector2ul a = new Vector2ul (1, 6);
103 Vector2ul c = a >> 1;
111 public static unsafe int test_0_vector2l_cmp_gt () {
112 Vector2l a = new Vector2l (10, 5);
113 Vector2l b = new Vector2l (-1, 5);
115 Vector2l c = Vector2l.CompareGreaterThan (a, b);
124 public static unsafe int test_0_vector2l_cmp_eq () {
125 Vector2l a = new Vector2l (0xFF, 5);
126 Vector2l b = new Vector2l (0xFF000000FFL, 5);
128 Vector2l c = Vector2l.CompareEqual (a, b);
137 public static unsafe int test_0_vector2l_srl () {
138 Vector2l a = new Vector2l (1, 6);
140 Vector2l c = Vector2l.LogicalRightShift (a, 1);
149 public static unsafe int test_0_vector2l_unpack_high () {
150 Vector2l a = new Vector2l (1, 6);
151 Vector2l b = new Vector2l (3, 4);
153 Vector2l c = Vector2l.UnpackHigh (a, b);
162 public static unsafe int test_0_vector2l_unpack_low () {
163 Vector2l a = new Vector2l (1, 6);
164 Vector2l b = new Vector2l (3, 4);
166 Vector2l c = Vector2l.UnpackLow (a, b);
175 public static unsafe int test_0_vector2l_xor () {
176 Vector2l a = new Vector2l (1, 6);
177 Vector2l b = new Vector2l (3, 4);
188 public static unsafe int test_0_vector2l_or () {
189 Vector2l a = new Vector2l (1, 6);
190 Vector2l b = new Vector2l (3, 4);
201 public static unsafe int test_0_vector2l_and () {
202 Vector2l a = new Vector2l (1, 6);
203 Vector2l b = new Vector2l (3, 4);
214 public static unsafe int test_0_vector2l_shl() {
215 Vector2l a = new Vector2l (1, 6);
225 public static unsafe int test_0_vector2l_sub() {
226 Vector2l a = new Vector2l (1, 6);
227 Vector2l b = new Vector2l (3, 4);
238 public static unsafe int test_0_vector2l_add () {
239 Vector2l a = new Vector2l (1, 2);
240 Vector2l b = new Vector2l (3, 4);
251 public static unsafe int test_0_vector2d_dup () {
252 Vector2d a = new Vector2d (3, 2);
254 Vector2d c = Vector2d.Duplicate (a);
263 public static unsafe int test_0_vector2d_cmp_eq () {
264 Vector2d a = new Vector2d (3, 2);
265 Vector2d b = new Vector2d (3, 4);
267 Vector4ui c = (Vector4ui)Vector2d.CompareEqual (a, b);
269 if (c.X != 0xFFFFFFFF)
271 if (c.Y != 0xFFFFFFFF)
280 public static unsafe int test_0_vector2d_unpack_low () {
281 Vector2d a = new Vector2d (1, 2);
282 Vector2d b = new Vector2d (4, 5);
284 Vector2d c = Vector2d.InterleaveLow (a, b);
293 public static unsafe int test_0_vector2d_unpack_high () {
294 Vector2d a = new Vector2d (1, 2);
295 Vector2d b = new Vector2d (4, 5);
297 Vector2d c = Vector2d.InterleaveHigh (a, b);
305 public static unsafe int test_0_vector2d_addsub () {
306 Vector2d a = new Vector2d (1, 2);
307 Vector2d b = new Vector2d (4, 1);
309 Vector2d c = Vector2d.AddSub (a, b);
317 public static unsafe int test_0_vector2d_hsub () {
318 Vector2d a = new Vector2d (1, 2);
319 Vector2d b = new Vector2d (4, 1);
321 Vector2d c = Vector2d.HorizontalSub (a, b);
330 public static unsafe int test_0_vector2d_hadd () {
331 Vector2d a = new Vector2d (1, 2);
332 Vector2d b = new Vector2d (4, 0);
334 Vector2d c = Vector2d.HorizontalAdd (a, b);
343 public static unsafe int test_0_vector2d_min () {
344 Vector2d a = new Vector2d (1, 2);
345 Vector2d b = new Vector2d (4, 0);
347 Vector2d c = Vector2d.Min (a, b);
356 public static unsafe int test_0_vector2d_max () {
357 Vector2d a = new Vector2d (1, 2);
358 Vector2d b = new Vector2d (4, 0);
360 Vector2d c = Vector2d.Max (a, b);
370 public static unsafe int test_0_vector2d_andnot () {
371 Vector2d a = new Vector2d (1, 2);
372 Vector2d b = new Vector2d (3, 4);
374 Vector4ui c = (Vector4ui)Vector2d.AndNot (a, b);
378 if (c.Y != 1074266112)
387 public static unsafe int test_0_vector2d_div () {
388 Vector2d a = new Vector2d (1, 2);
389 Vector2d b = new Vector2d (4, 5);
400 public static unsafe int test_0_vector2d_mul () {
401 Vector2d a = new Vector2d (1, 2);
402 Vector2d b = new Vector2d (3, 5);
412 public static unsafe int test_0_vector2d_sub () {
413 Vector2d a = new Vector2d (1, 2);
414 Vector2d b = new Vector2d (3, 5);
424 public static unsafe int test_0_vector2d_add () {
425 Vector2d a = new Vector2d (1, 2);
426 Vector2d b = new Vector2d (3, 4);
436 public static unsafe int test_0_vector2d_xor () {
437 Vector2d a = new Vector2d (1, 2);
438 Vector2d b = new Vector2d (3, 4);
440 Vector4ui c = (Vector4ui)(a ^ b);
444 if (c.Y != 2146959360)
453 public static unsafe int test_0_vector2d_or () {
454 Vector2d a = new Vector2d (1, 2);
455 Vector2d b = new Vector2d (3, 4);
457 Vector4ui c = (Vector4ui)(a | b);
461 if (c.Y != 2146959360)
465 if (c.W != 1074790400)
470 public static unsafe int test_0_vector2d_and () {
471 Vector2d a = new Vector2d (1, 2);
472 Vector2d b = new Vector2d (3, 4);
474 Vector4ui c = (Vector4ui)(a & b);
482 if (c.W != 1073741824)
487 public static unsafe int test_vector8s_pack_signed_sat () {
488 Vector8s a = new Vector8s (-200, 200, 3, 0, 5, 6, 5, 4);
489 Vector8s b = new Vector8s (9, 2, 1, 2, 3, 6, 5, 6);
491 Vector16sb c = Vector8s.PackWithSignedSaturation (a, b);
501 public static unsafe int test_vector16sb_sub_sat () {
502 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
503 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
505 Vector16sb c = Vector16sb.SubtractWithSaturation (a, b);
526 public static unsafe int test_vector16sb_add_sat () {
527 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
528 Vector16sb b = new Vector16sb (100, -100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
530 Vector16sb c = Vector16sb.AddWithSaturation (a, b);
551 public static unsafe int test_vector16sb_cmp_gt () {
552 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
553 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
555 Vector16sb c = Vector16sb.CompareGreaterThan (a, b);
575 public static int test_0_vector4ui_pack_with_sat () {
576 Vector4ui a = new Vector4ui (0xF0000000,0xF0000,3,4);
577 Vector4ui b = new Vector4ui (5,6,7,8);
579 Vector8us c = Vector4ui.SignedPackWithUnsignedSaturation (a, b);
600 public static int test_0_vector8us_pack_with_sat () {
601 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
602 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
603 Vector16b c = Vector8us.SignedPackWithUnsignedSaturation (a, b);
618 public static int test_0_vector8us_mul_high () {
619 Vector8us a = new Vector8us (0xFF00, 2, 3, 0, 5, 6, 5, 4);
620 Vector8us b = new Vector8us (0xFF00, 2, 1, 2, 3, 6, 5, 6);
621 Vector8us c = Vector8us.MultiplyStoreHigh (a, b);
642 public static int test_0_vector8us_cmpeq () {
643 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
644 Vector8us b = new Vector8us (9, 2, 1, 2, 3, 6, 5, 6);
645 Vector8us c = Vector8us.CompareEqual (a, b);
667 public static int test_0_vector4ui_cmpeq () {
668 Vector4ui a = new Vector4ui (6,1,6,3);
669 Vector4ui b = new Vector4ui (3,4,6,7);
670 Vector4ui c = Vector4ui.CompareEqual (a, b);
676 if (c.Z != 0xFFFFFFFF)
683 public static int test_0_vector4ui_shuffle () {
684 Vector4ui a = new Vector4ui (1,2,3,4);
685 Vector4ui c = Vector4ui.Shuffle (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
698 public static int test_0_vector4ui_extract_mask () {
699 Vector4ui a = new Vector4ui (0xFF00FF00,0x0F0FAA99,0,0);
700 int c = Vector4ui.ExtractByteMask (a);
707 public static int test_0_vector4ui_min () {
708 Vector4ui a = new Vector4ui (6,1,6,3);
709 Vector4ui b = new Vector4ui (3,4,6,7);
710 Vector4ui c = Vector4ui.Min (a, b);
723 public static int test_0_vector4ui_max () {
724 Vector4ui a = new Vector4ui (6,1,6,3);
725 Vector4ui b = new Vector4ui (3,4,6,7);
726 Vector4ui c = Vector4ui.Max (a, b);
739 public static int vector16b_cmpeq () {
740 Vector16b a = new Vector16b (1,0,9,0,0,0,0,0,0,0,0,0,0,0,0,1);
741 Vector16b b = new Vector16b (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
742 Vector16b c = Vector16b.CompareEqual (a, b);
780 public static int vector16b_sum_abs_diff () {
781 Vector16b a = new Vector16b (100,20,20,20,0,0,0,0,0,0,0,0,0,0, 0, 0);
782 Vector16sb b = new Vector16sb (0, 10,10,10,0,0,0,0,0,0,0,0,0,0,10,10);
783 Vector8us c = Vector16b.SumOfAbsoluteDifferences (a, b);
805 public static int test_0_vector16b_extract_mask () {
806 Vector16b a = new Vector16b (0xF0,0,0xF0,0,0,0,0xF0,0xAA,0x0F,0,0xFF,0,0,0,0,0);
807 int c = Vector16b.ExtractByteMask (a);
814 public static int test_0_vector16b_min () {
815 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
816 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
817 Vector16b c = Vector16b.Min (a, b);
854 public static int test_0_vector16b_max () {
855 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
856 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
857 Vector16b c = Vector16b.Max (a, b);
893 public static int test_0_vector16b_avg () {
894 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
895 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
896 Vector16b c = Vector16b.Average (a, b);
934 static unsafe Vector8us bad_method_regression_2 (Vector16b va, Vector16b vb) {
935 Vector8us res = new Vector8us ();
936 byte *a = (byte*)&va;
937 byte *b = (byte*)&vb;
940 for (int i = 0; i < 8; ++i)
941 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
942 res.V0 = (ushort)tmp;
945 for (int i = 0; i < 8; ++i)
946 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
947 res.V4 = (ushort)tmp;
951 /*This bug was caused the simplifier not taking notice of LDADDR on the remaining blocks.*/
952 public static int test_2_local_simplifier_regression_other_blocks () {
953 Vector16b a = new Vector16b (1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
954 Vector16b b = new Vector16b (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
955 Vector8us res = bad_method_regression_2 (a,b);
956 return (int)res.V0 + res.V4;
959 static unsafe Vector8us bad_method_regression (Vector16b va, Vector16b vb) {
960 Vector8us res = new Vector8us ();
961 byte *a = (byte*)&va;
962 byte *b = (byte*)&vb;
963 *((ushort*)&res) = 10;
974 /*This bug was caused the simplifier not taking notice of LDADDR on the first block.*/
975 public static int test_10_local_simplifier_regression_first_block () {
976 Vector16b a = new Vector16b ();
977 Vector16b b = new Vector16b ();
978 Vector8us res = bad_method_regression (a,b);
983 public static int test_0_vecto8us_extract_mask () {
984 Vector8us a = new Vector8us (0xF0F0, 0x700F, 0xAABB, 0x0000, 0x00F0, 0xF0F0, 0, 0);
985 int c = Vector8us.ExtractByteMask (a);
992 public static int test_0_vecto8us_shuffle_low () {
993 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
994 Vector8us c = Vector8us.ShuffleLow (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1015 public static int test_0_vecto8us_shuffle_high () {
1016 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1017 Vector8us c = Vector8us.ShuffleHigh (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1039 public static int test_0_vecto8us_max () {
1040 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1041 Vector8us b = new Vector8us (9, 1, 1, 2, 9, 6, 5, 1000);
1042 Vector8us c = Vector8us.Max (a, b);
1064 public static int test_0_vecto8us_min () {
1065 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
1066 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1067 Vector8us c = Vector8us.Min (a, b);
1088 public static int test_0_vecto8us_avg () {
1089 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1090 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1091 Vector8us c = Vector8us.Average (a, b);
1112 static void store_helper (ref Vector4f x) {
1114 k = new Vector4f(9,9,9,9);
1118 public static int test_0_vector4f_byref_store ()
1121 k = new Vector4f(1,2,3,4);
1122 store_helper (ref k);
1128 public static int test_0_vector4f_init_array_element ()
1130 Vector4f[] v = new Vector4f[1];
1131 v[0] = new Vector4f(9,9,9,9);
1137 public static int test_0_vector4f_dup_high () {
1138 Vector4f a = new Vector4f (1, 2, 3, 4);
1139 Vector4f c = Vector4f.DuplicateHigh(a);
1152 public static int test_0_vector4f_dup_low () {
1153 Vector4f a = new Vector4f (1, 2, 3, 4);
1154 Vector4f c = Vector4f.DuplicateLow (a);
1168 public static int test_0_vector4f_interleave_high () {
1169 Vector4f a = new Vector4f (1, 2, 3, 4);
1170 Vector4f b = new Vector4f (5, 6, 7, 8);
1171 Vector4f c = Vector4f.InterleaveHigh (a, b);
1184 public static int test_0_vector4f_interleave_low () {
1185 Vector4f a = new Vector4f (1, 2, 3, 4);
1186 Vector4f b = new Vector4f (5, 6, 7, 8);
1187 Vector4f c = Vector4f.InterleaveLow (a, b);
1200 public static int test_0_vector4f_rcp () {
1201 Vector4f a = new Vector4f (1, 2, 4, 8);
1202 Vector4f c = Vector4f.Reciprocal (a);
1204 //Test with ranges due to the terrible precision.
1205 if (c.X < (1 - 0.01f) || c.X > (1 + 0.01f))
1207 if (c.Y < (0.5 - 0.01f) || c.Y > (0.5 + 0.01f))
1209 if (c.Z < (0.25 - 0.01f) || c.Z > (0.25 + 0.01f))
1211 if (c.W < (0.125 - 0.01f) || c.W > (0.125 + 0.01f))
1216 public static int test_0_vector4f_xor () {
1217 Vector4f a = new Vector4f (1, 2, 3, 4);
1218 Vector4f b = new Vector4f (1, 3, 3, 8);
1221 if (((Vector4ui)c).X != 0)
1223 if (((Vector4ui)c).Y != 0x400000)
1225 if (((Vector4ui)c).Z != 0)
1227 if (((Vector4ui)c).W != 0x1800000)
1232 public static int test_0_vector4f_or () {
1233 Vector4f a = new Vector4f (1, 2, 3, 4);
1234 Vector4f b = new Vector4f (1, 3, 3, 8);
1237 if (((Vector4ui)c).X != 0x3F800000)
1239 if (((Vector4ui)c).Y != 0x40400000)
1241 if (((Vector4ui)c).Z != 0x40400000)
1243 if (((Vector4ui)c).W != 0x41800000)
1247 public static int test_0_vector4f_andn () {
1248 Vector4f a = new Vector4f (1, 2, 3, 4);
1249 Vector4f b = new Vector4f (1, 3, 3, 8);
1250 Vector4f c = Vector4f.AndNot (a ,b);
1252 if (((Vector4ui)c).X != 0)
1254 if (((Vector4ui)c).Y != 0x400000)
1256 if (((Vector4ui)c).Z != 0)
1258 if (((Vector4ui)c).W != 0x1000000)
1263 public static int test_0_vector4f_and () {
1264 Vector4f a = new Vector4f (1, 2, 3, 4);
1265 Vector4f b = new Vector4f (1, 3, 3, 8);
1268 if (((Vector4ui)c).X != 0x3F800000)
1270 if (((Vector4ui)c).Y != 0x40000000)
1272 if (((Vector4ui)c).Z != 0x40400000)
1274 if (((Vector4ui)c).W != 0x40000000)
1279 public static int test_0_vector4f_cmpord () {
1280 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1281 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1282 Vector4f c = Vector4f.CompareOrdered (a, b);
1284 if (((Vector4ui)c).X != 0)
1286 if (((Vector4ui)c).Y != 0)
1288 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1290 if (((Vector4ui)c).W != 0xFFFFFFFF)
1295 public static int test_0_vector4f_cmpnle () {
1296 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1297 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1298 Vector4f c = Vector4f.CompareNotLessEqual (a, b);
1300 if (((Vector4ui)c).X != 0xFFFFFFFF)
1302 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1304 if (((Vector4ui)c).Z != 0)
1306 if (((Vector4ui)c).W != 0)
1311 public static int test_0_vector4f_cmpnlt () {
1312 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1313 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1314 Vector4f c = Vector4f.CompareNotLessThan (a, b);
1316 if (((Vector4ui)c).X != 0xFFFFFFFF)
1318 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1320 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1322 if (((Vector4ui)c).W != 0)
1327 public static int test_0_vector4f_cmpneq () {
1328 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1329 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1330 Vector4f c = Vector4f.CompareNotEqual (a, b);
1332 if (((Vector4ui)c).X != 0xFFFFFFFF)
1334 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1336 if (((Vector4ui)c).Z != 0)
1338 if (((Vector4ui)c).W != 0xFFFFFFFF)
1343 public static int test_0_vector4f_cmpunord () {
1344 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1345 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1346 Vector4f c = Vector4f.CompareUnordered (a, b);
1348 if (((Vector4ui)c).X != 0xFFFFFFFF)
1350 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1352 if (((Vector4ui)c).Z != 0)
1354 if (((Vector4ui)c).W != 0)
1359 public static int test_0_vector4f_cmple () {
1360 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1361 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1362 Vector4f c = Vector4f.CompareLessEqual (a, b);
1364 if (((Vector4ui)c).X != 0)
1366 if (((Vector4ui)c).Y != 0)
1368 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1370 if (((Vector4ui)c).W != 0xFFFFFFFF)
1375 public static int test_0_vector4f_cmplt () {
1376 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1377 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1378 Vector4f c = Vector4f.CompareLessThan (a, b);
1380 if (((Vector4ui)c).X != 0)
1382 if (((Vector4ui)c).Y != 0)
1384 if (((Vector4ui)c).Z != 0)
1386 if (((Vector4ui)c).W != 0xFFFFFFFF)
1391 public static int test_0_vector4f_cmpeq () {
1392 Vector4f a = new Vector4f (float.NaN, 2, 3, 6);
1393 Vector4f b = new Vector4f (1, float.NaN, 3, 4);
1394 Vector4f c = Vector4f.CompareEqual (a, b);
1396 if (((Vector4ui)c).X != 0)
1398 if (((Vector4ui)c).Y != 0)
1400 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1402 if (((Vector4ui)c).W != 0)
1407 public static int test_0_vector4ui_sar () {
1408 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1410 Vector4ui c = Vector4ui.ArithmeticRightShift (a, 2);
1412 if (c.X != 0xFC000000)
1423 public static int test_0_vector4ui_unpack_high () {
1424 Vector4ui a = new Vector4ui (1,2,3,4);
1425 Vector4ui b = new Vector4ui (5,6,7,8);
1427 Vector4ui c = Vector4ui.UnpackHigh(a, b);
1440 public static int test_0_vector4ui_unpack_low () {
1441 Vector4ui a = new Vector4ui (1,2,3,4);
1442 Vector4ui b = new Vector4ui (5,6,7,8);
1444 Vector4ui c = Vector4ui.UnpackLow (a, b);
1457 public static int test_0_vector4ui_xor () {
1458 Vector4ui a = new Vector4ui (1,2,3,4);
1459 Vector4ui b = new Vector4ui (7,5,3,1);
1461 Vector4ui c = a ^ b;
1474 public static int test_0_vector4ui_or () {
1475 Vector4ui a = new Vector4ui (1,2,3,4);
1476 Vector4ui b = new Vector4ui (7,5,3,1);
1478 Vector4ui c = a | b;
1490 public static int test_0_vector4ui_and () {
1491 Vector4ui a = new Vector4ui (1,2,3,4);
1492 Vector4ui b = new Vector4ui (7,5,3,1);
1494 Vector4ui c = a & b;
1507 public static int test_0_vector4ui_shr () {
1508 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1510 Vector4ui c = a >> 2;
1512 if (c.X != 0x3C000000)
1523 public static int test_0_vector4ui_shl () {
1524 Vector4ui a = new Vector4ui (10,20,3,40);
1526 Vector4ui c = a << 2;
1539 public static int test_0_vector4ui_mul () {
1540 Vector4ui a = new Vector4ui (0x8888,20,3,40);
1541 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1543 Vector4ui c = a * b;
1545 if (c.X != 0xffff7800)
1555 public static int test_0_vector4ui_sub () {
1556 Vector4ui a = new Vector4ui (1,20,3,40);
1557 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1559 Vector4ui c = a - b;
1561 if (c.X != 0xff0101)
1572 public static int test_0_vector4ui_add () {
1573 Vector4ui a = new Vector4ui (0xFF00FF00u,2,3,4);
1574 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1576 Vector4ui c = a + b;
1578 if (c.X != 0xfe01fe00)
1590 static int test_0_vector4ui_accessors () {
1591 Vector4ui a = new Vector4ui (1,2,3,4);
1617 static int test_0_vector8us_sub_sat () {
1618 Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
1619 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1620 Vector8us c = Vector8us.SubtractWithSaturation (a, b);
1641 static int test_0_vector8us_add_sat () {
1642 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1643 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1644 Vector8us c = Vector8us.AddWithSaturation (a, b);
1665 static int test_0_vector8us_unpack_low () {
1666 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1667 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
1668 Vector8us c = Vector8us.UnpackLow (a, b);
1690 static int test_0_vector8us_shift_left () {
1691 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1693 Vector8us c = a << amt;
1704 static int test_0_vector8us_shift_right_arithmetic () {
1705 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1707 Vector8us c = Vector8us.ArithmeticRightShift (a, amt);
1718 static int test_0_vector8us_shift_variable_offset () {
1720 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1722 Vector8us c = b >> off;
1739 static int test_0_vector8us_shift_operand_is_live_after_op () {
1740 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1742 Vector8us c = b >> 2;
1758 static int test_0_vector8us_shr_constant () {
1759 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1760 Vector8us c = a >> 2;
1771 static int test_0_vector8us_mul () {
1772 Vector8us a = new Vector8us (0x0F00,4,5,6,7,8,9,10);
1773 Vector8us b = new Vector8us (0x0888,1,2,3,4,5,6,8);
1775 Vector8us c = a * b;
1785 static int test_0_vector8us_add () {
1786 Vector8us a = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1787 Vector8us b = new Vector8us (0x8888,1,2,3,4,5,6,8);
1789 Vector8us c = a + b;
1800 static int test_0_vector8us_sub () {
1801 Vector8us a = new Vector8us (3,4,5,6,7,8,9,10);
1802 Vector8us b = new Vector8us (10,1,2,3,4,5,6,8);
1804 Vector8us c = a - b;
1816 static int test_0_vector8us_accessors () {
1817 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1865 static int test_0_vector16b_unpack_high () {
1866 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1867 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1868 Vector16b c = Vector16b.UnpackHigh (a, b);
1889 static int test_0_vector16b_unpack_low () {
1890 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1891 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1892 Vector16b c = Vector16b.UnpackLow (a, b);
1913 static int test_0_vector16b_sub_sat () {
1914 Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1915 Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1916 Vector16b c = Vector16b.SubtractWithSaturation (a, b);
1927 static int test_0_vector16b_add_sat () {
1928 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1929 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1930 Vector16b c = Vector16b.AddWithSaturation (a, b);
1941 static int test_0_vector16b_add_ovf () {
1942 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1943 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1944 Vector16b c = a + b;
1955 static int test_0_vector16b_accessors () {
1956 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2043 public static int test_0_accessors () {
2044 Vector4f a = new Vector4f (1, 2, 3, 4);
2056 public static int test_0_packed_add_with_stack_tmp () {
2057 Vector4f a = new Vector4f (1, 2, 3, 4);
2058 Vector4f b = new Vector4f (5, 6, 7, 8);
2059 Vector4f c = new Vector4f (-1, -3, -4, -5);
2060 Vector4f d = a + b + c;
2072 public static int test_0_simple_packed_add () {
2073 Vector4f a = new Vector4f (1, 2, 3, 4);
2074 Vector4f b = new Vector4f (5, 6, 7, 8);
2088 public static int test_0_simple_packed_sub () {
2089 Vector4f a = new Vector4f (1, 2, 3, 4);
2090 Vector4f b = new Vector4f (5, 6, 7, 8);
2103 public static int test_0_simple_packed_mul () {
2104 Vector4f a = new Vector4f (1, 2, 3, 4);
2105 Vector4f b = new Vector4f (5, 6, 7, 8);
2118 public static int test_0_simple_packed_div () {
2119 Vector4f a = new Vector4f (2, 2, 3, 4);
2120 Vector4f b = new Vector4f (20, 10, 33, 12);
2133 public static int test_0_simple_packed_sqrt () {
2134 Vector4f a = new Vector4f (16, 4, 9, 25);
2135 a = Vector4f.Sqrt (a);
2147 public static int test_0_simple_packed_invsqrt () {
2148 Vector4f a = new Vector4f (16, 4, 100, 25);
2149 //this function has VERY low precision
2150 a = Vector4f.InvSqrt (a);
2151 if (a.X < (1/4f - 0.01f) || a.X > (1/4f + 0.01f))
2153 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
2155 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
2157 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
2162 public static int test_0_simple_packed_min () {
2163 Vector4f a = new Vector4f (16, -4, 9, 25);
2164 Vector4f b = new Vector4f (5, 3, 9, 0);
2165 Vector4f c = Vector4f.Min (a, b);
2177 public static int test_0_simple_packed_max () {
2178 Vector4f a = new Vector4f (16, -4, 9, 25);
2179 Vector4f b = new Vector4f (5, 3, 9, 0);
2180 Vector4f c = Vector4f.Max (a, b);
2192 public static int test_0_simple_packed_hadd () {
2193 Vector4f a = new Vector4f (5, 5, 6, 6);
2194 Vector4f b = new Vector4f (7, 7, 8, 8);
2195 Vector4f c = Vector4f.HorizontalAdd (a, b);
2207 public static int test_0_simple_packed_hsub () {
2208 Vector4f a = new Vector4f (5, 2, 6, 1);
2209 Vector4f b = new Vector4f (7, 0, 8, 3);
2210 Vector4f c = Vector4f.HorizontalSub (a, b);
2222 public static int test_0_simple_packed_addsub () {
2223 Vector4f a = new Vector4f (5, 2, 6, 1);
2224 Vector4f b = new Vector4f (7, 0, 8, 3);
2225 Vector4f c = Vector4f.AddSub (a, b);
2237 public static int test_0_simple_packed_shuffle () {
2238 Vector4f a = new Vector4f (1, 2, 3, 4);
2239 a = Vector4f.Shuffle(a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2251 public static int test_0_packed_shuffle_with_reg_pressure () {
2252 Vector4f v = new Vector4f (1, 2, 3, 4);
2253 Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
2254 if (ff) v = v + v -v ;
2256 Vector4f r0 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2257 Vector4f r1 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2258 Vector4f x = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2259 Vector4f r2 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2260 Vector4f r3 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2268 Vector4f result = r0 + r1 + r2 + r3;
2278 if (result.Y != result.Y)
2283 public static int test_24_regs_pressure_a () {
2284 Vector4f a = new Vector4f (1, 2, 3, 4);
2292 public static int test_54_regs_pressure_b () {
2293 Vector4f a = new Vector4f (1, 2, 3, 4);
2297 Vector4f e = a + b + c;
2298 Vector4f f = d - b + a - c;
2299 Vector4f g = a - d * f - c + b;
2300 Vector4f h = a * b - c + e;
2301 Vector4f i = h - g - f - e - d - c - b - a;
2302 Vector4f j = a + b + c + d + e + f + g + h + i;
2307 public static int test_3_single_block_var_is_properly_promoted () {
2308 Vector4f a = new Vector4f (4, 5, 6, 7);
2312 Vector4f b = new Vector4f (1, 2, 3, 4);
2323 static float float_val = 45f;
2325 public static int test_0_sse2_opt_and_simd_intrinsic_proper_regalloc () {
2326 Vector4f v = new Vector4f (1, 2, 3, 4);
2327 float f = float_val;
2336 public static int Main () {
2337 return TestDriver.RunTests (typeof (SimdTests));