4 public class SimdTests {
5 public static int test_0_set_vector4f_operator_neq () {
6 Vector4f a = new Vector4f(1, 2, 3, 4);
7 Vector4f b = new Vector4f(1, 2, 3, 4);
11 a = new Vector4f(1, 2, float.NaN, 4);
12 b = new Vector4f(1, 2, float.NaN, 4);
13 if (!(a != b)) //NaN is always !=
16 a = new Vector4f(1, 2, float.NaN, 4);
17 b = new Vector4f(1, 2, 10, 4);
21 a = new Vector4f(1, 2, float.PositiveInfinity, 4);
22 b = new Vector4f(1, 2, float.PositiveInfinity, 4);
26 a = new Vector4f(1, 2, 20, 4);
27 b = new Vector4f(1, 2, 30, 4);
34 public static int test_0_set_vector4f_operator_eq () {
35 Vector4f a = new Vector4f(1, 2, 3, 4);
36 Vector4f b = new Vector4f(1, 2, 3, 4);
40 a = new Vector4f(1, 2, float.NaN, 4);
41 b = new Vector4f(1, 2, float.NaN, 4);
45 a = new Vector4f(1, 2, 10, 4);
46 b = new Vector4f(1, 2, float.NaN, 4);
50 a = new Vector4f(1, 2, float.PositiveInfinity, 4);
51 b = new Vector4f(1, 2, float.PositiveInfinity, 4);
57 public static int test_1_set_vector4ui_operator_neq () {
58 Vector4ui a = new Vector4ui(1, 2, 3, 4);
59 Vector4ui b = new Vector4ui(1, 2, 3, 4);
65 public static int test_0_set_vector4ui_operator_neq () {
66 Vector4ui a = new Vector4ui(1, 2, 3, 4);
67 Vector4ui b = new Vector4ui(111, 2, 3, 4);
73 public static int test_0_set_vector4ui_operator_eq () {
74 Vector4ui a = new Vector4ui(1, 2, 3, 4);
75 Vector4ui b = new Vector4ui(1, 2, 3, 4);
81 public static int test_1_set_vector4ui_operator_eq () {
82 Vector4ui a = new Vector4ui(1, 2, 3, 4);
83 Vector4ui b = new Vector4ui(111, 2, 3, 4);
89 public static int test_0_set_vector_small_array () {
90 uint[] array = new uint[3];
93 array.SetVector (new Vector4ui (), 0);
95 } catch (IndexOutOfRangeException) {
100 public static int test_0_set_vector_negative_index () {
101 uint[] array = new uint[4];
104 array.SetVector (new Vector4ui (), -1);
106 } catch (IndexOutOfRangeException) {
111 public static int test_0_set_vector_bounds_error () {
112 uint[] array = new uint[4];
115 array.SetVector (new Vector4ui (), 1);
117 } catch (IndexOutOfRangeException) {
122 public static int test_0_set_vector () {
123 uint[] array = new uint[10];
124 Vector4ui a = new Vector4ui (11, 22, 33, 44);
126 array.SetVector (a, 1);
139 public static int test_0_get_vector_small_array () {
140 uint[] array = new uint[3];
143 Vector4ui res = array.GetVector (0);
145 } catch (IndexOutOfRangeException) {
150 public static int test_0_get_vector_negative_index () {
151 uint[] array = new uint[4];
154 Vector4ui res = array.GetVector (-1);
156 } catch (IndexOutOfRangeException) {
161 public static int test_0_get_vector_bounds_error () {
162 uint[] array = new uint[4];
165 Vector4ui res = array.GetVector (1);
167 } catch (IndexOutOfRangeException) {
172 public static int test_0_get_vector () {
173 uint[] array = new uint[] { 11, 22, 33, 44, 55, 66, 77, 88, 99, 111 };
175 Vector4ui res = array.GetVector (1);
189 public static int test_0_accessor_vecto2l () {
190 Vector2l a = new Vector2l (3, 2);
197 a.X = 500000000000055l;
200 if (a.X != 500000000000055l)
202 if (a.Y != -12345678900l)
207 public static int test_0_accessor_vecto2d () {
208 Vector2d a = new Vector2d (3, 2);
218 if (a.X != 5000000000000)
225 public static int test_0_accessor_vecto4f () {
226 Vector4f a = new Vector4f (1,2,3,4);
253 public static int test_0_accessor_vecto4i () {
254 Vector4i a = new Vector4i (0x70000000, -1, 3, 4);
256 if (a.X != 0x70000000)
276 if (a.W != -44444444)
281 public static int test_0_accessor_vecto4ui () {
282 Vector4ui a = new Vector4ui (0xF0000000, 0xF0000, 3, 4);
284 if (a.X != 0xF0000000)
309 static float use_getter_with_byref (ref Vector4f a) {
313 public static int test_0_accessor_and_byref_var () {
314 Vector4f a = new Vector4f (1, 2, 3, 4);
315 if (use_getter_with_byref (ref a) != 4)
320 public static unsafe int test_0_vector2ul_slr () {
321 Vector2ul a = new Vector2ul (1, 6);
323 Vector2ul c = a >> 1;
331 public static unsafe int test_0_vector2l_cmp_gt () {
332 Vector2l a = new Vector2l (10, 5);
333 Vector2l b = new Vector2l (-1, 5);
335 Vector2l c = Vector2l.CompareGreaterThan (a, b);
344 public static unsafe int test_0_vector2l_cmp_eq () {
345 Vector2l a = new Vector2l (0xFF, 5);
346 Vector2l b = new Vector2l (0xFF000000FFL, 5);
348 Vector2l c = Vector2l.CompareEqual (a, b);
357 public static unsafe int test_0_vector2l_srl () {
358 Vector2l a = new Vector2l (1, 6);
360 Vector2l c = Vector2l.LogicalRightShift (a, 1);
369 public static unsafe int test_0_vector2l_unpack_high () {
370 Vector2l a = new Vector2l (1, 6);
371 Vector2l b = new Vector2l (3, 4);
373 Vector2l c = Vector2l.UnpackHigh (a, b);
382 public static unsafe int test_0_vector2l_unpack_low () {
383 Vector2l a = new Vector2l (1, 6);
384 Vector2l b = new Vector2l (3, 4);
386 Vector2l c = Vector2l.UnpackLow (a, b);
395 public static unsafe int test_0_vector2l_xor () {
396 Vector2l a = new Vector2l (1, 6);
397 Vector2l b = new Vector2l (3, 4);
408 public static unsafe int test_0_vector2l_or () {
409 Vector2l a = new Vector2l (1, 6);
410 Vector2l b = new Vector2l (3, 4);
421 public static unsafe int test_0_vector2l_and () {
422 Vector2l a = new Vector2l (1, 6);
423 Vector2l b = new Vector2l (3, 4);
434 public static unsafe int test_0_vector2l_shl() {
435 Vector2l a = new Vector2l (1, 6);
445 public static unsafe int test_0_vector2l_sub() {
446 Vector2l a = new Vector2l (1, 6);
447 Vector2l b = new Vector2l (3, 4);
458 public static unsafe int test_0_vector2l_add () {
459 Vector2l a = new Vector2l (1, 2);
460 Vector2l b = new Vector2l (3, 4);
471 public static unsafe int test_0_vector2d_dup () {
472 Vector2d a = new Vector2d (3, 2);
474 Vector2d c = Vector2d.Duplicate (a);
483 public static unsafe int test_0_vector2d_cmp_eq () {
484 Vector2d a = new Vector2d (3, 2);
485 Vector2d b = new Vector2d (3, 4);
487 Vector4ui c = (Vector4ui)Vector2d.CompareEqual (a, b);
489 if (c.X != 0xFFFFFFFF)
491 if (c.Y != 0xFFFFFFFF)
500 public static unsafe int test_0_vector2d_unpack_low () {
501 Vector2d a = new Vector2d (1, 2);
502 Vector2d b = new Vector2d (4, 5);
504 Vector2d c = Vector2d.InterleaveLow (a, b);
513 public static unsafe int test_0_vector2d_unpack_high () {
514 Vector2d a = new Vector2d (1, 2);
515 Vector2d b = new Vector2d (4, 5);
517 Vector2d c = Vector2d.InterleaveHigh (a, b);
525 public static unsafe int test_0_vector2d_addsub () {
526 Vector2d a = new Vector2d (1, 2);
527 Vector2d b = new Vector2d (4, 1);
529 Vector2d c = Vector2d.AddSub (a, b);
537 public static unsafe int test_0_vector2d_hsub () {
538 Vector2d a = new Vector2d (1, 2);
539 Vector2d b = new Vector2d (4, 1);
541 Vector2d c = Vector2d.HorizontalSub (a, b);
550 public static unsafe int test_0_vector2d_hadd () {
551 Vector2d a = new Vector2d (1, 2);
552 Vector2d b = new Vector2d (4, 0);
554 Vector2d c = Vector2d.HorizontalAdd (a, b);
563 public static unsafe int test_0_vector2d_min () {
564 Vector2d a = new Vector2d (1, 2);
565 Vector2d b = new Vector2d (4, 0);
567 Vector2d c = Vector2d.Min (a, b);
576 public static unsafe int test_0_vector2d_max () {
577 Vector2d a = new Vector2d (1, 2);
578 Vector2d b = new Vector2d (4, 0);
580 Vector2d c = Vector2d.Max (a, b);
590 public static unsafe int test_0_vector2d_andnot () {
591 Vector2d a = new Vector2d (1, 2);
592 Vector2d b = new Vector2d (3, 4);
594 Vector4ui c = (Vector4ui)Vector2d.AndNot (a, b);
595 Vector4ui ta = (Vector4ui)a;
596 Vector4ui tb = (Vector4ui)b;
598 if (c.X != (~ta.X & tb.X))
600 if (c.Y != (~ta.Y & tb.Y))
602 if (c.Z != (~ta.Z & tb.Z))
604 if (c.W != (~ta.W & tb.W))
609 public static unsafe int test_0_vector2d_div () {
610 Vector2d a = new Vector2d (1, 2);
611 Vector2d b = new Vector2d (4, 5);
622 public static unsafe int test_0_vector2d_mul () {
623 Vector2d a = new Vector2d (1, 2);
624 Vector2d b = new Vector2d (3, 5);
634 public static unsafe int test_0_vector2d_sub () {
635 Vector2d a = new Vector2d (1, 2);
636 Vector2d b = new Vector2d (3, 5);
646 public static unsafe int test_0_vector2d_add () {
647 Vector2d a = new Vector2d (1, 2);
648 Vector2d b = new Vector2d (3, 4);
658 public static unsafe int test_0_vector2d_xor () {
659 Vector2d a = new Vector2d (1, 2);
660 Vector2d b = new Vector2d (3, 4);
662 Vector4ui c = (Vector4ui)(a ^ b);
663 Vector4ui ta = (Vector4ui)a;
664 Vector4ui tb = (Vector4ui)b;
666 if (c.X != (ta.X ^ tb.X))
668 if (c.Y != (ta.Y ^ tb.Y))
670 if (c.Z != (ta.Z ^ tb.Z))
672 if (c.W != (ta.W ^ tb.W))
677 public static unsafe int test_0_vector2d_or () {
678 Vector2d a = new Vector2d (1, 2);
679 Vector2d b = new Vector2d (3, 4);
681 Vector4ui c = (Vector4ui)(a | b);
682 Vector4ui ta = (Vector4ui)a;
683 Vector4ui tb = (Vector4ui)b;
685 if (c.X != (ta.X | tb.X))
687 if (c.Y != (ta.Y | tb.Y))
689 if (c.Z != (ta.Z | tb.Z))
691 if (c.W != (ta.W | tb.W))
696 public static unsafe int test_0_vector2d_and () {
697 Vector2d a = new Vector2d (1, 2);
698 Vector2d b = new Vector2d (3, 4);
700 Vector4ui c = (Vector4ui)(a & b);
701 Vector4ui ta = (Vector4ui)a;
702 Vector4ui tb = (Vector4ui)b;
704 if (c.X != (ta.X & tb.X))
706 if (c.Y != (ta.Y & tb.Y))
708 if (c.Z != (ta.Z & tb.Z))
710 if (c.W != (ta.W & tb.W))
715 public static unsafe int test_vector8s_pack_signed_sat () {
716 Vector8s a = new Vector8s (-200, 200, 3, 0, 5, 6, 5, 4);
717 Vector8s b = new Vector8s (9, 2, 1, 2, 3, 6, 5, 6);
719 Vector16sb c = Vector8s.PackWithSignedSaturation (a, b);
729 public static unsafe int test_vector16sb_sub_sat () {
730 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
731 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
733 Vector16sb c = Vector16sb.SubtractWithSaturation (a, b);
754 public static unsafe int test_vector16sb_add_sat () {
755 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
756 Vector16sb b = new Vector16sb (100, -100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
758 Vector16sb c = Vector16sb.AddWithSaturation (a, b);
779 public static unsafe int test_vector16sb_cmp_gt () {
780 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
781 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
783 Vector16sb c = Vector16sb.CompareGreaterThan (a, b);
803 public static int test_0_vector4ui_pack_with_sat () {
804 Vector4ui a = new Vector4ui (0xF0000000,0xF0000,3,4);
805 Vector4ui b = new Vector4ui (5,6,7,8);
807 Vector8us c = Vector4ui.SignedPackWithUnsignedSaturation (a, b);
828 public static int test_0_vector8us_pack_with_sat () {
829 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
830 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
831 Vector16b c = Vector8us.SignedPackWithUnsignedSaturation (a, b);
846 public static int test_0_vector8us_mul_high () {
847 Vector8us a = new Vector8us (0xFF00, 2, 3, 0, 5, 6, 5, 4);
848 Vector8us b = new Vector8us (0xFF00, 2, 1, 2, 3, 6, 5, 6);
849 Vector8us c = Vector8us.MultiplyStoreHigh (a, b);
870 public static int test_0_vector8us_cmpeq () {
871 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
872 Vector8us b = new Vector8us (9, 2, 1, 2, 3, 6, 5, 6);
873 Vector8us c = Vector8us.CompareEqual (a, b);
895 public static int test_0_vector4ui_cmpeq () {
896 Vector4ui a = new Vector4ui (6,1,6,3);
897 Vector4ui b = new Vector4ui (3,4,6,7);
898 Vector4ui c = Vector4ui.CompareEqual (a, b);
904 if (c.Z != 0xFFFFFFFF)
911 public static int test_0_vector4ui_shuffle () {
912 Vector4ui a = new Vector4ui (1,2,3,4);
913 Vector4ui c = Vector4ui.Shuffle (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
926 public static int test_0_vector4ui_min () {
927 Vector4ui a = new Vector4ui (6,1,6,3);
928 Vector4ui b = new Vector4ui (3,4,6,7);
929 Vector4ui c = Vector4ui.Min (a, b);
942 public static int test_0_vector4ui_max () {
943 Vector4ui a = new Vector4ui (6,1,6,3);
944 Vector4ui b = new Vector4ui (3,4,6,7);
945 Vector4ui c = Vector4ui.Max (a, b);
958 public static int vector16b_cmpeq () {
959 Vector16b a = new Vector16b (1,0,9,0,0,0,0,0,0,0,0,0,0,0,0,1);
960 Vector16b b = new Vector16b (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
961 Vector16b c = Vector16b.CompareEqual (a, b);
999 public static int vector16b_sum_abs_diff () {
1000 Vector16b a = new Vector16b (100,20,20,20,0,0,0,0,0,0,0,0,0,0, 0, 0);
1001 Vector16sb b = new Vector16sb (0, 10,10,10,0,0,0,0,0,0,0,0,0,0,10,10);
1002 Vector8us c = Vector16b.SumOfAbsoluteDifferences (a, b);
1024 public static int test_0_vector16b_extract_mask () {
1025 Vector16b a = new Vector16b (0xF0,0,0xF0,0,0,0,0xF0,0xAA,0x0F,0,0xFF,0,0,0,0,0);
1026 int c = Vector16b.ExtractByteMask (a);
1033 public static int test_0_vector16b_min () {
1034 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
1035 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1036 Vector16b c = Vector16b.Min (a, b);
1073 public static int test_0_vector16b_max () {
1074 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
1075 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1076 Vector16b c = Vector16b.Max (a, b);
1112 public static int test_0_vector16b_avg () {
1113 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1114 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1115 Vector16b c = Vector16b.Average (a, b);
1153 static unsafe Vector8us bad_method_regression_2 (Vector16b va, Vector16b vb) {
1154 Vector8us res = new Vector8us ();
1155 byte *a = (byte*)&va;
1156 byte *b = (byte*)&vb;
1159 for (int i = 0; i < 8; ++i)
1160 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
1161 res.V0 = (ushort)tmp;
1164 for (int i = 0; i < 8; ++i)
1165 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
1166 res.V4 = (ushort)tmp;
1170 /*This bug was caused the simplifier not taking notice of LDADDR on the remaining blocks.*/
1171 public static int test_2_local_simplifier_regression_other_blocks () {
1172 Vector16b a = new Vector16b (1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
1173 Vector16b b = new Vector16b (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
1174 Vector8us res = bad_method_regression_2 (a,b);
1175 return (int)res.V0 + res.V4;
1178 static unsafe Vector8us bad_method_regression (Vector16b va, Vector16b vb) {
1179 Vector8us res = new Vector8us ();
1180 byte *a = (byte*)&va;
1181 byte *b = (byte*)&vb;
1182 *((ushort*)&res) = 10;
1193 /*This bug was caused the simplifier not taking notice of LDADDR on the first block.*/
1194 public static int test_10_local_simplifier_regression_first_block () {
1195 Vector16b a = new Vector16b ();
1196 Vector16b b = new Vector16b ();
1197 Vector8us res = bad_method_regression (a,b);
1201 public static int test_0_vecto8us_shuffle_low () {
1202 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1203 Vector8us c = Vector8us.ShuffleLow (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1224 public static int test_0_vecto8us_shuffle_high () {
1225 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1226 Vector8us c = Vector8us.ShuffleHigh (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1248 public static int test_0_vecto8us_max () {
1249 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1250 Vector8us b = new Vector8us (9, 1, 1, 2, 9, 6, 5, 1000);
1251 Vector8us c = Vector8us.Max (a, b);
1273 public static int test_0_vecto8us_min () {
1274 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
1275 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1276 Vector8us c = Vector8us.Min (a, b);
1297 public static int test_0_vecto8us_avg () {
1298 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1299 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1300 Vector8us c = Vector8us.Average (a, b);
1321 static void store_helper (ref Vector4f x) {
1323 k = new Vector4f(9,9,9,9);
1327 public static int test_0_vector4f_byref_store ()
1330 k = new Vector4f(1,2,3,4);
1331 store_helper (ref k);
1337 public static int test_0_vector4f_init_array_element ()
1339 Vector4f[] v = new Vector4f[1];
1340 v[0] = new Vector4f(9,9,9,9);
1346 public static int test_0_vector4f_dup_high () {
1347 Vector4f a = new Vector4f (1, 2, 3, 4);
1348 Vector4f c = Vector4f.DuplicateHigh(a);
1361 public static int test_0_vector4f_dup_low () {
1362 Vector4f a = new Vector4f (1, 2, 3, 4);
1363 Vector4f c = Vector4f.DuplicateLow (a);
1377 public static int test_0_vector4f_interleave_high () {
1378 Vector4f a = new Vector4f (1, 2, 3, 4);
1379 Vector4f b = new Vector4f (5, 6, 7, 8);
1380 Vector4f c = Vector4f.InterleaveHigh (a, b);
1393 public static int test_0_vector4f_interleave_low () {
1394 Vector4f a = new Vector4f (1, 2, 3, 4);
1395 Vector4f b = new Vector4f (5, 6, 7, 8);
1396 Vector4f c = Vector4f.InterleaveLow (a, b);
1409 public static int test_0_vector4f_rcp () {
1410 Vector4f a = new Vector4f (1, 2, 4, 8);
1411 Vector4f c = Vector4f.Reciprocal (a);
1413 //Test with ranges due to the terrible precision.
1414 if (c.X < (1 - 0.01f) || c.X > (1 + 0.01f))
1416 if (c.Y < (0.5 - 0.01f) || c.Y > (0.5 + 0.01f))
1418 if (c.Z < (0.25 - 0.01f) || c.Z > (0.25 + 0.01f))
1420 if (c.W < (0.125 - 0.01f) || c.W > (0.125 + 0.01f))
1425 public static int test_0_vector4f_xor () {
1426 Vector4f a = new Vector4f (1, 2, 3, 4);
1427 Vector4f b = new Vector4f (1, 3, 3, 8);
1430 if (((Vector4ui)c).X != 0)
1432 if (((Vector4ui)c).Y != 0x400000)
1434 if (((Vector4ui)c).Z != 0)
1436 if (((Vector4ui)c).W != 0x1800000)
1441 public static int test_0_vector4f_or () {
1442 Vector4f a = new Vector4f (1, 2, 3, 4);
1443 Vector4f b = new Vector4f (1, 3, 3, 8);
1446 if (((Vector4ui)c).X != 0x3F800000)
1448 if (((Vector4ui)c).Y != 0x40400000)
1450 if (((Vector4ui)c).Z != 0x40400000)
1452 if (((Vector4ui)c).W != 0x41800000)
1456 public static int test_0_vector4f_andn () {
1457 Vector4f a = new Vector4f (1, 2, 3, 4);
1458 Vector4f b = new Vector4f (1, 3, 3, 8);
1459 Vector4f c = Vector4f.AndNot (a ,b);
1461 if (((Vector4ui)c).X != 0)
1463 if (((Vector4ui)c).Y != 0x400000)
1465 if (((Vector4ui)c).Z != 0)
1467 if (((Vector4ui)c).W != 0x1000000)
1472 public static int test_0_vector4f_and () {
1473 Vector4f a = new Vector4f (1, 2, 3, 4);
1474 Vector4f b = new Vector4f (1, 3, 3, 8);
1477 if (((Vector4ui)c).X != 0x3F800000)
1479 if (((Vector4ui)c).Y != 0x40000000)
1481 if (((Vector4ui)c).Z != 0x40400000)
1483 if (((Vector4ui)c).W != 0x40000000)
1488 public static int test_0_vector4f_cmpord () {
1489 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1490 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1491 Vector4f c = Vector4f.CompareOrdered (a, b);
1493 if (((Vector4ui)c).X != 0)
1495 if (((Vector4ui)c).Y != 0)
1497 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1499 if (((Vector4ui)c).W != 0xFFFFFFFF)
1504 public static int test_0_vector4f_cmpnle () {
1505 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1506 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1507 Vector4f c = Vector4f.CompareNotLessEqual (a, b);
1509 if (((Vector4ui)c).X != 0xFFFFFFFF)
1511 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1513 if (((Vector4ui)c).Z != 0)
1515 if (((Vector4ui)c).W != 0)
1520 public static int test_0_vector4f_cmpnlt () {
1521 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1522 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1523 Vector4f c = Vector4f.CompareNotLessThan (a, b);
1525 if (((Vector4ui)c).X != 0xFFFFFFFF)
1527 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1529 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1531 if (((Vector4ui)c).W != 0)
1536 public static int test_0_vector4f_cmpneq () {
1537 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1538 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1539 Vector4f c = Vector4f.CompareNotEqual (a, b);
1541 if (((Vector4ui)c).X != 0xFFFFFFFF)
1543 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1545 if (((Vector4ui)c).Z != 0)
1547 if (((Vector4ui)c).W != 0xFFFFFFFF)
1552 public static int test_0_vector4f_cmpunord () {
1553 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1554 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1555 Vector4f c = Vector4f.CompareUnordered (a, b);
1557 if (((Vector4ui)c).X != 0xFFFFFFFF)
1559 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1561 if (((Vector4ui)c).Z != 0)
1563 if (((Vector4ui)c).W != 0)
1568 public static int test_0_vector4f_cmple () {
1569 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1570 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1571 Vector4f c = Vector4f.CompareLessEqual (a, b);
1573 if (((Vector4ui)c).X != 0)
1575 if (((Vector4ui)c).Y != 0)
1577 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1579 if (((Vector4ui)c).W != 0xFFFFFFFF)
1584 public static int test_0_vector4f_cmplt () {
1585 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1586 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1587 Vector4f c = Vector4f.CompareLessThan (a, b);
1589 if (((Vector4ui)c).X != 0)
1591 if (((Vector4ui)c).Y != 0)
1593 if (((Vector4ui)c).Z != 0)
1595 if (((Vector4ui)c).W != 0xFFFFFFFF)
1600 public static int test_0_vector4f_cmpeq () {
1601 Vector4f a = new Vector4f (float.NaN, 2, 3, 6);
1602 Vector4f b = new Vector4f (1, float.NaN, 3, 4);
1603 Vector4f c = Vector4f.CompareEqual (a, b);
1605 if (((Vector4ui)c).X != 0)
1607 if (((Vector4ui)c).Y != 0)
1609 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1611 if (((Vector4ui)c).W != 0)
1616 public static int test_0_vector4ui_sar () {
1617 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1619 Vector4ui c = Vector4ui.ArithmeticRightShift (a, 2);
1621 if (c.X != 0xFC000000)
1632 public static int test_0_vector4ui_unpack_high () {
1633 Vector4ui a = new Vector4ui (1,2,3,4);
1634 Vector4ui b = new Vector4ui (5,6,7,8);
1636 Vector4ui c = Vector4ui.UnpackHigh(a, b);
1649 public static int test_0_vector4ui_unpack_low () {
1650 Vector4ui a = new Vector4ui (1,2,3,4);
1651 Vector4ui b = new Vector4ui (5,6,7,8);
1653 Vector4ui c = Vector4ui.UnpackLow (a, b);
1666 public static int test_0_vector4ui_xor () {
1667 Vector4ui a = new Vector4ui (1,2,3,4);
1668 Vector4ui b = new Vector4ui (7,5,3,1);
1670 Vector4ui c = a ^ b;
1683 public static int test_0_vector4ui_or () {
1684 Vector4ui a = new Vector4ui (1,2,3,4);
1685 Vector4ui b = new Vector4ui (7,5,3,1);
1687 Vector4ui c = a | b;
1699 public static int test_0_vector4ui_and () {
1700 Vector4ui a = new Vector4ui (1,2,3,4);
1701 Vector4ui b = new Vector4ui (7,5,3,1);
1703 Vector4ui c = a & b;
1716 public static int test_0_vector4ui_shr () {
1717 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1719 Vector4ui c = a >> 2;
1721 if (c.X != 0x3C000000)
1732 public static int test_0_vector4ui_shl () {
1733 Vector4ui a = new Vector4ui (10,20,3,40);
1735 Vector4ui c = a << 2;
1748 public static int test_0_vector4ui_mul () {
1749 Vector4ui a = new Vector4ui (0x8888,20,3,40);
1750 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1752 Vector4ui c = a * b;
1754 if (c.X != 0xffff7800)
1764 public static int test_0_vector4ui_sub () {
1765 Vector4ui a = new Vector4ui (1,20,3,40);
1766 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1768 Vector4ui c = a - b;
1770 if (c.X != 0xff0101)
1781 public static int test_0_vector4ui_add () {
1782 Vector4ui a = new Vector4ui (0xFF00FF00u,2,3,4);
1783 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1785 Vector4ui c = a + b;
1787 if (c.X != 0xfe01fe00)
1799 static int test_0_vector4ui_accessors () {
1800 Vector4ui a = new Vector4ui (1,2,3,4);
1826 static int test_0_vector8us_sub_sat () {
1827 Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
1828 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1829 Vector8us c = Vector8us.SubtractWithSaturation (a, b);
1850 static int test_0_vector8us_add_sat () {
1851 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1852 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1853 Vector8us c = Vector8us.AddWithSaturation (a, b);
1874 static int test_0_vector8us_unpack_low () {
1875 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1876 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
1877 Vector8us c = Vector8us.UnpackLow (a, b);
1899 static int test_0_vector8us_shift_left () {
1900 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1902 Vector8us c = a << amt;
1913 static int test_0_vector8us_shift_right_arithmetic () {
1914 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1916 Vector8us c = Vector8us.ArithmeticRightShift (a, amt);
1927 static int test_0_vector8us_shift_variable_offset () {
1929 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1931 Vector8us c = b >> off;
1948 static int test_0_vector8us_shift_operand_is_live_after_op () {
1949 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1951 Vector8us c = b >> 2;
1967 static int test_0_vector8us_shr_constant () {
1968 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1969 Vector8us c = a >> 2;
1980 static int test_0_vector8us_mul () {
1981 Vector8us a = new Vector8us (0x0F00,4,5,6,7,8,9,10);
1982 Vector8us b = new Vector8us (0x0888,1,2,3,4,5,6,8);
1984 Vector8us c = a * b;
1994 static int test_0_vector8us_add () {
1995 Vector8us a = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1996 Vector8us b = new Vector8us (0x8888,1,2,3,4,5,6,8);
1998 Vector8us c = a + b;
2009 static int test_0_vector8us_sub () {
2010 Vector8us a = new Vector8us (3,4,5,6,7,8,9,10);
2011 Vector8us b = new Vector8us (10,1,2,3,4,5,6,8);
2013 Vector8us c = a - b;
2025 static int test_0_vector8us_accessors () {
2026 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
2074 static int test_0_vector16b_unpack_high () {
2075 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2076 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2077 Vector16b c = Vector16b.UnpackHigh (a, b);
2098 static int test_0_vector16b_unpack_low () {
2099 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2100 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2101 Vector16b c = Vector16b.UnpackLow (a, b);
2122 static int test_0_vector16b_sub_sat () {
2123 Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2124 Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2125 Vector16b c = Vector16b.SubtractWithSaturation (a, b);
2136 static int test_0_vector16b_add_sat () {
2137 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2138 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2139 Vector16b c = Vector16b.AddWithSaturation (a, b);
2150 static int test_0_vector16b_add_ovf () {
2151 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2152 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2153 Vector16b c = a + b;
2164 static int test_0_vector16b_accessors () {
2165 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2252 public static int test_0_accessors () {
2253 Vector4f a = new Vector4f (1, 2, 3, 4);
2265 public static int test_0_packed_add_with_stack_tmp () {
2266 Vector4f a = new Vector4f (1, 2, 3, 4);
2267 Vector4f b = new Vector4f (5, 6, 7, 8);
2268 Vector4f c = new Vector4f (-1, -3, -4, -5);
2269 Vector4f d = a + b + c;
2281 public static int test_0_simple_packed_add () {
2282 Vector4f a = new Vector4f (1, 2, 3, 4);
2283 Vector4f b = new Vector4f (5, 6, 7, 8);
2297 public static int test_0_simple_packed_sub () {
2298 Vector4f a = new Vector4f (1, 2, 3, 4);
2299 Vector4f b = new Vector4f (5, 6, 7, 8);
2312 public static int test_0_simple_packed_mul () {
2313 Vector4f a = new Vector4f (1, 2, 3, 4);
2314 Vector4f b = new Vector4f (5, 6, 7, 8);
2327 public static int test_0_simple_packed_div () {
2328 Vector4f a = new Vector4f (2, 2, 3, 4);
2329 Vector4f b = new Vector4f (20, 10, 33, 12);
2342 public static int test_0_simple_packed_sqrt () {
2343 Vector4f a = new Vector4f (16, 4, 9, 25);
2344 a = Vector4f.Sqrt (a);
2356 public static int test_0_simple_packed_invsqrt () {
2357 Vector4f a = new Vector4f (16, 4, 100, 25);
2358 //this function has VERY low precision
2359 a = Vector4f.InvSqrt (a);
2360 if (a.X < (1/4f - 0.01f) || a.X > (1/4f + 0.01f))
2362 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
2364 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
2366 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
2371 public static int test_0_simple_packed_min () {
2372 Vector4f a = new Vector4f (16, -4, 9, 25);
2373 Vector4f b = new Vector4f (5, 3, 9, 0);
2374 Vector4f c = Vector4f.Min (a, b);
2386 public static int test_0_simple_packed_max () {
2387 Vector4f a = new Vector4f (16, -4, 9, 25);
2388 Vector4f b = new Vector4f (5, 3, 9, 0);
2389 Vector4f c = Vector4f.Max (a, b);
2401 public static int test_0_simple_packed_hadd () {
2402 Vector4f a = new Vector4f (5, 5, 6, 6);
2403 Vector4f b = new Vector4f (7, 7, 8, 8);
2404 Vector4f c = Vector4f.HorizontalAdd (a, b);
2416 public static int test_0_simple_packed_hsub () {
2417 Vector4f a = new Vector4f (5, 2, 6, 1);
2418 Vector4f b = new Vector4f (7, 0, 8, 3);
2419 Vector4f c = Vector4f.HorizontalSub (a, b);
2431 public static int test_0_simple_packed_addsub () {
2432 Vector4f a = new Vector4f (5, 2, 6, 1);
2433 Vector4f b = new Vector4f (7, 0, 8, 3);
2434 Vector4f c = Vector4f.AddSub (a, b);
2446 public static int test_0_simple_packed_shuffle () {
2447 Vector4f a = new Vector4f (1, 2, 3, 4);
2448 a = Vector4f.Shuffle(a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2460 public static int test_0_packed_shuffle_with_reg_pressure () {
2461 Vector4f v = new Vector4f (1, 2, 3, 4);
2462 Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
2463 if (ff) v = v + v -v ;
2465 Vector4f r0 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2466 Vector4f r1 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2467 Vector4f x = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2468 Vector4f r2 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2469 Vector4f r3 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2477 Vector4f result = r0 + r1 + r2 + r3;
2487 if (result.Y != result.Y)
2492 public static int test_24_regs_pressure_a () {
2493 Vector4f a = new Vector4f (1, 2, 3, 4);
2501 public static int test_54_regs_pressure_b () {
2502 Vector4f a = new Vector4f (1, 2, 3, 4);
2506 Vector4f e = a + b + c;
2507 Vector4f f = d - b + a - c;
2508 Vector4f g = a - d * f - c + b;
2509 Vector4f h = a * b - c + e;
2510 Vector4f i = h - g - f - e - d - c - b - a;
2511 Vector4f j = a + b + c + d + e + f + g + h + i;
2516 public static int test_3_single_block_var_is_properly_promoted () {
2517 Vector4f a = new Vector4f (4, 5, 6, 7);
2521 Vector4f b = new Vector4f (1, 2, 3, 4);
2532 static float float_val = 45f;
2534 public static int test_0_sse2_opt_and_simd_intrinsic_proper_regalloc () {
2535 Vector4f v = new Vector4f (1, 2, 3, 4);
2536 float f = float_val;
2545 public static int Main () {
2546 return TestDriver.RunTests (typeof (SimdTests));