4 public class SimdTests {
5 public static int test_0_bug_462457 ()
7 Vector4f sum = new Vector4f(0,0,0,0);
8 Vector4f add = new Vector4f(1.0F,1.0F,1.0F,1.0F);
10 for (int i = 0; i < 10; ++i)
18 public static int test_0_vector16b_operator_neq () {
19 Vector16b a = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
20 Vector16b b = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
29 public static int test_0_vector16b_operator_eq () {
30 Vector16b a = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
31 Vector16b b = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
40 public static int test_0_vector8us_operator_neq () {
41 Vector8us a = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
42 Vector8us b = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
51 public static int test_0_vector8us_operator_eq () {
52 Vector8us a = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
53 Vector8us b = new Vector8us(1, 2, 3, 4, 5, 6, 7, 8);
62 public static int test_0_set_vector4f_operator_neq () {
63 Vector4f a = new Vector4f(1, 2, 3, 4);
64 Vector4f b = new Vector4f(1, 2, 3, 4);
68 a = new Vector4f(1, 2, float.NaN, 4);
69 b = new Vector4f(1, 2, float.NaN, 4);
70 if (!(a != b)) //NaN is always !=
73 a = new Vector4f(1, 2, float.NaN, 4);
74 b = new Vector4f(1, 2, 10, 4);
78 a = new Vector4f(1, 2, float.PositiveInfinity, 4);
79 b = new Vector4f(1, 2, float.PositiveInfinity, 4);
83 a = new Vector4f(1, 2, 20, 4);
84 b = new Vector4f(1, 2, 30, 4);
91 public static int test_0_set_vector4f_operator_eq () {
92 Vector4f a = new Vector4f(1, 2, 3, 4);
93 Vector4f b = new Vector4f(1, 2, 3, 4);
97 a = new Vector4f(1, 2, float.NaN, 4);
98 b = new Vector4f(1, 2, float.NaN, 4);
102 a = new Vector4f(1, 2, 10, 4);
103 b = new Vector4f(1, 2, float.NaN, 4);
107 a = new Vector4f(1, 2, float.PositiveInfinity, 4);
108 b = new Vector4f(1, 2, float.PositiveInfinity, 4);
114 public static int test_1_set_vector4ui_operator_neq () {
115 Vector4ui a = new Vector4ui(1, 2, 3, 4);
116 Vector4ui b = new Vector4ui(1, 2, 3, 4);
122 public static int test_0_set_vector4ui_operator_neq () {
123 Vector4ui a = new Vector4ui(1, 2, 3, 4);
124 Vector4ui b = new Vector4ui(111, 2, 3, 4);
130 public static int test_0_set_vector4ui_operator_eq () {
131 Vector4ui a = new Vector4ui(1, 2, 3, 4);
132 Vector4ui b = new Vector4ui(1, 2, 3, 4);
138 public static int test_1_set_vector4ui_operator_eq () {
139 Vector4ui a = new Vector4ui(1, 2, 3, 4);
140 Vector4ui b = new Vector4ui(111, 2, 3, 4);
146 public static int test_0_set_vector_small_array () {
147 uint[] array = new uint[3];
150 array.SetVector (new Vector4ui (), 0);
152 } catch (IndexOutOfRangeException) {
157 public static int test_0_set_vector_negative_index () {
158 uint[] array = new uint[4];
161 array.SetVector (new Vector4ui (), -1);
163 } catch (IndexOutOfRangeException) {
168 public static int test_0_set_vector_bounds_error () {
169 uint[] array = new uint[4];
172 array.SetVector (new Vector4ui (), 1);
174 } catch (IndexOutOfRangeException) {
179 public static int test_0_set_vector () {
180 uint[] array = new uint[10];
181 Vector4ui a = new Vector4ui (11, 22, 33, 44);
183 array.SetVector (a, 1);
196 public static int test_0_get_vector_small_array () {
197 uint[] array = new uint[3];
200 Vector4ui res = array.GetVector (0);
202 } catch (IndexOutOfRangeException) {
207 public static int test_0_get_vector_negative_index () {
208 uint[] array = new uint[4];
211 Vector4ui res = array.GetVector (-1);
213 } catch (IndexOutOfRangeException) {
218 public static int test_0_get_vector_bounds_error () {
219 uint[] array = new uint[4];
222 Vector4ui res = array.GetVector (1);
224 } catch (IndexOutOfRangeException) {
229 public static int test_0_get_vector () {
230 uint[] array = new uint[] { 11, 22, 33, 44, 55, 66, 77, 88, 99, 111 };
232 Vector4ui res = array.GetVector (1);
246 public static int test_0_accessor_vecto2l () {
247 Vector2l a = new Vector2l (3, 2);
254 a.X = 500000000000055l;
257 if (a.X != 500000000000055l)
259 if (a.Y != -12345678900l)
264 public static int test_0_accessor_vecto2d () {
265 Vector2d a = new Vector2d (3, 2);
275 if (a.X != 5000000000000)
282 public static int test_0_accessor_vecto4f () {
283 Vector4f a = new Vector4f (1,2,3,4);
310 public static int test_0_accessor_vecto4i () {
311 Vector4i a = new Vector4i (0x70000000, -1, 3, 4);
313 if (a.X != 0x70000000)
333 if (a.W != -44444444)
338 public static int test_0_accessor_vecto4ui () {
339 Vector4ui a = new Vector4ui (0xF0000000, 0xF0000, 3, 4);
341 if (a.X != 0xF0000000)
366 static float use_getter_with_byref (ref Vector4f a) {
370 public static int test_0_accessor_and_byref_var () {
371 Vector4f a = new Vector4f (1, 2, 3, 4);
372 if (use_getter_with_byref (ref a) != 4)
377 public static unsafe int test_0_vector2ul_slr () {
378 Vector2ul a = new Vector2ul (1, 6);
380 Vector2ul c = a >> 1;
388 public static unsafe int test_0_vector2l_cmp_gt () {
389 Vector2l a = new Vector2l (10, 5);
390 Vector2l b = new Vector2l (-1, 5);
392 Vector2l c = a.CompareGreaterThan (b);
401 public static unsafe int test_0_vector2l_cmp_eq () {
402 Vector2l a = new Vector2l (0xFF, 5);
403 Vector2l b = new Vector2l (0xFF000000FFL, 5);
405 Vector2l c = a.CompareEqual (b);
414 public static unsafe int test_0_vector2l_srl () {
415 Vector2l a = new Vector2l (1, 6);
417 Vector2l c = a.LogicalRightShift (1);
426 public static unsafe int test_0_vector2l_unpack_high () {
427 Vector2l a = new Vector2l (1, 6);
428 Vector2l b = new Vector2l (3, 4);
430 Vector2l c = a.UnpackHigh (b);
439 public static unsafe int test_0_vector2l_unpack_low () {
440 Vector2l a = new Vector2l (1, 6);
441 Vector2l b = new Vector2l (3, 4);
443 Vector2l c = a.UnpackLow (b);
452 public static unsafe int test_0_vector2l_xor () {
453 Vector2l a = new Vector2l (1, 6);
454 Vector2l b = new Vector2l (3, 4);
465 public static unsafe int test_0_vector2l_or () {
466 Vector2l a = new Vector2l (1, 6);
467 Vector2l b = new Vector2l (3, 4);
478 public static unsafe int test_0_vector2l_and () {
479 Vector2l a = new Vector2l (1, 6);
480 Vector2l b = new Vector2l (3, 4);
491 public static unsafe int test_0_vector2l_shl() {
492 Vector2l a = new Vector2l (1, 6);
502 public static unsafe int test_0_vector2l_sub() {
503 Vector2l a = new Vector2l (1, 6);
504 Vector2l b = new Vector2l (3, 4);
515 public static unsafe int test_0_vector2l_add () {
516 Vector2l a = new Vector2l (1, 2);
517 Vector2l b = new Vector2l (3, 4);
528 public static unsafe int test_0_vector2d_dup () {
529 Vector2d a = new Vector2d (3, 2);
531 Vector2d c = a.Duplicate ();
540 public static unsafe int test_0_vector2d_cmp_eq () {
541 Vector2d a = new Vector2d (3, 2);
542 Vector2d b = new Vector2d (3, 4);
544 Vector4ui c = (Vector4ui)a.CompareEqual (b);
546 if (c.X != 0xFFFFFFFF)
548 if (c.Y != 0xFFFFFFFF)
557 public static unsafe int test_0_vector2d_unpack_low () {
558 Vector2d a = new Vector2d (1, 2);
559 Vector2d b = new Vector2d (4, 5);
561 Vector2d c = a.InterleaveLow (b);
570 public static unsafe int test_0_vector2d_unpack_high () {
571 Vector2d a = new Vector2d (1, 2);
572 Vector2d b = new Vector2d (4, 5);
574 Vector2d c = a.InterleaveHigh (b);
582 public static unsafe int test_0_vector2d_addsub () {
583 Vector2d a = new Vector2d (1, 2);
584 Vector2d b = new Vector2d (4, 1);
586 Vector2d c = a.AddSub (b);
594 public static unsafe int test_0_vector2d_hsub () {
595 Vector2d a = new Vector2d (1, 2);
596 Vector2d b = new Vector2d (4, 1);
598 Vector2d c = a.HorizontalSub (b);
607 public static unsafe int test_0_vector2d_hadd () {
608 Vector2d a = new Vector2d (1, 2);
609 Vector2d b = new Vector2d (4, 0);
611 Vector2d c = a.HorizontalAdd (b);
620 public static unsafe int test_0_vector2d_min () {
621 Vector2d a = new Vector2d (1, 2);
622 Vector2d b = new Vector2d (4, 0);
624 Vector2d c = a.Min (b);
633 public static unsafe int test_0_vector2d_max () {
634 Vector2d a = new Vector2d (1, 2);
635 Vector2d b = new Vector2d (4, 0);
637 Vector2d c = a.Max (b);
647 public static unsafe int test_0_vector2d_andnot () {
648 Vector2d a = new Vector2d (1, 2);
649 Vector2d b = new Vector2d (3, 4);
651 Vector4ui c = (Vector4ui)a.AndNot (b);
652 Vector4ui ta = (Vector4ui)a;
653 Vector4ui tb = (Vector4ui)b;
655 if (c.X != (~ta.X & tb.X))
657 if (c.Y != (~ta.Y & tb.Y))
659 if (c.Z != (~ta.Z & tb.Z))
661 if (c.W != (~ta.W & tb.W))
666 public static unsafe int test_0_vector2d_div () {
667 Vector2d a = new Vector2d (1, 2);
668 Vector2d b = new Vector2d (4, 5);
679 public static unsafe int test_0_vector2d_mul () {
680 Vector2d a = new Vector2d (1, 2);
681 Vector2d b = new Vector2d (3, 5);
691 public static unsafe int test_0_vector2d_sub () {
692 Vector2d a = new Vector2d (1, 2);
693 Vector2d b = new Vector2d (3, 5);
703 public static unsafe int test_0_vector2d_add () {
704 Vector2d a = new Vector2d (1, 2);
705 Vector2d b = new Vector2d (3, 4);
715 public static unsafe int test_0_vector2d_xor () {
716 Vector2d a = new Vector2d (1, 2);
717 Vector2d b = new Vector2d (3, 4);
719 Vector4ui c = (Vector4ui)(a ^ b);
720 Vector4ui ta = (Vector4ui)a;
721 Vector4ui tb = (Vector4ui)b;
723 if (c.X != (ta.X ^ tb.X))
725 if (c.Y != (ta.Y ^ tb.Y))
727 if (c.Z != (ta.Z ^ tb.Z))
729 if (c.W != (ta.W ^ tb.W))
734 public static unsafe int test_0_vector2d_or () {
735 Vector2d a = new Vector2d (1, 2);
736 Vector2d b = new Vector2d (3, 4);
738 Vector4ui c = (Vector4ui)(a | b);
739 Vector4ui ta = (Vector4ui)a;
740 Vector4ui tb = (Vector4ui)b;
742 if (c.X != (ta.X | tb.X))
744 if (c.Y != (ta.Y | tb.Y))
746 if (c.Z != (ta.Z | tb.Z))
748 if (c.W != (ta.W | tb.W))
753 public static unsafe int test_0_vector2d_and () {
754 Vector2d a = new Vector2d (1, 2);
755 Vector2d b = new Vector2d (3, 4);
757 Vector4ui c = (Vector4ui)(a & b);
758 Vector4ui ta = (Vector4ui)a;
759 Vector4ui tb = (Vector4ui)b;
761 if (c.X != (ta.X & tb.X))
763 if (c.Y != (ta.Y & tb.Y))
765 if (c.Z != (ta.Z & tb.Z))
767 if (c.W != (ta.W & tb.W))
772 public static unsafe int test_vector8s_pack_signed_sat () {
773 Vector8s a = new Vector8s (-200, 200, 3, 0, 5, 6, 5, 4);
774 Vector8s b = new Vector8s (9, 2, 1, 2, 3, 6, 5, 6);
776 Vector16sb c = a.PackWithSignedSaturation (b);
786 public static unsafe int test_vector16sb_sub_sat () {
787 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
788 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
790 Vector16sb c = a.SubtractWithSaturation (b);
811 public static unsafe int test_vector16sb_add_sat () {
812 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
813 Vector16sb b = new Vector16sb (100, -100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
815 Vector16sb c = a.AddWithSaturation (b);
836 public static unsafe int test_vector16sb_cmp_gt () {
837 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
838 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
840 Vector16sb c = a.CompareGreaterThan (b);
860 public static int test_0_vector4ui_pack_with_sat () {
861 Vector4ui a = new Vector4ui (0xF0000000,0xF0000,3,4);
862 Vector4ui b = new Vector4ui (5,6,7,8);
864 Vector8us c = a.SignedPackWithUnsignedSaturation (b);
885 public static int test_0_vector8us_pack_with_sat () {
886 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
887 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
888 Vector16b c = a.SignedPackWithUnsignedSaturation (b);
903 public static int test_0_vector8us_mul_high () {
904 Vector8us a = new Vector8us (0xFF00, 2, 3, 0, 5, 6, 5, 4);
905 Vector8us b = new Vector8us (0xFF00, 2, 1, 2, 3, 6, 5, 6);
906 Vector8us c = a.MultiplyStoreHigh (b);
927 public static int test_0_vector8us_cmpeq () {
928 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
929 Vector8us b = new Vector8us (9, 2, 1, 2, 3, 6, 5, 6);
930 Vector8us c = a.CompareEqual (b);
952 public static int test_0_vector4ui_cmpeq () {
953 Vector4ui a = new Vector4ui (6,1,6,3);
954 Vector4ui b = new Vector4ui (3,4,6,7);
955 Vector4ui c = a.CompareEqual (b);
961 if (c.Z != 0xFFFFFFFF)
968 public static int test_0_vector4ui_shuffle () {
969 Vector4ui a = new Vector4ui (1,2,3,4);
970 Vector4ui c = a.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
983 public static int test_0_vector4ui_min () {
984 Vector4ui a = new Vector4ui (6,1,6,3);
985 Vector4ui b = new Vector4ui (3,4,6,7);
986 Vector4ui c = a.Min (b);
999 public static int test_0_vector4ui_max () {
1000 Vector4ui a = new Vector4ui (6,1,6,3);
1001 Vector4ui b = new Vector4ui (3,4,6,7);
1002 Vector4ui c = a.Max (b);
1015 public static int vector16b_cmpeq () {
1016 Vector16b a = new Vector16b (1,0,9,0,0,0,0,0,0,0,0,0,0,0,0,1);
1017 Vector16b b = new Vector16b (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
1018 Vector16b c = a.CompareEqual (b);
1056 public static int vector16b_sum_abs_diff () {
1057 Vector16b a = new Vector16b (100,20,20,20,0,0,0,0,0,0,0,0,0,0, 0, 0);
1058 Vector16sb b = new Vector16sb (0, 10,10,10,0,0,0,0,0,0,0,0,0,0,10,10);
1059 Vector8us c = a.SumOfAbsoluteDifferences (b);
1081 public static int test_0_vector16b_extract_mask () {
1082 Vector16b a = new Vector16b (0xF0,0,0xF0,0,0,0,0xF0,0xAA,0x0F,0,0xFF,0,0,0,0,0);
1083 int c = a.ExtractByteMask ();
1090 public static int test_0_vector16b_min () {
1091 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
1092 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1093 Vector16b c = a.Min (b);
1130 public static int test_0_vector16b_max () {
1131 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
1132 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1133 Vector16b c = a.Max (b);
1169 public static int test_0_vector16b_avg () {
1170 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1171 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1172 Vector16b c = a.Average (b);
1210 static unsafe Vector8us bad_method_regression_2 (Vector16b va, Vector16b vb) {
1211 Vector8us res = new Vector8us ();
1212 byte *a = (byte*)&va;
1213 byte *b = (byte*)&vb;
1216 for (int i = 0; i < 8; ++i)
1217 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
1218 res.V0 = (ushort)tmp;
1221 for (int i = 0; i < 8; ++i)
1222 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
1223 res.V4 = (ushort)tmp;
1227 /*This bug was caused the simplifier not taking notice of LDADDR on the remaining blocks.*/
1228 public static int test_2_local_simplifier_regression_other_blocks () {
1229 Vector16b a = new Vector16b (1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
1230 Vector16b b = new Vector16b (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
1231 Vector8us res = bad_method_regression_2 (a,b);
1232 return (int)res.V0 + res.V4;
1235 static unsafe Vector8us bad_method_regression (Vector16b va, Vector16b vb) {
1236 Vector8us res = new Vector8us ();
1237 byte *a = (byte*)&va;
1238 byte *b = (byte*)&vb;
1239 *((ushort*)&res) = 10;
1250 /*This bug was caused the simplifier not taking notice of LDADDR on the first block.*/
1251 public static int test_10_local_simplifier_regression_first_block () {
1252 Vector16b a = new Vector16b ();
1253 Vector16b b = new Vector16b ();
1254 Vector8us res = bad_method_regression (a,b);
1258 public static int test_0_vecto8us_shuffle_low () {
1259 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1260 Vector8us c = a.ShuffleLow (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1281 public static int test_0_vecto8us_shuffle_high () {
1282 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1283 Vector8us c = a.ShuffleHigh (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1305 public static int test_0_vecto8us_max () {
1306 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1307 Vector8us b = new Vector8us (9, 1, 1, 2, 9, 6, 5, 1000);
1308 Vector8us c = a.Max (b);
1330 public static int test_0_vecto8us_min () {
1331 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
1332 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1333 Vector8us c = a.Min (b);
1354 public static int test_0_vecto8us_avg () {
1355 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
1356 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
1357 Vector8us c = a.Average (b);
1378 static void store_helper (ref Vector4f x) {
1380 k = new Vector4f(9,9,9,9);
1384 public static int test_0_vector4f_byref_store ()
1387 k = new Vector4f(1,2,3,4);
1388 store_helper (ref k);
1394 public static int test_0_vector4f_init_array_element ()
1396 Vector4f[] v = new Vector4f[1];
1397 v[0] = new Vector4f(9,9,9,9);
1403 public static int test_0_vector4f_dup_high () {
1404 Vector4f a = new Vector4f (1, 2, 3, 4);
1405 Vector4f c = a.DuplicateHigh();
1418 public static int test_0_vector4f_dup_low () {
1419 Vector4f a = new Vector4f (1, 2, 3, 4);
1420 Vector4f c = a.DuplicateLow ();
1434 public static int test_0_vector4f_interleave_high () {
1435 Vector4f a = new Vector4f (1, 2, 3, 4);
1436 Vector4f b = new Vector4f (5, 6, 7, 8);
1437 Vector4f c = a.InterleaveHigh (b);
1450 public static int test_0_vector4f_interleave_low () {
1451 Vector4f a = new Vector4f (1, 2, 3, 4);
1452 Vector4f b = new Vector4f (5, 6, 7, 8);
1453 Vector4f c = a.InterleaveLow (b);
1466 public static int test_0_vector4f_rcp () {
1467 Vector4f a = new Vector4f (1, 2, 4, 8);
1468 Vector4f c = a.Reciprocal ();
1470 //Test with ranges due to the terrible precision.
1471 if (c.X < (1 - 0.01f) || c.X > (1 + 0.01f))
1473 if (c.Y < (0.5 - 0.01f) || c.Y > (0.5 + 0.01f))
1475 if (c.Z < (0.25 - 0.01f) || c.Z > (0.25 + 0.01f))
1477 if (c.W < (0.125 - 0.01f) || c.W > (0.125 + 0.01f))
1482 public static int test_0_vector4f_xor () {
1483 Vector4f a = new Vector4f (1, 2, 3, 4);
1484 Vector4f b = new Vector4f (1, 3, 3, 8);
1487 if (((Vector4ui)c).X != 0)
1489 if (((Vector4ui)c).Y != 0x400000)
1491 if (((Vector4ui)c).Z != 0)
1493 if (((Vector4ui)c).W != 0x1800000)
1498 public static int test_0_vector4f_or () {
1499 Vector4f a = new Vector4f (1, 2, 3, 4);
1500 Vector4f b = new Vector4f (1, 3, 3, 8);
1503 if (((Vector4ui)c).X != 0x3F800000)
1505 if (((Vector4ui)c).Y != 0x40400000)
1507 if (((Vector4ui)c).Z != 0x40400000)
1509 if (((Vector4ui)c).W != 0x41800000)
1513 public static int test_0_vector4f_andn () {
1514 Vector4f a = new Vector4f (1, 2, 3, 4);
1515 Vector4f b = new Vector4f (1, 3, 3, 8);
1516 Vector4f c = a.AndNot (b);
1518 if (((Vector4ui)c).X != 0)
1520 if (((Vector4ui)c).Y != 0x400000)
1522 if (((Vector4ui)c).Z != 0)
1524 if (((Vector4ui)c).W != 0x1000000)
1529 public static int test_0_vector4f_and () {
1530 Vector4f a = new Vector4f (1, 2, 3, 4);
1531 Vector4f b = new Vector4f (1, 3, 3, 8);
1534 if (((Vector4ui)c).X != 0x3F800000)
1536 if (((Vector4ui)c).Y != 0x40000000)
1538 if (((Vector4ui)c).Z != 0x40400000)
1540 if (((Vector4ui)c).W != 0x40000000)
1545 public static int test_0_vector4f_cmpord () {
1546 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1547 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1548 Vector4f c = a.CompareOrdered (b);
1550 if (((Vector4ui)c).X != 0)
1552 if (((Vector4ui)c).Y != 0)
1554 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1556 if (((Vector4ui)c).W != 0xFFFFFFFF)
1561 public static int test_0_vector4f_cmpnle () {
1562 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1563 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1564 Vector4f c = a.CompareNotLessEqual (b);
1566 if (((Vector4ui)c).X != 0xFFFFFFFF)
1568 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1570 if (((Vector4ui)c).Z != 0)
1572 if (((Vector4ui)c).W != 0)
1577 public static int test_0_vector4f_cmpnlt () {
1578 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1579 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1580 Vector4f c = a.CompareNotLessThan (b);
1582 if (((Vector4ui)c).X != 0xFFFFFFFF)
1584 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1586 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1588 if (((Vector4ui)c).W != 0)
1593 public static int test_0_vector4f_cmpneq () {
1594 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1595 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1596 Vector4f c = a.CompareNotEqual (b);
1598 if (((Vector4ui)c).X != 0xFFFFFFFF)
1600 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1602 if (((Vector4ui)c).Z != 0)
1604 if (((Vector4ui)c).W != 0xFFFFFFFF)
1609 public static int test_0_vector4f_cmpunord () {
1610 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1611 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1612 Vector4f c = a.CompareUnordered (b);
1614 if (((Vector4ui)c).X != 0xFFFFFFFF)
1616 if (((Vector4ui)c).Y != 0xFFFFFFFF)
1618 if (((Vector4ui)c).Z != 0)
1620 if (((Vector4ui)c).W != 0)
1625 public static int test_0_vector4f_cmple () {
1626 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1627 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1628 Vector4f c = a.CompareLessEqual (b);
1630 if (((Vector4ui)c).X != 0)
1632 if (((Vector4ui)c).Y != 0)
1634 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1636 if (((Vector4ui)c).W != 0xFFFFFFFF)
1641 public static int test_0_vector4f_cmplt () {
1642 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
1643 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
1644 Vector4f c = a.CompareLessThan (b);
1646 if (((Vector4ui)c).X != 0)
1648 if (((Vector4ui)c).Y != 0)
1650 if (((Vector4ui)c).Z != 0)
1652 if (((Vector4ui)c).W != 0xFFFFFFFF)
1657 public static int test_0_vector4f_cmpeq () {
1658 Vector4f a = new Vector4f (float.NaN, 2, 3, 6);
1659 Vector4f b = new Vector4f (1, float.NaN, 3, 4);
1660 Vector4f c = a.CompareEqual (b);
1662 if (((Vector4ui)c).X != 0)
1664 if (((Vector4ui)c).Y != 0)
1666 if (((Vector4ui)c).Z != 0xFFFFFFFF)
1668 if (((Vector4ui)c).W != 0)
1673 public static int test_0_vector4ui_sar () {
1674 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1676 Vector4ui c = a.ArithmeticRightShift (2);
1678 if (c.X != 0xFC000000)
1689 public static int test_0_vector4ui_unpack_high () {
1690 Vector4ui a = new Vector4ui (1,2,3,4);
1691 Vector4ui b = new Vector4ui (5,6,7,8);
1693 Vector4ui c = a.UnpackHigh(b);
1706 public static int test_0_vector4ui_unpack_low () {
1707 Vector4ui a = new Vector4ui (1,2,3,4);
1708 Vector4ui b = new Vector4ui (5,6,7,8);
1710 Vector4ui c = a.UnpackLow (b);
1723 public static int test_0_vector4ui_xor () {
1724 Vector4ui a = new Vector4ui (1,2,3,4);
1725 Vector4ui b = new Vector4ui (7,5,3,1);
1727 Vector4ui c = a ^ b;
1740 public static int test_0_vector4ui_or () {
1741 Vector4ui a = new Vector4ui (1,2,3,4);
1742 Vector4ui b = new Vector4ui (7,5,3,1);
1744 Vector4ui c = a | b;
1756 public static int test_0_vector4ui_and () {
1757 Vector4ui a = new Vector4ui (1,2,3,4);
1758 Vector4ui b = new Vector4ui (7,5,3,1);
1760 Vector4ui c = a & b;
1773 public static int test_0_vector4ui_shr () {
1774 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1776 Vector4ui c = a >> 2;
1778 if (c.X != 0x3C000000)
1789 public static int test_0_vector4ui_shl () {
1790 Vector4ui a = new Vector4ui (10,20,3,40);
1792 Vector4ui c = a << 2;
1805 public static int test_0_vector4ui_mul () {
1806 Vector4ui a = new Vector4ui (0x8888,20,3,40);
1807 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1809 Vector4ui c = a * b;
1811 if (c.X != 0xffff7800)
1821 public static int test_0_vector4ui_sub () {
1822 Vector4ui a = new Vector4ui (1,20,3,40);
1823 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1825 Vector4ui c = a - b;
1827 if (c.X != 0xff0101)
1838 public static int test_0_vector4ui_add () {
1839 Vector4ui a = new Vector4ui (0xFF00FF00u,2,3,4);
1840 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1842 Vector4ui c = a + b;
1844 if (c.X != 0xfe01fe00)
1856 static int test_0_vector4ui_accessors () {
1857 Vector4ui a = new Vector4ui (1,2,3,4);
1883 static int test_0_vector8us_sub_sat () {
1884 Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
1885 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1886 Vector8us c = a.SubtractWithSaturation (b);
1907 static int test_0_vector8us_add_sat () {
1908 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1909 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1910 Vector8us c = a.AddWithSaturation (b);
1931 static int test_0_vector8us_unpack_low () {
1932 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1933 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
1934 Vector8us c = a.UnpackLow (b);
1956 static int test_0_vector8us_shift_left () {
1957 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1959 Vector8us c = a << amt;
1970 static int test_0_vector8us_shift_right_arithmetic () {
1971 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1973 Vector8us c = a.ArithmeticRightShift (amt);
1984 static int test_0_vector8us_shift_variable_offset () {
1986 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1988 Vector8us c = b >> off;
2005 static int test_0_vector8us_shift_operand_is_live_after_op () {
2006 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
2008 Vector8us c = b >> 2;
2024 static int test_0_vector8us_shr_constant () {
2025 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
2026 Vector8us c = a >> 2;
2037 static int test_0_vector8us_mul () {
2038 Vector8us a = new Vector8us (0x0F00,4,5,6,7,8,9,10);
2039 Vector8us b = new Vector8us (0x0888,1,2,3,4,5,6,8);
2041 Vector8us c = a * b;
2051 static int test_0_vector8us_add () {
2052 Vector8us a = new Vector8us (0xFF00,4,5,6,7,8,9,10);
2053 Vector8us b = new Vector8us (0x8888,1,2,3,4,5,6,8);
2055 Vector8us c = a + b;
2066 static int test_0_vector8us_sub () {
2067 Vector8us a = new Vector8us (3,4,5,6,7,8,9,10);
2068 Vector8us b = new Vector8us (10,1,2,3,4,5,6,8);
2070 Vector8us c = a - b;
2082 static int test_0_vector8us_accessors () {
2083 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
2131 static int test_0_vector16b_unpack_high () {
2132 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2133 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2134 Vector16b c = a.UnpackHigh (b);
2155 static int test_0_vector16b_unpack_low () {
2156 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2157 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2158 Vector16b c = a.UnpackLow (b);
2179 static int test_0_vector16b_sub_sat () {
2180 Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2181 Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2182 Vector16b c = a.SubtractWithSaturation (b);
2193 static int test_0_vector16b_add_sat () {
2194 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2195 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2196 Vector16b c = a.AddWithSaturation (b);
2207 static int test_0_vector16b_add_ovf () {
2208 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2209 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
2210 Vector16b c = a + b;
2221 static int test_0_vector16b_accessors () {
2222 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
2309 public static int test_0_accessors () {
2310 Vector4f a = new Vector4f (1, 2, 3, 4);
2322 public static int test_0_packed_add_with_stack_tmp () {
2323 Vector4f a = new Vector4f (1, 2, 3, 4);
2324 Vector4f b = new Vector4f (5, 6, 7, 8);
2325 Vector4f c = new Vector4f (-1, -3, -4, -5);
2326 Vector4f d = a + b + c;
2338 public static int test_0_simple_packed_add () {
2339 Vector4f a = new Vector4f (1, 2, 3, 4);
2340 Vector4f b = new Vector4f (5, 6, 7, 8);
2354 public static int test_0_simple_packed_sub () {
2355 Vector4f a = new Vector4f (1, 2, 3, 4);
2356 Vector4f b = new Vector4f (5, 6, 7, 8);
2369 public static int test_0_simple_packed_mul () {
2370 Vector4f a = new Vector4f (1, 2, 3, 4);
2371 Vector4f b = new Vector4f (5, 6, 7, 8);
2384 public static int test_0_simple_packed_div () {
2385 Vector4f a = new Vector4f (2, 2, 3, 4);
2386 Vector4f b = new Vector4f (20, 10, 33, 12);
2399 public static int test_0_simple_packed_sqrt () {
2400 Vector4f a = new Vector4f (16, 4, 9, 25);
2413 public static int test_0_simple_packed_invsqrt () {
2414 Vector4f a = new Vector4f (16, 4, 100, 25);
2415 //this function has VERY low precision
2417 if (a.X < (1/4f - 0.01f) || a.X > (1/4f + 0.01f))
2419 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
2421 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
2423 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
2428 public static int test_0_simple_packed_min () {
2429 Vector4f a = new Vector4f (16, -4, 9, 25);
2430 Vector4f b = new Vector4f (5, 3, 9, 0);
2431 Vector4f c = a.Min (b);
2443 public static int test_0_simple_packed_max () {
2444 Vector4f a = new Vector4f (16, -4, 9, 25);
2445 Vector4f b = new Vector4f (5, 3, 9, 0);
2446 Vector4f c = a.Max (b);
2458 public static int test_0_simple_packed_hadd () {
2459 Vector4f a = new Vector4f (5, 5, 6, 6);
2460 Vector4f b = new Vector4f (7, 7, 8, 8);
2461 Vector4f c = a.HorizontalAdd (b);
2473 public static int test_0_simple_packed_hsub () {
2474 Vector4f a = new Vector4f (5, 2, 6, 1);
2475 Vector4f b = new Vector4f (7, 0, 8, 3);
2476 Vector4f c = a.HorizontalSub (b);
2488 public static int test_0_simple_packed_addsub () {
2489 Vector4f a = new Vector4f (5, 2, 6, 1);
2490 Vector4f b = new Vector4f (7, 0, 8, 3);
2491 Vector4f c = a.AddSub (b);
2503 public static int test_0_simple_packed_shuffle () {
2504 Vector4f a = new Vector4f (1, 2, 3, 4);
2505 a = a.Shuffle(ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2517 public static int test_0_packed_shuffle_with_reg_pressure () {
2518 Vector4f v = new Vector4f (1, 2, 3, 4);
2519 Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
2520 if (ff) v = v + v -v ;
2522 Vector4f r0 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2523 Vector4f r1 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2524 Vector4f x = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2525 Vector4f r2 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2526 Vector4f r3 = v.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
2534 Vector4f result = r0 + r1 + r2 + r3;
2544 if (result.Y != result.Y)
2549 public static int test_24_regs_pressure_a () {
2550 Vector4f a = new Vector4f (1, 2, 3, 4);
2558 public static int test_54_regs_pressure_b () {
2559 Vector4f a = new Vector4f (1, 2, 3, 4);
2563 Vector4f e = a + b + c;
2564 Vector4f f = d - b + a - c;
2565 Vector4f g = a - d * f - c + b;
2566 Vector4f h = a * b - c + e;
2567 Vector4f i = h - g - f - e - d - c - b - a;
2568 Vector4f j = a + b + c + d + e + f + g + h + i;
2573 public static int test_3_single_block_var_is_properly_promoted () {
2574 Vector4f a = new Vector4f (4, 5, 6, 7);
2578 Vector4f b = new Vector4f (1, 2, 3, 4);
2589 static float float_val = 45f;
2591 public static int test_0_sse2_opt_and_simd_intrinsic_proper_regalloc () {
2592 Vector4f v = new Vector4f (1, 2, 3, 4);
2593 float f = float_val;
2602 public static int Main () {
2603 return TestDriver.RunTests (typeof (SimdTests));