4 public class SimdTests {
5 public static int test_0_set_vector_small_array () {
6 uint[] array = new uint[3];
9 array.SetVector (new Vector4ui (), 0);
11 } catch (IndexOutOfRangeException) {
16 public static int test_0_set_vector_negative_index () {
17 uint[] array = new uint[4];
20 array.SetVector (new Vector4ui (), -1);
22 } catch (IndexOutOfRangeException) {
27 public static int test_0_set_vector_bounds_error () {
28 uint[] array = new uint[4];
31 array.SetVector (new Vector4ui (), 1);
33 } catch (IndexOutOfRangeException) {
38 public static int test_0_set_vector () {
39 uint[] array = new uint[10];
40 Vector4ui a = new Vector4ui (11, 22, 33, 44);
42 array.SetVector (a, 1);
55 public static int test_0_get_vector_small_array () {
56 uint[] array = new uint[3];
59 Vector4ui res = array.GetVector (0);
61 } catch (IndexOutOfRangeException) {
66 public static int test_0_get_vector_negative_index () {
67 uint[] array = new uint[4];
70 Vector4ui res = array.GetVector (-1);
72 } catch (IndexOutOfRangeException) {
77 public static int test_0_get_vector_bounds_error () {
78 uint[] array = new uint[4];
81 Vector4ui res = array.GetVector (1);
83 } catch (IndexOutOfRangeException) {
88 public static int test_0_get_vector () {
89 uint[] array = new uint[] { 11, 22, 33, 44, 55, 66, 77, 88, 99, 111 };
91 Vector4ui res = array.GetVector (1);
105 public static int test_0_accessor_vecto2l () {
106 Vector2l a = new Vector2l (3, 2);
113 a.X = 500000000000055l;
116 if (a.X != 500000000000055l)
118 if (a.Y != -12345678900l)
123 public static int test_0_accessor_vecto2d () {
124 Vector2d a = new Vector2d (3, 2);
134 if (a.X != 5000000000000)
141 public static int test_0_accessor_vecto4f () {
142 Vector4f a = new Vector4f (1,2,3,4);
169 public static int test_0_accessor_vecto4i () {
170 Vector4i a = new Vector4i (0x70000000, -1, 3, 4);
172 if (a.X != 0x70000000)
192 if (a.W != -44444444)
197 public static int test_0_accessor_vecto4ui () {
198 Vector4ui a = new Vector4ui (0xF0000000, 0xF0000, 3, 4);
200 if (a.X != 0xF0000000)
225 static float use_getter_with_byref (ref Vector4f a) {
229 public static int test_0_accessor_and_byref_var () {
230 Vector4f a = new Vector4f (1, 2, 3, 4);
231 if (use_getter_with_byref (ref a) != 4)
236 public static unsafe int test_0_vector2ul_slr () {
237 Vector2ul a = new Vector2ul (1, 6);
239 Vector2ul c = a >> 1;
247 public static unsafe int test_0_vector2l_cmp_gt () {
248 Vector2l a = new Vector2l (10, 5);
249 Vector2l b = new Vector2l (-1, 5);
251 Vector2l c = Vector2l.CompareGreaterThan (a, b);
260 public static unsafe int test_0_vector2l_cmp_eq () {
261 Vector2l a = new Vector2l (0xFF, 5);
262 Vector2l b = new Vector2l (0xFF000000FFL, 5);
264 Vector2l c = Vector2l.CompareEqual (a, b);
273 public static unsafe int test_0_vector2l_srl () {
274 Vector2l a = new Vector2l (1, 6);
276 Vector2l c = Vector2l.LogicalRightShift (a, 1);
285 public static unsafe int test_0_vector2l_unpack_high () {
286 Vector2l a = new Vector2l (1, 6);
287 Vector2l b = new Vector2l (3, 4);
289 Vector2l c = Vector2l.UnpackHigh (a, b);
298 public static unsafe int test_0_vector2l_unpack_low () {
299 Vector2l a = new Vector2l (1, 6);
300 Vector2l b = new Vector2l (3, 4);
302 Vector2l c = Vector2l.UnpackLow (a, b);
311 public static unsafe int test_0_vector2l_xor () {
312 Vector2l a = new Vector2l (1, 6);
313 Vector2l b = new Vector2l (3, 4);
324 public static unsafe int test_0_vector2l_or () {
325 Vector2l a = new Vector2l (1, 6);
326 Vector2l b = new Vector2l (3, 4);
337 public static unsafe int test_0_vector2l_and () {
338 Vector2l a = new Vector2l (1, 6);
339 Vector2l b = new Vector2l (3, 4);
350 public static unsafe int test_0_vector2l_shl() {
351 Vector2l a = new Vector2l (1, 6);
361 public static unsafe int test_0_vector2l_sub() {
362 Vector2l a = new Vector2l (1, 6);
363 Vector2l b = new Vector2l (3, 4);
374 public static unsafe int test_0_vector2l_add () {
375 Vector2l a = new Vector2l (1, 2);
376 Vector2l b = new Vector2l (3, 4);
387 public static unsafe int test_0_vector2d_dup () {
388 Vector2d a = new Vector2d (3, 2);
390 Vector2d c = Vector2d.Duplicate (a);
399 public static unsafe int test_0_vector2d_cmp_eq () {
400 Vector2d a = new Vector2d (3, 2);
401 Vector2d b = new Vector2d (3, 4);
403 Vector4ui c = (Vector4ui)Vector2d.CompareEqual (a, b);
405 if (c.X != 0xFFFFFFFF)
407 if (c.Y != 0xFFFFFFFF)
416 public static unsafe int test_0_vector2d_unpack_low () {
417 Vector2d a = new Vector2d (1, 2);
418 Vector2d b = new Vector2d (4, 5);
420 Vector2d c = Vector2d.InterleaveLow (a, b);
429 public static unsafe int test_0_vector2d_unpack_high () {
430 Vector2d a = new Vector2d (1, 2);
431 Vector2d b = new Vector2d (4, 5);
433 Vector2d c = Vector2d.InterleaveHigh (a, b);
441 public static unsafe int test_0_vector2d_addsub () {
442 Vector2d a = new Vector2d (1, 2);
443 Vector2d b = new Vector2d (4, 1);
445 Vector2d c = Vector2d.AddSub (a, b);
453 public static unsafe int test_0_vector2d_hsub () {
454 Vector2d a = new Vector2d (1, 2);
455 Vector2d b = new Vector2d (4, 1);
457 Vector2d c = Vector2d.HorizontalSub (a, b);
466 public static unsafe int test_0_vector2d_hadd () {
467 Vector2d a = new Vector2d (1, 2);
468 Vector2d b = new Vector2d (4, 0);
470 Vector2d c = Vector2d.HorizontalAdd (a, b);
479 public static unsafe int test_0_vector2d_min () {
480 Vector2d a = new Vector2d (1, 2);
481 Vector2d b = new Vector2d (4, 0);
483 Vector2d c = Vector2d.Min (a, b);
492 public static unsafe int test_0_vector2d_max () {
493 Vector2d a = new Vector2d (1, 2);
494 Vector2d b = new Vector2d (4, 0);
496 Vector2d c = Vector2d.Max (a, b);
506 public static unsafe int test_0_vector2d_andnot () {
507 Vector2d a = new Vector2d (1, 2);
508 Vector2d b = new Vector2d (3, 4);
510 Vector4ui c = (Vector4ui)Vector2d.AndNot (a, b);
514 if (c.Y != 1074266112)
523 public static unsafe int test_0_vector2d_div () {
524 Vector2d a = new Vector2d (1, 2);
525 Vector2d b = new Vector2d (4, 5);
536 public static unsafe int test_0_vector2d_mul () {
537 Vector2d a = new Vector2d (1, 2);
538 Vector2d b = new Vector2d (3, 5);
548 public static unsafe int test_0_vector2d_sub () {
549 Vector2d a = new Vector2d (1, 2);
550 Vector2d b = new Vector2d (3, 5);
560 public static unsafe int test_0_vector2d_add () {
561 Vector2d a = new Vector2d (1, 2);
562 Vector2d b = new Vector2d (3, 4);
572 public static unsafe int test_0_vector2d_xor () {
573 Vector2d a = new Vector2d (1, 2);
574 Vector2d b = new Vector2d (3, 4);
576 Vector4ui c = (Vector4ui)(a ^ b);
580 if (c.Y != 2146959360)
589 public static unsafe int test_0_vector2d_or () {
590 Vector2d a = new Vector2d (1, 2);
591 Vector2d b = new Vector2d (3, 4);
593 Vector4ui c = (Vector4ui)(a | b);
597 if (c.Y != 2146959360)
601 if (c.W != 1074790400)
606 public static unsafe int test_0_vector2d_and () {
607 Vector2d a = new Vector2d (1, 2);
608 Vector2d b = new Vector2d (3, 4);
610 Vector4ui c = (Vector4ui)(a & b);
618 if (c.W != 1073741824)
623 public static unsafe int test_vector8s_pack_signed_sat () {
624 Vector8s a = new Vector8s (-200, 200, 3, 0, 5, 6, 5, 4);
625 Vector8s b = new Vector8s (9, 2, 1, 2, 3, 6, 5, 6);
627 Vector16sb c = Vector8s.PackWithSignedSaturation (a, b);
637 public static unsafe int test_vector16sb_sub_sat () {
638 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
639 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
641 Vector16sb c = Vector16sb.SubtractWithSaturation (a, b);
662 public static unsafe int test_vector16sb_add_sat () {
663 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
664 Vector16sb b = new Vector16sb (100, -100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
666 Vector16sb c = Vector16sb.AddWithSaturation (a, b);
687 public static unsafe int test_vector16sb_cmp_gt () {
688 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
689 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
691 Vector16sb c = Vector16sb.CompareGreaterThan (a, b);
711 public static int test_0_vector4ui_pack_with_sat () {
712 Vector4ui a = new Vector4ui (0xF0000000,0xF0000,3,4);
713 Vector4ui b = new Vector4ui (5,6,7,8);
715 Vector8us c = Vector4ui.SignedPackWithUnsignedSaturation (a, b);
736 public static int test_0_vector8us_pack_with_sat () {
737 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
738 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
739 Vector16b c = Vector8us.SignedPackWithUnsignedSaturation (a, b);
754 public static int test_0_vector8us_mul_high () {
755 Vector8us a = new Vector8us (0xFF00, 2, 3, 0, 5, 6, 5, 4);
756 Vector8us b = new Vector8us (0xFF00, 2, 1, 2, 3, 6, 5, 6);
757 Vector8us c = Vector8us.MultiplyStoreHigh (a, b);
778 public static int test_0_vector8us_cmpeq () {
779 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
780 Vector8us b = new Vector8us (9, 2, 1, 2, 3, 6, 5, 6);
781 Vector8us c = Vector8us.CompareEqual (a, b);
803 public static int test_0_vector4ui_cmpeq () {
804 Vector4ui a = new Vector4ui (6,1,6,3);
805 Vector4ui b = new Vector4ui (3,4,6,7);
806 Vector4ui c = Vector4ui.CompareEqual (a, b);
812 if (c.Z != 0xFFFFFFFF)
819 public static int test_0_vector4ui_shuffle () {
820 Vector4ui a = new Vector4ui (1,2,3,4);
821 Vector4ui c = Vector4ui.Shuffle (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
834 public static int test_0_vector4ui_extract_mask () {
835 Vector4ui a = new Vector4ui (0xFF00FF00,0x0F0FAA99,0,0);
836 int c = Vector4ui.ExtractByteMask (a);
843 public static int test_0_vector4ui_min () {
844 Vector4ui a = new Vector4ui (6,1,6,3);
845 Vector4ui b = new Vector4ui (3,4,6,7);
846 Vector4ui c = Vector4ui.Min (a, b);
859 public static int test_0_vector4ui_max () {
860 Vector4ui a = new Vector4ui (6,1,6,3);
861 Vector4ui b = new Vector4ui (3,4,6,7);
862 Vector4ui c = Vector4ui.Max (a, b);
875 public static int vector16b_cmpeq () {
876 Vector16b a = new Vector16b (1,0,9,0,0,0,0,0,0,0,0,0,0,0,0,1);
877 Vector16b b = new Vector16b (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
878 Vector16b c = Vector16b.CompareEqual (a, b);
916 public static int vector16b_sum_abs_diff () {
917 Vector16b a = new Vector16b (100,20,20,20,0,0,0,0,0,0,0,0,0,0, 0, 0);
918 Vector16sb b = new Vector16sb (0, 10,10,10,0,0,0,0,0,0,0,0,0,0,10,10);
919 Vector8us c = Vector16b.SumOfAbsoluteDifferences (a, b);
941 public static int test_0_vector16b_extract_mask () {
942 Vector16b a = new Vector16b (0xF0,0,0xF0,0,0,0,0xF0,0xAA,0x0F,0,0xFF,0,0,0,0,0);
943 int c = Vector16b.ExtractByteMask (a);
950 public static int test_0_vector16b_min () {
951 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
952 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
953 Vector16b c = Vector16b.Min (a, b);
990 public static int test_0_vector16b_max () {
991 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
992 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
993 Vector16b c = Vector16b.Max (a, b);
1029 public static int test_0_vector16b_avg () {
1030 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1031 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1032 Vector16b c = Vector16b.Average (a, b);
1070 static unsafe Vector8us bad_method_regression_2 (Vector16b va, Vector16b vb) {
1071 Vector8us res = new Vector8us ();
1072 byte *a = (byte*)&va;
1073 byte *b = (byte*)&vb;
1076 for (int i = 0; i < 8; ++i)
1077 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
1078 res.V0 = (ushort)tmp;
1081 for (int i = 0; i < 8; ++i)
1082 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
1083 res.V4 = (ushort)tmp;
1087 /*This bug was caused the simplifier not taking notice of LDADDR on the remaining blocks.*/
1088 public static int test_2_local_simplifier_regression_other_blocks () {
1089 Vector16b a = new Vector16b (1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
1090 Vector16b b = new Vector16b (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
1091 Vector8us res = bad_method_regression_2 (a,b);
1092 return (int)res.V0 + res.V4;
1095 static unsafe Vector8us bad_method_regression (Vector16b va, Vector16b vb) {
1096 Vector8us res = new Vector8us ();
1097 byte *a = (byte*)&va;
1098 byte *b = (byte*)&vb;
1099 *((ushort*)&res) = 10;
1110 /*This bug was caused the simplifier not taking notice of LDADDR on the first block.*/
1111 public static int test_10_local_simplifier_regression_first_block () {
1112 Vector16b a = new Vector16b ();
1113 Vector16b b = new Vector16b ();
1114 Vector8us res = bad_method_regression (a,b);
1119 public static int test_0_vecto8us_extract_mask () {
1120 Vector8us a = new Vector8us (0xF0F0, 0x700F, 0xAABB, 0x0000, 0x00F0, 0xF0F0, 0, 0);
1121 int c = Vector8us.ExtractByteMask (a);
1128 public static int test_0_vecto8us_shuffle_low () {
1129 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1130 Vector8us c = Vector8us.ShuffleLow (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1151 public static int test_0_vecto8us_shuffle_high () {
1152 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1153 Vector8us c = Vector8us.ShuffleHigh (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1175 public static int test_0_vecto8us_max () {
1176 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1177 Vector8us b = new Vector8us (9, 1, 1, 2, 9, 6, 5, 1000);
1178 Vector8us c = Vector8us.Max (a, b);
1200 public static int test_0_vecto8us_min () {
1201 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
1202 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1203 Vector8us c = Vector8us.Min (a, b);
1224 public static int test_0_vecto8us_avg () {
1225 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1226 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1227 Vector8us c = Vector8us.Average (a, b);
1248 static void store_helper (ref Vector4f x) {
1250 k = new Vector4f(9,9,9,9);
1254 public static int test_0_vector4f_byref_store ()
1257 k = new Vector4f(1,2,3,4);
1258 store_helper (ref k);
1264 public static int test_0_vector4f_init_array_element ()
1266 Vector4f[] v = new Vector4f[1];
1267 v[0] = new Vector4f(9,9,9,9);
1273 public static int test_0_vector4f_dup_high () {
1274 Vector4f a = new Vector4f (1, 2, 3, 4);
1275 Vector4f c = Vector4f.DuplicateHigh(a);
1288 public static int test_0_vector4f_dup_low () {
1289 Vector4f a = new Vector4f (1, 2, 3, 4);
1290 Vector4f c = Vector4f.DuplicateLow (a);
1304 public static int test_0_vector4f_interleave_high () {
1305 Vector4f a = new Vector4f (1, 2, 3, 4);
1306 Vector4f b = new Vector4f (5, 6, 7, 8);
1307 Vector4f c = Vector4f.InterleaveHigh (a, b);
1320 public static int test_0_vector4f_interleave_low () {
1321 Vector4f a = new Vector4f (1, 2, 3, 4);
1322 Vector4f b = new Vector4f (5, 6, 7, 8);
1323 Vector4f c = Vector4f.InterleaveLow (a, b);
1336 public static int test_0_vector4f_rcp () {
1337 Vector4f a = new Vector4f (1, 2, 4, 8);
1338 Vector4f c = Vector4f.Reciprocal (a);
1340 //Test with ranges due to the terrible precision.
1341 if (c.X < (1 - 0.01f) || c.X > (1 + 0.01f))
1343 if (c.Y < (0.5 - 0.01f) || c.Y > (0.5 + 0.01f))
1345 if (c.Z < (0.25 - 0.01f) || c.Z > (0.25 + 0.01f))
1347 if (c.W < (0.125 - 0.01f) || c.W > (0.125 + 0.01f))
1352 public static int test_0_vector4f_xor () {
1353 Vector4f a = new Vector4f (1, 2, 3, 4);
1354 Vector4f b = new Vector4f (1, 3, 3, 8);
1357 if (((Vector4ui)c).X != 0)
1359 if (((Vector4ui)c).Y != 0x400000)
1361 if (((Vector4ui)c).Z != 0)
1363 if (((Vector4ui)c).W != 0x1800000)
1368 public static int test_0_vector4f_or () {
1369 Vector4f a = new Vector4f (1, 2, 3, 4);
1370 Vector4f b = new Vector4f (1, 3, 3, 8);
1373 if (((Vector4ui)c).X != 0x3F800000)
1375 if (((Vector4ui)c).Y != 0x40400000)
1377 if (((Vector4ui)c).Z != 0x40400000)
1379 if (((Vector4ui)c).W != 0x41800000)
1383 public static int test_0_vector4f_andn () {
1384 Vector4f a = new Vector4f (1, 2, 3, 4);
1385 Vector4f b = new Vector4f (1, 3, 3, 8);
1386 Vector4f c = Vector4f.AndNot (a ,b);
1388 if (((Vector4ui)c).X != 0)
1390 if (((Vector4ui)c).Y != 0x400000)
1392 if (((Vector4ui)c).Z != 0)
1394 if (((Vector4ui)c).W != 0x1000000)
1399 public static int test_0_vector4f_and () {
1400 Vector4f a = new Vector4f (1, 2, 3, 4);
1401 Vector4f b = new Vector4f (1, 3, 3, 8);
1404 if (((Vector4ui)c).X != 0x3F800000)
1406 if (((Vector4ui)c).Y != 0x40000000)
1408 if (((Vector4ui)c).Z != 0x40400000)
1410 if (((Vector4ui)c).W != 0x40000000)
1415 public static int test_0_vector4f_cmpord () {
1416 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1417 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1418 Vector4f c = Vector4f.CompareOrdered (a, b);
1420 if (((Vector4ui)c).X != 0)
1422 if (((Vector4ui)c).Y != 0)
1424 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1426 if (((Vector4ui)c).W != 0xFFFFFFFF)
1431 public static int test_0_vector4f_cmpnle () {
1432 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1433 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1434 Vector4f c = Vector4f.CompareNotLessEqual (a, b);
1436 if (((Vector4ui)c).X != 0xFFFFFFFF)
1438 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1440 if (((Vector4ui)c).Z != 0)
1442 if (((Vector4ui)c).W != 0)
1447 public static int test_0_vector4f_cmpnlt () {
1448 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1449 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1450 Vector4f c = Vector4f.CompareNotLessThan (a, b);
1452 if (((Vector4ui)c).X != 0xFFFFFFFF)
1454 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1456 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1458 if (((Vector4ui)c).W != 0)
1463 public static int test_0_vector4f_cmpneq () {
1464 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1465 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1466 Vector4f c = Vector4f.CompareNotEqual (a, b);
1468 if (((Vector4ui)c).X != 0xFFFFFFFF)
1470 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1472 if (((Vector4ui)c).Z != 0)
1474 if (((Vector4ui)c).W != 0xFFFFFFFF)
1479 public static int test_0_vector4f_cmpunord () {
1480 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1481 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1482 Vector4f c = Vector4f.CompareUnordered (a, b);
1484 if (((Vector4ui)c).X != 0xFFFFFFFF)
1486 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1488 if (((Vector4ui)c).Z != 0)
1490 if (((Vector4ui)c).W != 0)
1495 public static int test_0_vector4f_cmple () {
1496 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1497 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1498 Vector4f c = Vector4f.CompareLessEqual (a, b);
1500 if (((Vector4ui)c).X != 0)
1502 if (((Vector4ui)c).Y != 0)
1504 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1506 if (((Vector4ui)c).W != 0xFFFFFFFF)
1511 public static int test_0_vector4f_cmplt () {
1512 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1513 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1514 Vector4f c = Vector4f.CompareLessThan (a, b);
1516 if (((Vector4ui)c).X != 0)
1518 if (((Vector4ui)c).Y != 0)
1520 if (((Vector4ui)c).Z != 0)
1522 if (((Vector4ui)c).W != 0xFFFFFFFF)
1527 public static int test_0_vector4f_cmpeq () {
1528 Vector4f a = new Vector4f (float.NaN, 2, 3, 6);
1529 Vector4f b = new Vector4f (1, float.NaN, 3, 4);
1530 Vector4f c = Vector4f.CompareEqual (a, b);
1532 if (((Vector4ui)c).X != 0)
1534 if (((Vector4ui)c).Y != 0)
1536 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1538 if (((Vector4ui)c).W != 0)
1543 public static int test_0_vector4ui_sar () {
1544 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1546 Vector4ui c = Vector4ui.ArithmeticRightShift (a, 2);
1548 if (c.X != 0xFC000000)
1559 public static int test_0_vector4ui_unpack_high () {
1560 Vector4ui a = new Vector4ui (1,2,3,4);
1561 Vector4ui b = new Vector4ui (5,6,7,8);
1563 Vector4ui c = Vector4ui.UnpackHigh(a, b);
1576 public static int test_0_vector4ui_unpack_low () {
1577 Vector4ui a = new Vector4ui (1,2,3,4);
1578 Vector4ui b = new Vector4ui (5,6,7,8);
1580 Vector4ui c = Vector4ui.UnpackLow (a, b);
1593 public static int test_0_vector4ui_xor () {
1594 Vector4ui a = new Vector4ui (1,2,3,4);
1595 Vector4ui b = new Vector4ui (7,5,3,1);
1597 Vector4ui c = a ^ b;
1610 public static int test_0_vector4ui_or () {
1611 Vector4ui a = new Vector4ui (1,2,3,4);
1612 Vector4ui b = new Vector4ui (7,5,3,1);
1614 Vector4ui c = a | b;
1626 public static int test_0_vector4ui_and () {
1627 Vector4ui a = new Vector4ui (1,2,3,4);
1628 Vector4ui b = new Vector4ui (7,5,3,1);
1630 Vector4ui c = a & b;
1643 public static int test_0_vector4ui_shr () {
1644 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1646 Vector4ui c = a >> 2;
1648 if (c.X != 0x3C000000)
1659 public static int test_0_vector4ui_shl () {
1660 Vector4ui a = new Vector4ui (10,20,3,40);
1662 Vector4ui c = a << 2;
1675 public static int test_0_vector4ui_mul () {
1676 Vector4ui a = new Vector4ui (0x8888,20,3,40);
1677 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1679 Vector4ui c = a * b;
1681 if (c.X != 0xffff7800)
1691 public static int test_0_vector4ui_sub () {
1692 Vector4ui a = new Vector4ui (1,20,3,40);
1693 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1695 Vector4ui c = a - b;
1697 if (c.X != 0xff0101)
1708 public static int test_0_vector4ui_add () {
1709 Vector4ui a = new Vector4ui (0xFF00FF00u,2,3,4);
1710 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1712 Vector4ui c = a + b;
1714 if (c.X != 0xfe01fe00)
1726 static int test_0_vector4ui_accessors () {
1727 Vector4ui a = new Vector4ui (1,2,3,4);
1753 static int test_0_vector8us_sub_sat () {
1754 Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
1755 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1756 Vector8us c = Vector8us.SubtractWithSaturation (a, b);
1777 static int test_0_vector8us_add_sat () {
1778 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1779 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1780 Vector8us c = Vector8us.AddWithSaturation (a, b);
1801 static int test_0_vector8us_unpack_low () {
1802 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1803 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
1804 Vector8us c = Vector8us.UnpackLow (a, b);
1826 static int test_0_vector8us_shift_left () {
1827 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1829 Vector8us c = a << amt;
1840 static int test_0_vector8us_shift_right_arithmetic () {
1841 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1843 Vector8us c = Vector8us.ArithmeticRightShift (a, amt);
1854 static int test_0_vector8us_shift_variable_offset () {
1856 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1858 Vector8us c = b >> off;
1875 static int test_0_vector8us_shift_operand_is_live_after_op () {
1876 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1878 Vector8us c = b >> 2;
1894 static int test_0_vector8us_shr_constant () {
1895 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1896 Vector8us c = a >> 2;
1907 static int test_0_vector8us_mul () {
1908 Vector8us a = new Vector8us (0x0F00,4,5,6,7,8,9,10);
1909 Vector8us b = new Vector8us (0x0888,1,2,3,4,5,6,8);
1911 Vector8us c = a * b;
1921 static int test_0_vector8us_add () {
1922 Vector8us a = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1923 Vector8us b = new Vector8us (0x8888,1,2,3,4,5,6,8);
1925 Vector8us c = a + b;
1936 static int test_0_vector8us_sub () {
1937 Vector8us a = new Vector8us (3,4,5,6,7,8,9,10);
1938 Vector8us b = new Vector8us (10,1,2,3,4,5,6,8);
1940 Vector8us c = a - b;
1952 static int test_0_vector8us_accessors () {
1953 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
2001 static int test_0_vector16b_unpack_high () {
2002 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2003 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2004 Vector16b c = Vector16b.UnpackHigh (a, b);
2025 static int test_0_vector16b_unpack_low () {
2026 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2027 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2028 Vector16b c = Vector16b.UnpackLow (a, b);
2049 static int test_0_vector16b_sub_sat () {
2050 Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2051 Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2052 Vector16b c = Vector16b.SubtractWithSaturation (a, b);
2063 static int test_0_vector16b_add_sat () {
2064 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2065 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2066 Vector16b c = Vector16b.AddWithSaturation (a, b);
2077 static int test_0_vector16b_add_ovf () {
2078 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2079 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2080 Vector16b c = a + b;
2091 static int test_0_vector16b_accessors () {
2092 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2179 public static int test_0_accessors () {
2180 Vector4f a = new Vector4f (1, 2, 3, 4);
2192 public static int test_0_packed_add_with_stack_tmp () {
2193 Vector4f a = new Vector4f (1, 2, 3, 4);
2194 Vector4f b = new Vector4f (5, 6, 7, 8);
2195 Vector4f c = new Vector4f (-1, -3, -4, -5);
2196 Vector4f d = a + b + c;
2208 public static int test_0_simple_packed_add () {
2209 Vector4f a = new Vector4f (1, 2, 3, 4);
2210 Vector4f b = new Vector4f (5, 6, 7, 8);
2224 public static int test_0_simple_packed_sub () {
2225 Vector4f a = new Vector4f (1, 2, 3, 4);
2226 Vector4f b = new Vector4f (5, 6, 7, 8);
2239 public static int test_0_simple_packed_mul () {
2240 Vector4f a = new Vector4f (1, 2, 3, 4);
2241 Vector4f b = new Vector4f (5, 6, 7, 8);
2254 public static int test_0_simple_packed_div () {
2255 Vector4f a = new Vector4f (2, 2, 3, 4);
2256 Vector4f b = new Vector4f (20, 10, 33, 12);
2269 public static int test_0_simple_packed_sqrt () {
2270 Vector4f a = new Vector4f (16, 4, 9, 25);
2271 a = Vector4f.Sqrt (a);
2283 public static int test_0_simple_packed_invsqrt () {
2284 Vector4f a = new Vector4f (16, 4, 100, 25);
2285 //this function has VERY low precision
2286 a = Vector4f.InvSqrt (a);
2287 if (a.X < (1/4f - 0.01f) || a.X > (1/4f + 0.01f))
2289 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
2291 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
2293 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
2298 public static int test_0_simple_packed_min () {
2299 Vector4f a = new Vector4f (16, -4, 9, 25);
2300 Vector4f b = new Vector4f (5, 3, 9, 0);
2301 Vector4f c = Vector4f.Min (a, b);
2313 public static int test_0_simple_packed_max () {
2314 Vector4f a = new Vector4f (16, -4, 9, 25);
2315 Vector4f b = new Vector4f (5, 3, 9, 0);
2316 Vector4f c = Vector4f.Max (a, b);
2328 public static int test_0_simple_packed_hadd () {
2329 Vector4f a = new Vector4f (5, 5, 6, 6);
2330 Vector4f b = new Vector4f (7, 7, 8, 8);
2331 Vector4f c = Vector4f.HorizontalAdd (a, b);
2343 public static int test_0_simple_packed_hsub () {
2344 Vector4f a = new Vector4f (5, 2, 6, 1);
2345 Vector4f b = new Vector4f (7, 0, 8, 3);
2346 Vector4f c = Vector4f.HorizontalSub (a, b);
2358 public static int test_0_simple_packed_addsub () {
2359 Vector4f a = new Vector4f (5, 2, 6, 1);
2360 Vector4f b = new Vector4f (7, 0, 8, 3);
2361 Vector4f c = Vector4f.AddSub (a, b);
2373 public static int test_0_simple_packed_shuffle () {
2374 Vector4f a = new Vector4f (1, 2, 3, 4);
2375 a = Vector4f.Shuffle(a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2387 public static int test_0_packed_shuffle_with_reg_pressure () {
2388 Vector4f v = new Vector4f (1, 2, 3, 4);
2389 Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
2390 if (ff) v = v + v -v ;
2392 Vector4f r0 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2393 Vector4f r1 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2394 Vector4f x = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2395 Vector4f r2 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2396 Vector4f r3 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2404 Vector4f result = r0 + r1 + r2 + r3;
2414 if (result.Y != result.Y)
2419 public static int test_24_regs_pressure_a () {
2420 Vector4f a = new Vector4f (1, 2, 3, 4);
2428 public static int test_54_regs_pressure_b () {
2429 Vector4f a = new Vector4f (1, 2, 3, 4);
2433 Vector4f e = a + b + c;
2434 Vector4f f = d - b + a - c;
2435 Vector4f g = a - d * f - c + b;
2436 Vector4f h = a * b - c + e;
2437 Vector4f i = h - g - f - e - d - c - b - a;
2438 Vector4f j = a + b + c + d + e + f + g + h + i;
2443 public static int test_3_single_block_var_is_properly_promoted () {
2444 Vector4f a = new Vector4f (4, 5, 6, 7);
2448 Vector4f b = new Vector4f (1, 2, 3, 4);
2459 static float float_val = 45f;
2461 public static int test_0_sse2_opt_and_simd_intrinsic_proper_regalloc () {
2462 Vector4f v = new Vector4f (1, 2, 3, 4);
2463 float f = float_val;
2472 public static int Main () {
2473 return TestDriver.RunTests (typeof (SimdTests));