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);
511 Vector4ui ta = (Vector4ui)a;
512 Vector4ui tb = (Vector4ui)b;
514 if (c.X != (~ta.X & tb.X))
516 if (c.Y != (~ta.Y & tb.Y))
518 if (c.Z != (~ta.Z & tb.Z))
520 if (c.W != (~ta.W & tb.W))
525 public static unsafe int test_0_vector2d_div () {
526 Vector2d a = new Vector2d (1, 2);
527 Vector2d b = new Vector2d (4, 5);
538 public static unsafe int test_0_vector2d_mul () {
539 Vector2d a = new Vector2d (1, 2);
540 Vector2d b = new Vector2d (3, 5);
550 public static unsafe int test_0_vector2d_sub () {
551 Vector2d a = new Vector2d (1, 2);
552 Vector2d b = new Vector2d (3, 5);
562 public static unsafe int test_0_vector2d_add () {
563 Vector2d a = new Vector2d (1, 2);
564 Vector2d b = new Vector2d (3, 4);
574 public static unsafe int test_0_vector2d_xor () {
575 Vector2d a = new Vector2d (1, 2);
576 Vector2d b = new Vector2d (3, 4);
578 Vector4ui c = (Vector4ui)(a ^ b);
579 Vector4ui ta = (Vector4ui)a;
580 Vector4ui tb = (Vector4ui)b;
582 if (c.X != (ta.X ^ tb.X))
584 if (c.Y != (ta.Y ^ tb.Y))
586 if (c.Z != (ta.Z ^ tb.Z))
588 if (c.W != (ta.W ^ tb.W))
593 public static unsafe int test_0_vector2d_or () {
594 Vector2d a = new Vector2d (1, 2);
595 Vector2d b = new Vector2d (3, 4);
597 Vector4ui c = (Vector4ui)(a | b);
598 Vector4ui ta = (Vector4ui)a;
599 Vector4ui tb = (Vector4ui)b;
601 if (c.X != (ta.X | tb.X))
603 if (c.Y != (ta.Y | tb.Y))
605 if (c.Z != (ta.Z | tb.Z))
607 if (c.W != (ta.W | tb.W))
612 public static unsafe int test_0_vector2d_and () {
613 Vector2d a = new Vector2d (1, 2);
614 Vector2d b = new Vector2d (3, 4);
616 Vector4ui c = (Vector4ui)(a & b);
617 Vector4ui ta = (Vector4ui)a;
618 Vector4ui tb = (Vector4ui)b;
620 if (c.X != (ta.X & tb.X))
622 if (c.Y != (ta.Y & tb.Y))
624 if (c.Z != (ta.Z & tb.Z))
626 if (c.W != (ta.W & tb.W))
631 public static unsafe int test_vector8s_pack_signed_sat () {
632 Vector8s a = new Vector8s (-200, 200, 3, 0, 5, 6, 5, 4);
633 Vector8s b = new Vector8s (9, 2, 1, 2, 3, 6, 5, 6);
635 Vector16sb c = Vector8s.PackWithSignedSaturation (a, b);
645 public static unsafe int test_vector16sb_sub_sat () {
646 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
647 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
649 Vector16sb c = Vector16sb.SubtractWithSaturation (a, b);
670 public static unsafe int test_vector16sb_add_sat () {
671 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
672 Vector16sb b = new Vector16sb (100, -100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
674 Vector16sb c = Vector16sb.AddWithSaturation (a, b);
695 public static unsafe int test_vector16sb_cmp_gt () {
696 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
697 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
699 Vector16sb c = Vector16sb.CompareGreaterThan (a, b);
719 public static int test_0_vector4ui_pack_with_sat () {
720 Vector4ui a = new Vector4ui (0xF0000000,0xF0000,3,4);
721 Vector4ui b = new Vector4ui (5,6,7,8);
723 Vector8us c = Vector4ui.SignedPackWithUnsignedSaturation (a, b);
744 public static int test_0_vector8us_pack_with_sat () {
745 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
746 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
747 Vector16b c = Vector8us.SignedPackWithUnsignedSaturation (a, b);
762 public static int test_0_vector8us_mul_high () {
763 Vector8us a = new Vector8us (0xFF00, 2, 3, 0, 5, 6, 5, 4);
764 Vector8us b = new Vector8us (0xFF00, 2, 1, 2, 3, 6, 5, 6);
765 Vector8us c = Vector8us.MultiplyStoreHigh (a, b);
786 public static int test_0_vector8us_cmpeq () {
787 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
788 Vector8us b = new Vector8us (9, 2, 1, 2, 3, 6, 5, 6);
789 Vector8us c = Vector8us.CompareEqual (a, b);
811 public static int test_0_vector4ui_cmpeq () {
812 Vector4ui a = new Vector4ui (6,1,6,3);
813 Vector4ui b = new Vector4ui (3,4,6,7);
814 Vector4ui c = Vector4ui.CompareEqual (a, b);
820 if (c.Z != 0xFFFFFFFF)
827 public static int test_0_vector4ui_shuffle () {
828 Vector4ui a = new Vector4ui (1,2,3,4);
829 Vector4ui c = Vector4ui.Shuffle (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
842 public static int test_0_vector4ui_min () {
843 Vector4ui a = new Vector4ui (6,1,6,3);
844 Vector4ui b = new Vector4ui (3,4,6,7);
845 Vector4ui c = Vector4ui.Min (a, b);
858 public static int test_0_vector4ui_max () {
859 Vector4ui a = new Vector4ui (6,1,6,3);
860 Vector4ui b = new Vector4ui (3,4,6,7);
861 Vector4ui c = Vector4ui.Max (a, b);
874 public static int vector16b_cmpeq () {
875 Vector16b a = new Vector16b (1,0,9,0,0,0,0,0,0,0,0,0,0,0,0,1);
876 Vector16b b = new Vector16b (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
877 Vector16b c = Vector16b.CompareEqual (a, b);
915 public static int vector16b_sum_abs_diff () {
916 Vector16b a = new Vector16b (100,20,20,20,0,0,0,0,0,0,0,0,0,0, 0, 0);
917 Vector16sb b = new Vector16sb (0, 10,10,10,0,0,0,0,0,0,0,0,0,0,10,10);
918 Vector8us c = Vector16b.SumOfAbsoluteDifferences (a, b);
940 public static int test_0_vector16b_extract_mask () {
941 Vector16b a = new Vector16b (0xF0,0,0xF0,0,0,0,0xF0,0xAA,0x0F,0,0xFF,0,0,0,0,0);
942 int c = Vector16b.ExtractByteMask (a);
949 public static int test_0_vector16b_min () {
950 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
951 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
952 Vector16b c = Vector16b.Min (a, b);
989 public static int test_0_vector16b_max () {
990 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
991 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
992 Vector16b c = Vector16b.Max (a, b);
1028 public static int test_0_vector16b_avg () {
1029 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1030 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1031 Vector16b c = Vector16b.Average (a, b);
1069 static unsafe Vector8us bad_method_regression_2 (Vector16b va, Vector16b vb) {
1070 Vector8us res = new Vector8us ();
1071 byte *a = (byte*)&va;
1072 byte *b = (byte*)&vb;
1075 for (int i = 0; i < 8; ++i)
1076 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
1077 res.V0 = (ushort)tmp;
1080 for (int i = 0; i < 8; ++i)
1081 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
1082 res.V4 = (ushort)tmp;
1086 /*This bug was caused the simplifier not taking notice of LDADDR on the remaining blocks.*/
1087 public static int test_2_local_simplifier_regression_other_blocks () {
1088 Vector16b a = new Vector16b (1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
1089 Vector16b b = new Vector16b (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
1090 Vector8us res = bad_method_regression_2 (a,b);
1091 return (int)res.V0 + res.V4;
1094 static unsafe Vector8us bad_method_regression (Vector16b va, Vector16b vb) {
1095 Vector8us res = new Vector8us ();
1096 byte *a = (byte*)&va;
1097 byte *b = (byte*)&vb;
1098 *((ushort*)&res) = 10;
1109 /*This bug was caused the simplifier not taking notice of LDADDR on the first block.*/
1110 public static int test_10_local_simplifier_regression_first_block () {
1111 Vector16b a = new Vector16b ();
1112 Vector16b b = new Vector16b ();
1113 Vector8us res = bad_method_regression (a,b);
1117 public static int test_0_vecto8us_shuffle_low () {
1118 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1119 Vector8us c = Vector8us.ShuffleLow (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1140 public static int test_0_vecto8us_shuffle_high () {
1141 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1142 Vector8us c = Vector8us.ShuffleHigh (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1164 public static int test_0_vecto8us_max () {
1165 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1166 Vector8us b = new Vector8us (9, 1, 1, 2, 9, 6, 5, 1000);
1167 Vector8us c = Vector8us.Max (a, b);
1189 public static int test_0_vecto8us_min () {
1190 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
1191 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1192 Vector8us c = Vector8us.Min (a, b);
1213 public static int test_0_vecto8us_avg () {
1214 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1215 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1216 Vector8us c = Vector8us.Average (a, b);
1237 static void store_helper (ref Vector4f x) {
1239 k = new Vector4f(9,9,9,9);
1243 public static int test_0_vector4f_byref_store ()
1246 k = new Vector4f(1,2,3,4);
1247 store_helper (ref k);
1253 public static int test_0_vector4f_init_array_element ()
1255 Vector4f[] v = new Vector4f[1];
1256 v[0] = new Vector4f(9,9,9,9);
1262 public static int test_0_vector4f_dup_high () {
1263 Vector4f a = new Vector4f (1, 2, 3, 4);
1264 Vector4f c = Vector4f.DuplicateHigh(a);
1277 public static int test_0_vector4f_dup_low () {
1278 Vector4f a = new Vector4f (1, 2, 3, 4);
1279 Vector4f c = Vector4f.DuplicateLow (a);
1293 public static int test_0_vector4f_interleave_high () {
1294 Vector4f a = new Vector4f (1, 2, 3, 4);
1295 Vector4f b = new Vector4f (5, 6, 7, 8);
1296 Vector4f c = Vector4f.InterleaveHigh (a, b);
1309 public static int test_0_vector4f_interleave_low () {
1310 Vector4f a = new Vector4f (1, 2, 3, 4);
1311 Vector4f b = new Vector4f (5, 6, 7, 8);
1312 Vector4f c = Vector4f.InterleaveLow (a, b);
1325 public static int test_0_vector4f_rcp () {
1326 Vector4f a = new Vector4f (1, 2, 4, 8);
1327 Vector4f c = Vector4f.Reciprocal (a);
1329 //Test with ranges due to the terrible precision.
1330 if (c.X < (1 - 0.01f) || c.X > (1 + 0.01f))
1332 if (c.Y < (0.5 - 0.01f) || c.Y > (0.5 + 0.01f))
1334 if (c.Z < (0.25 - 0.01f) || c.Z > (0.25 + 0.01f))
1336 if (c.W < (0.125 - 0.01f) || c.W > (0.125 + 0.01f))
1341 public static int test_0_vector4f_xor () {
1342 Vector4f a = new Vector4f (1, 2, 3, 4);
1343 Vector4f b = new Vector4f (1, 3, 3, 8);
1346 if (((Vector4ui)c).X != 0)
1348 if (((Vector4ui)c).Y != 0x400000)
1350 if (((Vector4ui)c).Z != 0)
1352 if (((Vector4ui)c).W != 0x1800000)
1357 public static int test_0_vector4f_or () {
1358 Vector4f a = new Vector4f (1, 2, 3, 4);
1359 Vector4f b = new Vector4f (1, 3, 3, 8);
1362 if (((Vector4ui)c).X != 0x3F800000)
1364 if (((Vector4ui)c).Y != 0x40400000)
1366 if (((Vector4ui)c).Z != 0x40400000)
1368 if (((Vector4ui)c).W != 0x41800000)
1372 public static int test_0_vector4f_andn () {
1373 Vector4f a = new Vector4f (1, 2, 3, 4);
1374 Vector4f b = new Vector4f (1, 3, 3, 8);
1375 Vector4f c = Vector4f.AndNot (a ,b);
1377 if (((Vector4ui)c).X != 0)
1379 if (((Vector4ui)c).Y != 0x400000)
1381 if (((Vector4ui)c).Z != 0)
1383 if (((Vector4ui)c).W != 0x1000000)
1388 public static int test_0_vector4f_and () {
1389 Vector4f a = new Vector4f (1, 2, 3, 4);
1390 Vector4f b = new Vector4f (1, 3, 3, 8);
1393 if (((Vector4ui)c).X != 0x3F800000)
1395 if (((Vector4ui)c).Y != 0x40000000)
1397 if (((Vector4ui)c).Z != 0x40400000)
1399 if (((Vector4ui)c).W != 0x40000000)
1404 public static int test_0_vector4f_cmpord () {
1405 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1406 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1407 Vector4f c = Vector4f.CompareOrdered (a, b);
1409 if (((Vector4ui)c).X != 0)
1411 if (((Vector4ui)c).Y != 0)
1413 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1415 if (((Vector4ui)c).W != 0xFFFFFFFF)
1420 public static int test_0_vector4f_cmpnle () {
1421 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1422 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1423 Vector4f c = Vector4f.CompareNotLessEqual (a, b);
1425 if (((Vector4ui)c).X != 0xFFFFFFFF)
1427 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1429 if (((Vector4ui)c).Z != 0)
1431 if (((Vector4ui)c).W != 0)
1436 public static int test_0_vector4f_cmpnlt () {
1437 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1438 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1439 Vector4f c = Vector4f.CompareNotLessThan (a, b);
1441 if (((Vector4ui)c).X != 0xFFFFFFFF)
1443 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1445 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1447 if (((Vector4ui)c).W != 0)
1452 public static int test_0_vector4f_cmpneq () {
1453 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1454 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1455 Vector4f c = Vector4f.CompareNotEqual (a, b);
1457 if (((Vector4ui)c).X != 0xFFFFFFFF)
1459 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1461 if (((Vector4ui)c).Z != 0)
1463 if (((Vector4ui)c).W != 0xFFFFFFFF)
1468 public static int test_0_vector4f_cmpunord () {
1469 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1470 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1471 Vector4f c = Vector4f.CompareUnordered (a, b);
1473 if (((Vector4ui)c).X != 0xFFFFFFFF)
1475 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1477 if (((Vector4ui)c).Z != 0)
1479 if (((Vector4ui)c).W != 0)
1484 public static int test_0_vector4f_cmple () {
1485 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1486 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1487 Vector4f c = Vector4f.CompareLessEqual (a, b);
1489 if (((Vector4ui)c).X != 0)
1491 if (((Vector4ui)c).Y != 0)
1493 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1495 if (((Vector4ui)c).W != 0xFFFFFFFF)
1500 public static int test_0_vector4f_cmplt () {
1501 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1502 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1503 Vector4f c = Vector4f.CompareLessThan (a, b);
1505 if (((Vector4ui)c).X != 0)
1507 if (((Vector4ui)c).Y != 0)
1509 if (((Vector4ui)c).Z != 0)
1511 if (((Vector4ui)c).W != 0xFFFFFFFF)
1516 public static int test_0_vector4f_cmpeq () {
1517 Vector4f a = new Vector4f (float.NaN, 2, 3, 6);
1518 Vector4f b = new Vector4f (1, float.NaN, 3, 4);
1519 Vector4f c = Vector4f.CompareEqual (a, b);
1521 if (((Vector4ui)c).X != 0)
1523 if (((Vector4ui)c).Y != 0)
1525 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1527 if (((Vector4ui)c).W != 0)
1532 public static int test_0_vector4ui_sar () {
1533 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1535 Vector4ui c = Vector4ui.ArithmeticRightShift (a, 2);
1537 if (c.X != 0xFC000000)
1548 public static int test_0_vector4ui_unpack_high () {
1549 Vector4ui a = new Vector4ui (1,2,3,4);
1550 Vector4ui b = new Vector4ui (5,6,7,8);
1552 Vector4ui c = Vector4ui.UnpackHigh(a, b);
1565 public static int test_0_vector4ui_unpack_low () {
1566 Vector4ui a = new Vector4ui (1,2,3,4);
1567 Vector4ui b = new Vector4ui (5,6,7,8);
1569 Vector4ui c = Vector4ui.UnpackLow (a, b);
1582 public static int test_0_vector4ui_xor () {
1583 Vector4ui a = new Vector4ui (1,2,3,4);
1584 Vector4ui b = new Vector4ui (7,5,3,1);
1586 Vector4ui c = a ^ b;
1599 public static int test_0_vector4ui_or () {
1600 Vector4ui a = new Vector4ui (1,2,3,4);
1601 Vector4ui b = new Vector4ui (7,5,3,1);
1603 Vector4ui c = a | b;
1615 public static int test_0_vector4ui_and () {
1616 Vector4ui a = new Vector4ui (1,2,3,4);
1617 Vector4ui b = new Vector4ui (7,5,3,1);
1619 Vector4ui c = a & b;
1632 public static int test_0_vector4ui_shr () {
1633 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1635 Vector4ui c = a >> 2;
1637 if (c.X != 0x3C000000)
1648 public static int test_0_vector4ui_shl () {
1649 Vector4ui a = new Vector4ui (10,20,3,40);
1651 Vector4ui c = a << 2;
1664 public static int test_0_vector4ui_mul () {
1665 Vector4ui a = new Vector4ui (0x8888,20,3,40);
1666 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1668 Vector4ui c = a * b;
1670 if (c.X != 0xffff7800)
1680 public static int test_0_vector4ui_sub () {
1681 Vector4ui a = new Vector4ui (1,20,3,40);
1682 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1684 Vector4ui c = a - b;
1686 if (c.X != 0xff0101)
1697 public static int test_0_vector4ui_add () {
1698 Vector4ui a = new Vector4ui (0xFF00FF00u,2,3,4);
1699 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1701 Vector4ui c = a + b;
1703 if (c.X != 0xfe01fe00)
1715 static int test_0_vector4ui_accessors () {
1716 Vector4ui a = new Vector4ui (1,2,3,4);
1742 static int test_0_vector8us_sub_sat () {
1743 Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
1744 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1745 Vector8us c = Vector8us.SubtractWithSaturation (a, b);
1766 static int test_0_vector8us_add_sat () {
1767 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1768 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1769 Vector8us c = Vector8us.AddWithSaturation (a, b);
1790 static int test_0_vector8us_unpack_low () {
1791 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1792 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
1793 Vector8us c = Vector8us.UnpackLow (a, b);
1815 static int test_0_vector8us_shift_left () {
1816 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1818 Vector8us c = a << amt;
1829 static int test_0_vector8us_shift_right_arithmetic () {
1830 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1832 Vector8us c = Vector8us.ArithmeticRightShift (a, amt);
1843 static int test_0_vector8us_shift_variable_offset () {
1845 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1847 Vector8us c = b >> off;
1864 static int test_0_vector8us_shift_operand_is_live_after_op () {
1865 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1867 Vector8us c = b >> 2;
1883 static int test_0_vector8us_shr_constant () {
1884 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1885 Vector8us c = a >> 2;
1896 static int test_0_vector8us_mul () {
1897 Vector8us a = new Vector8us (0x0F00,4,5,6,7,8,9,10);
1898 Vector8us b = new Vector8us (0x0888,1,2,3,4,5,6,8);
1900 Vector8us c = a * b;
1910 static int test_0_vector8us_add () {
1911 Vector8us a = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1912 Vector8us b = new Vector8us (0x8888,1,2,3,4,5,6,8);
1914 Vector8us c = a + b;
1925 static int test_0_vector8us_sub () {
1926 Vector8us a = new Vector8us (3,4,5,6,7,8,9,10);
1927 Vector8us b = new Vector8us (10,1,2,3,4,5,6,8);
1929 Vector8us c = a - b;
1941 static int test_0_vector8us_accessors () {
1942 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1990 static int test_0_vector16b_unpack_high () {
1991 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1992 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1993 Vector16b c = Vector16b.UnpackHigh (a, b);
2014 static int test_0_vector16b_unpack_low () {
2015 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2016 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2017 Vector16b c = Vector16b.UnpackLow (a, b);
2038 static int test_0_vector16b_sub_sat () {
2039 Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2040 Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2041 Vector16b c = Vector16b.SubtractWithSaturation (a, b);
2052 static int test_0_vector16b_add_sat () {
2053 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2054 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2055 Vector16b c = Vector16b.AddWithSaturation (a, b);
2066 static int test_0_vector16b_add_ovf () {
2067 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2068 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2069 Vector16b c = a + b;
2080 static int test_0_vector16b_accessors () {
2081 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2168 public static int test_0_accessors () {
2169 Vector4f a = new Vector4f (1, 2, 3, 4);
2181 public static int test_0_packed_add_with_stack_tmp () {
2182 Vector4f a = new Vector4f (1, 2, 3, 4);
2183 Vector4f b = new Vector4f (5, 6, 7, 8);
2184 Vector4f c = new Vector4f (-1, -3, -4, -5);
2185 Vector4f d = a + b + c;
2197 public static int test_0_simple_packed_add () {
2198 Vector4f a = new Vector4f (1, 2, 3, 4);
2199 Vector4f b = new Vector4f (5, 6, 7, 8);
2213 public static int test_0_simple_packed_sub () {
2214 Vector4f a = new Vector4f (1, 2, 3, 4);
2215 Vector4f b = new Vector4f (5, 6, 7, 8);
2228 public static int test_0_simple_packed_mul () {
2229 Vector4f a = new Vector4f (1, 2, 3, 4);
2230 Vector4f b = new Vector4f (5, 6, 7, 8);
2243 public static int test_0_simple_packed_div () {
2244 Vector4f a = new Vector4f (2, 2, 3, 4);
2245 Vector4f b = new Vector4f (20, 10, 33, 12);
2258 public static int test_0_simple_packed_sqrt () {
2259 Vector4f a = new Vector4f (16, 4, 9, 25);
2260 a = Vector4f.Sqrt (a);
2272 public static int test_0_simple_packed_invsqrt () {
2273 Vector4f a = new Vector4f (16, 4, 100, 25);
2274 //this function has VERY low precision
2275 a = Vector4f.InvSqrt (a);
2276 if (a.X < (1/4f - 0.01f) || a.X > (1/4f + 0.01f))
2278 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
2280 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
2282 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
2287 public static int test_0_simple_packed_min () {
2288 Vector4f a = new Vector4f (16, -4, 9, 25);
2289 Vector4f b = new Vector4f (5, 3, 9, 0);
2290 Vector4f c = Vector4f.Min (a, b);
2302 public static int test_0_simple_packed_max () {
2303 Vector4f a = new Vector4f (16, -4, 9, 25);
2304 Vector4f b = new Vector4f (5, 3, 9, 0);
2305 Vector4f c = Vector4f.Max (a, b);
2317 public static int test_0_simple_packed_hadd () {
2318 Vector4f a = new Vector4f (5, 5, 6, 6);
2319 Vector4f b = new Vector4f (7, 7, 8, 8);
2320 Vector4f c = Vector4f.HorizontalAdd (a, b);
2332 public static int test_0_simple_packed_hsub () {
2333 Vector4f a = new Vector4f (5, 2, 6, 1);
2334 Vector4f b = new Vector4f (7, 0, 8, 3);
2335 Vector4f c = Vector4f.HorizontalSub (a, b);
2347 public static int test_0_simple_packed_addsub () {
2348 Vector4f a = new Vector4f (5, 2, 6, 1);
2349 Vector4f b = new Vector4f (7, 0, 8, 3);
2350 Vector4f c = Vector4f.AddSub (a, b);
2362 public static int test_0_simple_packed_shuffle () {
2363 Vector4f a = new Vector4f (1, 2, 3, 4);
2364 a = Vector4f.Shuffle(a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2376 public static int test_0_packed_shuffle_with_reg_pressure () {
2377 Vector4f v = new Vector4f (1, 2, 3, 4);
2378 Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
2379 if (ff) v = v + v -v ;
2381 Vector4f r0 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2382 Vector4f r1 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2383 Vector4f x = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2384 Vector4f r2 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2385 Vector4f r3 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2393 Vector4f result = r0 + r1 + r2 + r3;
2403 if (result.Y != result.Y)
2408 public static int test_24_regs_pressure_a () {
2409 Vector4f a = new Vector4f (1, 2, 3, 4);
2417 public static int test_54_regs_pressure_b () {
2418 Vector4f a = new Vector4f (1, 2, 3, 4);
2422 Vector4f e = a + b + c;
2423 Vector4f f = d - b + a - c;
2424 Vector4f g = a - d * f - c + b;
2425 Vector4f h = a * b - c + e;
2426 Vector4f i = h - g - f - e - d - c - b - a;
2427 Vector4f j = a + b + c + d + e + f + g + h + i;
2432 public static int test_3_single_block_var_is_properly_promoted () {
2433 Vector4f a = new Vector4f (4, 5, 6, 7);
2437 Vector4f b = new Vector4f (1, 2, 3, 4);
2448 static float float_val = 45f;
2450 public static int test_0_sse2_opt_and_simd_intrinsic_proper_regalloc () {
2451 Vector4f v = new Vector4f (1, 2, 3, 4);
2452 float f = float_val;
2461 public static int Main () {
2462 return TestDriver.RunTests (typeof (SimdTests));