4 public class SimdTests {
6 public static unsafe int test_vector8s_pack_signed_sat () {
7 Vector8s a = new Vector8s (-200, 200, 3, 0, 5, 6, 5, 4);
8 Vector8s b = new Vector8s (9, 2, 1, 2, 3, 6, 5, 6);
10 Vector16sb c = Vector8s.PackWithSignedSaturation (a, b);
12 Console.WriteLine (c.V0);//-128
13 Console.WriteLine (c.V1);//128
17 public static unsafe int test_vector16sb_sub_sat () {
18 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
19 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
21 Vector16sb c = Vector16sb.SubWithSaturation (a, b);
42 public static unsafe int test_vector16sb_add_sat () {
43 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
44 Vector16sb b = new Vector16sb (100, -100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
46 Vector16sb c = Vector16sb.AddWithSaturation (a, b);
67 public static unsafe int test_vector16sb_cmp_gt () {
68 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
69 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
71 Vector16sb c = Vector16sb.CompareGreaterThan (a, b);
91 public static int test_0_vector4ui_pack_with_sat () {
92 Vector4ui a = new Vector4ui (0xF0000000,0xF0000,3,4);
93 Vector4ui b = new Vector4ui (5,6,7,8);
95 Vector8us c = Vector4ui.SignedPackWithUnsignedSaturation (a, b);
116 public static int test_0_vector8us_pack_with_sat () {
117 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
118 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
119 Vector16b c = Vector8us.SignedPackWithUnsignedSaturation (a, b);
134 public static int test_0_vector8us_mul_high () {
135 Vector8us a = new Vector8us (0xFF00, 2, 3, 0, 5, 6, 5, 4);
136 Vector8us b = new Vector8us (0xFF00, 2, 1, 2, 3, 6, 5, 6);
137 Vector8us c = Vector8us.MultiplyStoreHigh (a, b);
158 public static int test_0_vector8us_cmpeq () {
159 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
160 Vector8us b = new Vector8us (9, 2, 1, 2, 3, 6, 5, 6);
161 Vector8us c = Vector8us.CompareEqual (a, b);
183 public static int test_0_vector4ui_cmpeq () {
184 Vector4ui a = new Vector4ui (6,1,6,3);
185 Vector4ui b = new Vector4ui (3,4,6,7);
186 Vector4ui c = Vector4ui.CompareEqual (a, b);
192 if (c.Z != 0xFFFFFFFF)
199 public static int test_0_vector4ui_shuffle () {
200 Vector4ui a = new Vector4ui (1,2,3,4);
201 Vector4ui c = Vector4ui.Shuffle (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
214 public static int test_0_vector4ui_extract_mask () {
215 Vector4ui a = new Vector4ui (0xFF00FF00,0x0F0FAA99,0,0);
216 int c = Vector4ui.ExtractByteMask (a);
223 public static int test_0_vector4ui_min () {
224 Vector4ui a = new Vector4ui (6,1,6,3);
225 Vector4ui b = new Vector4ui (3,4,6,7);
226 Vector4ui c = Vector4ui.Min (a, b);
239 public static int test_0_vector4ui_max () {
240 Vector4ui a = new Vector4ui (6,1,6,3);
241 Vector4ui b = new Vector4ui (3,4,6,7);
242 Vector4ui c = Vector4ui.Max (a, b);
255 public static int vector16b_cmpeq () {
256 Vector16b a = new Vector16b (1,0,9,0,0,0,0,0,0,0,0,0,0,0,0,1);
257 Vector16b b = new Vector16b (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
258 Vector16b c = Vector16b.CompareEqual (a, b);
296 public static int vector16b_sum_abs_diff () {
297 Vector16b a = new Vector16b (100,20,20,20,0,0,0,0,0,0,0,0,0,0, 0, 0);
298 Vector16sb b = new Vector16sb (0, 10,10,10,0,0,0,0,0,0,0,0,0,0,10,10);
299 Vector8us c = Vector16b.SumOfAbsoluteDifferences (a, b);
321 public static int test_0_vector16b_extract_mask () {
322 Vector16b a = new Vector16b (0xF0,0,0xF0,0,0,0,0xF0,0xAA,0x0F,0,0xFF,0,0,0,0,0);
323 int c = Vector16b.ExtractByteMask (a);
330 public static int test_0_vector16b_min () {
331 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
332 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
333 Vector16b c = Vector16b.Min (a, b);
370 public static int test_0_vector16b_max () {
371 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
372 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
373 Vector16b c = Vector16b.Max (a, b);
409 public static int test_0_vector16b_avg () {
410 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
411 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
412 Vector16b c = Vector16b.Average (a, b);
450 static unsafe Vector8us bad_method_regression_2 (Vector16b va, Vector16b vb) {
451 Vector8us res = new Vector8us ();
452 byte *a = (byte*)&va;
453 byte *b = (byte*)&vb;
456 for (int i = 0; i < 8; ++i)
457 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
458 res.V0 = (ushort)tmp;
461 for (int i = 0; i < 8; ++i)
462 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
463 res.V4 = (ushort)tmp;
467 /*This bug was caused the simplifier not taking notice of LDADDR on the remaining blocks.*/
468 public static int test_2_local_simplifier_regression_other_blocks () {
469 Vector16b a = new Vector16b (1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
470 Vector16b b = new Vector16b (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
471 Vector8us res = bad_method_regression_2 (a,b);
472 return (int)res.V0 + res.V4;
475 static unsafe Vector8us bad_method_regression (Vector16b va, Vector16b vb) {
476 Vector8us res = new Vector8us ();
477 byte *a = (byte*)&va;
478 byte *b = (byte*)&vb;
479 *((ushort*)&res) = 10;
490 /*This bug was caused the simplifier not taking notice of LDADDR on the first block.*/
491 public static int test_10_local_simplifier_regression_first_block () {
492 Vector16b a = new Vector16b ();
493 Vector16b b = new Vector16b ();
494 Vector8us res = bad_method_regression (a,b);
499 public static int test_0_vecto8us_extract_mask () {
500 Vector8us a = new Vector8us (0xF0F0, 0x700F, 0xAABB, 0x0000, 0x00F0, 0xF0F0, 0, 0);
501 int c = Vector8us.ExtractByteMask (a);
508 public static int test_0_vecto8us_shuffle_low () {
509 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
510 Vector8us c = Vector8us.ShuffleLow (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
531 public static int test_0_vecto8us_shuffle_high () {
532 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
533 Vector8us c = Vector8us.ShuffleHigh (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
555 public static int test_0_vecto8us_max () {
556 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
557 Vector8us b = new Vector8us (9, 1, 1, 2, 9, 6, 5, 1000);
558 Vector8us c = Vector8us.Max (a, b);
580 public static int test_0_vecto8us_min () {
581 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
582 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
583 Vector8us c = Vector8us.Min (a, b);
604 public static int test_0_vecto8us_avg () {
605 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
606 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
607 Vector8us c = Vector8us.Average (a, b);
628 static void store_helper (ref Vector4f x) {
630 k = new Vector4f(9,9,9,9);
634 public static int test_0_vector4f_byref_store ()
637 k = new Vector4f(1,2,3,4);
638 store_helper (ref k);
644 public static int test_0_vector4f_init_array_element ()
646 Vector4f[] v = new Vector4f[1];
647 v[0] = new Vector4f(9,9,9,9);
653 public static int test_0_vector4f_dup_high () {
654 Vector4f a = new Vector4f (1, 2, 3, 4);
655 Vector4f c = Vector4f.DuplicateHigh(a);
668 public static int test_0_vector4f_dup_low () {
669 Vector4f a = new Vector4f (1, 2, 3, 4);
670 Vector4f c = Vector4f.DuplicateLow (a);
684 public static int test_0_vector4f_interleave_high () {
685 Vector4f a = new Vector4f (1, 2, 3, 4);
686 Vector4f b = new Vector4f (5, 6, 7, 8);
687 Vector4f c = Vector4f.InterleaveHigh (a, b);
700 public static int test_0_vector4f_interleave_low () {
701 Vector4f a = new Vector4f (1, 2, 3, 4);
702 Vector4f b = new Vector4f (5, 6, 7, 8);
703 Vector4f c = Vector4f.InterleaveLow (a, b);
716 public static int test_0_vector4f_rcp () {
717 Vector4f a = new Vector4f (1, 2, 4, 8);
718 Vector4f c = Vector4f.Reciprocal (a);
720 //Test with ranges due to the terrible precision.
721 if (c.X < (1 - 0.01f) || c.X > (1 + 0.01f))
723 if (c.Y < (0.5 - 0.01f) || c.Y > (0.5 + 0.01f))
725 if (c.Z < (0.25 - 0.01f) || c.Z > (0.25 + 0.01f))
727 if (c.W < (0.125 - 0.01f) || c.W > (0.125 + 0.01f))
732 public static int test_0_vector4f_xor () {
733 Vector4f a = new Vector4f (1, 2, 3, 4);
734 Vector4f b = new Vector4f (1, 3, 3, 8);
737 if (((Vector4ui)c).X != 0)
739 if (((Vector4ui)c).Y != 0x400000)
741 if (((Vector4ui)c).Z != 0)
743 if (((Vector4ui)c).W != 0x1800000)
748 public static int test_0_vector4f_or () {
749 Vector4f a = new Vector4f (1, 2, 3, 4);
750 Vector4f b = new Vector4f (1, 3, 3, 8);
753 if (((Vector4ui)c).X != 0x3F800000)
755 if (((Vector4ui)c).Y != 0x40400000)
757 if (((Vector4ui)c).Z != 0x40400000)
759 if (((Vector4ui)c).W != 0x41800000)
763 public static int test_0_vector4f_andn () {
764 Vector4f a = new Vector4f (1, 2, 3, 4);
765 Vector4f b = new Vector4f (1, 3, 3, 8);
766 Vector4f c = Vector4f.AndNot (a ,b);
768 if (((Vector4ui)c).X != 0)
770 if (((Vector4ui)c).Y != 0x400000)
772 if (((Vector4ui)c).Z != 0)
774 if (((Vector4ui)c).W != 0x1000000)
779 public static int test_0_vector4f_and () {
780 Vector4f a = new Vector4f (1, 2, 3, 4);
781 Vector4f b = new Vector4f (1, 3, 3, 8);
784 if (((Vector4ui)c).X != 0x3F800000)
786 if (((Vector4ui)c).Y != 0x40000000)
788 if (((Vector4ui)c).Z != 0x40400000)
790 if (((Vector4ui)c).W != 0x40000000)
795 public static int test_0_vector4f_cmpord () {
796 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
797 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
798 Vector4f c = Vector4f.CompareOrdered (a, b);
800 if (((Vector4ui)c).X != 0)
802 if (((Vector4ui)c).Y != 0)
804 if (((Vector4ui)c).Z != 0xFFFFFFFF)
806 if (((Vector4ui)c).W != 0xFFFFFFFF)
811 public static int test_0_vector4f_cmpnle () {
812 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
813 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
814 Vector4f c = Vector4f.CompareNotLessEqual (a, b);
816 if (((Vector4ui)c).X != 0xFFFFFFFF)
818 if (((Vector4ui)c).Y != 0xFFFFFFFF)
820 if (((Vector4ui)c).Z != 0)
822 if (((Vector4ui)c).W != 0)
827 public static int test_0_vector4f_cmpnlt () {
828 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
829 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
830 Vector4f c = Vector4f.CompareNotLessThan (a, b);
832 if (((Vector4ui)c).X != 0xFFFFFFFF)
834 if (((Vector4ui)c).Y != 0xFFFFFFFF)
836 if (((Vector4ui)c).Z != 0xFFFFFFFF)
838 if (((Vector4ui)c).W != 0)
843 public static int test_0_vector4f_cmpneq () {
844 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
845 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
846 Vector4f c = Vector4f.CompareNotEqual (a, b);
848 if (((Vector4ui)c).X != 0xFFFFFFFF)
850 if (((Vector4ui)c).Y != 0xFFFFFFFF)
852 if (((Vector4ui)c).Z != 0)
854 if (((Vector4ui)c).W != 0xFFFFFFFF)
859 public static int test_0_vector4f_cmpunord () {
860 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
861 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
862 Vector4f c = Vector4f.CompareUnordered (a, b);
864 if (((Vector4ui)c).X != 0xFFFFFFFF)
866 if (((Vector4ui)c).Y != 0xFFFFFFFF)
868 if (((Vector4ui)c).Z != 0)
870 if (((Vector4ui)c).W != 0)
875 public static int test_0_vector4f_cmple () {
876 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
877 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
878 Vector4f c = Vector4f.CompareLessEqual (a, b);
880 if (((Vector4ui)c).X != 0)
882 if (((Vector4ui)c).Y != 0)
884 if (((Vector4ui)c).Z != 0xFFFFFFFF)
886 if (((Vector4ui)c).W != 0xFFFFFFFF)
891 public static int test_0_vector4f_cmplt () {
892 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
893 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
894 Vector4f c = Vector4f.CompareLessThan (a, b);
896 if (((Vector4ui)c).X != 0)
898 if (((Vector4ui)c).Y != 0)
900 if (((Vector4ui)c).Z != 0)
902 if (((Vector4ui)c).W != 0xFFFFFFFF)
907 public static int test_0_vector4f_cmpeq () {
908 Vector4f a = new Vector4f (float.NaN, 2, 3, 6);
909 Vector4f b = new Vector4f (1, float.NaN, 3, 4);
910 Vector4f c = Vector4f.CompareEqual (a, b);
912 if (((Vector4ui)c).X != 0)
914 if (((Vector4ui)c).Y != 0)
916 if (((Vector4ui)c).Z != 0xFFFFFFFF)
918 if (((Vector4ui)c).W != 0)
923 public static int test_0_vector4ui_sar () {
924 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
926 Vector4ui c = Vector4ui.ShiftRightArithmetic (a, 2);
928 if (c.X != 0xFC000000)
939 public static int test_0_vector4ui_unpack_high () {
940 Vector4ui a = new Vector4ui (1,2,3,4);
941 Vector4ui b = new Vector4ui (5,6,7,8);
943 Vector4ui c = Vector4ui.UnpackHigh(a, b);
956 public static int test_0_vector4ui_unpack_low () {
957 Vector4ui a = new Vector4ui (1,2,3,4);
958 Vector4ui b = new Vector4ui (5,6,7,8);
960 Vector4ui c = Vector4ui.UnpackLow (a, b);
973 public static int test_0_vector4ui_xor () {
974 Vector4ui a = new Vector4ui (1,2,3,4);
975 Vector4ui b = new Vector4ui (7,5,3,1);
990 public static int test_0_vector4ui_or () {
991 Vector4ui a = new Vector4ui (1,2,3,4);
992 Vector4ui b = new Vector4ui (7,5,3,1);
1006 public static int test_0_vector4ui_and () {
1007 Vector4ui a = new Vector4ui (1,2,3,4);
1008 Vector4ui b = new Vector4ui (7,5,3,1);
1010 Vector4ui c = a & b;
1023 public static int test_0_vector4ui_shr () {
1024 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1026 Vector4ui c = a >> 2;
1028 if (c.X != 0x3C000000)
1039 public static int test_0_vector4ui_shl () {
1040 Vector4ui a = new Vector4ui (10,20,3,40);
1042 Vector4ui c = a << 2;
1055 public static int test_0_vector4ui_mul () {
1056 Vector4ui a = new Vector4ui (0x8888,20,3,40);
1057 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1059 Vector4ui c = a * b;
1061 if (c.X != 0xffff7800)
1071 public static int test_0_vector4ui_sub () {
1072 Vector4ui a = new Vector4ui (1,20,3,40);
1073 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1075 Vector4ui c = a - b;
1077 if (c.X != 0xff0101)
1088 public static int test_0_vector4ui_add () {
1089 Vector4ui a = new Vector4ui (0xFF00FF00u,2,3,4);
1090 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1092 Vector4ui c = a + b;
1094 if (c.X != 0xfe01fe00)
1106 static int test_0_vector4ui_accessors () {
1107 Vector4ui a = new Vector4ui (1,2,3,4);
1133 static int test_0_vector8us_sub_sat () {
1134 Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
1135 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1136 Vector8us c = Vector8us.SubWithSaturation (a, b);
1157 static int test_0_vector8us_add_sat () {
1158 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1159 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1160 Vector8us c = Vector8us.AddWithSaturation (a, b);
1181 static int test_0_vector8us_unpack_low () {
1182 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1183 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
1184 Vector8us c = Vector8us.UnpackLow (a, b);
1206 static int test_0_vector8us_shift_left () {
1207 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1209 Vector8us c = a << amt;
1220 static int test_0_vector8us_shift_right_arithmetic () {
1221 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1223 Vector8us c = Vector8us.ShiftRightArithmetic (a, amt);
1234 static int test_0_vector8us_shift_variable_offset () {
1236 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1238 Vector8us c = b >> off;
1255 static int test_0_vector8us_shift_operand_is_live_after_op () {
1256 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1258 Vector8us c = b >> 2;
1274 static int test_0_vector8us_shr_constant () {
1275 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1276 Vector8us c = a >> 2;
1287 static int test_0_vector8us_mul () {
1288 Vector8us a = new Vector8us (0x0F00,4,5,6,7,8,9,10);
1289 Vector8us b = new Vector8us (0x0888,1,2,3,4,5,6,8);
1291 Vector8us c = a * b;
1301 static int test_0_vector8us_add () {
1302 Vector8us a = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1303 Vector8us b = new Vector8us (0x8888,1,2,3,4,5,6,8);
1305 Vector8us c = a + b;
1316 static int test_0_vector8us_sub () {
1317 Vector8us a = new Vector8us (3,4,5,6,7,8,9,10);
1318 Vector8us b = new Vector8us (10,1,2,3,4,5,6,8);
1320 Vector8us c = a - b;
1332 static int test_0_vector8us_accessors () {
1333 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1381 static int test_0_vector16b_unpack_high () {
1382 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1383 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1384 Vector16b c = Vector16b.UnpackHigh (a, b);
1405 static int test_0_vector16b_unpack_low () {
1406 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1407 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1408 Vector16b c = Vector16b.UnpackLow (a, b);
1429 static int test_0_vector16b_sub_sat () {
1430 Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1431 Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1432 Vector16b c = Vector16b.SubWithSaturation (a, b);
1443 static int test_0_vector16b_add_sat () {
1444 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1445 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1446 Vector16b c = Vector16b.AddWithSaturation (a, b);
1457 static int test_0_vector16b_add_ovf () {
1458 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1459 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1460 Vector16b c = a + b;
1471 static int test_0_vector16b_accessors () {
1472 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1559 public static int test_0_accessors () {
1560 Vector4f a = new Vector4f (1, 2, 3, 4);
1572 public static int test_0_packed_add_with_stack_tmp () {
1573 Vector4f a = new Vector4f (1, 2, 3, 4);
1574 Vector4f b = new Vector4f (5, 6, 7, 8);
1575 Vector4f c = new Vector4f (-1, -3, -4, -5);
1576 Vector4f d = a + b + c;
1588 public static int test_0_simple_packed_add () {
1589 Vector4f a = new Vector4f (1, 2, 3, 4);
1590 Vector4f b = new Vector4f (5, 6, 7, 8);
1604 public static int test_0_simple_packed_sub () {
1605 Vector4f a = new Vector4f (1, 2, 3, 4);
1606 Vector4f b = new Vector4f (5, 6, 7, 8);
1619 public static int test_0_simple_packed_mul () {
1620 Vector4f a = new Vector4f (1, 2, 3, 4);
1621 Vector4f b = new Vector4f (5, 6, 7, 8);
1634 public static int test_0_simple_packed_div () {
1635 Vector4f a = new Vector4f (2, 2, 3, 4);
1636 Vector4f b = new Vector4f (20, 10, 33, 12);
1649 public static int test_0_simple_packed_sqrt () {
1650 Vector4f a = new Vector4f (16, 4, 9, 25);
1651 a = Vector4f.Sqrt (a);
1663 public static int test_0_simple_packed_invsqrt () {
1664 Vector4f a = new Vector4f (16, 4, 100, 25);
1665 //this function has VERY low precision
1666 a = Vector4f.InvSqrt (a);
1667 if (a.X < (1/4f - 0.01f) || a.X > (1/4f + 0.01f))
1669 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
1671 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
1673 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
1678 public static int test_0_simple_packed_min () {
1679 Vector4f a = new Vector4f (16, -4, 9, 25);
1680 Vector4f b = new Vector4f (5, 3, 9, 0);
1681 Vector4f c = Vector4f.Min (a, b);
1693 public static int test_0_simple_packed_max () {
1694 Vector4f a = new Vector4f (16, -4, 9, 25);
1695 Vector4f b = new Vector4f (5, 3, 9, 0);
1696 Vector4f c = Vector4f.Max (a, b);
1708 public static int test_0_simple_packed_hadd () {
1709 Vector4f a = new Vector4f (5, 5, 6, 6);
1710 Vector4f b = new Vector4f (7, 7, 8, 8);
1711 Vector4f c = Vector4f.HorizontalAdd (a, b);
1723 public static int test_0_simple_packed_hsub () {
1724 Vector4f a = new Vector4f (5, 2, 6, 1);
1725 Vector4f b = new Vector4f (7, 0, 8, 3);
1726 Vector4f c = Vector4f.HorizontalSub (a, b);
1738 public static int test_0_simple_packed_addsub () {
1739 Vector4f a = new Vector4f (5, 2, 6, 1);
1740 Vector4f b = new Vector4f (7, 0, 8, 3);
1741 Vector4f c = Vector4f.AddSub (a, b);
1753 public static int test_0_simple_packed_shuffle () {
1754 Vector4f a = new Vector4f (1, 2, 3, 4);
1755 a = Vector4f.Shuffle(a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1767 public static int test_0_packed_shuffle_with_reg_pressure () {
1768 Vector4f v = new Vector4f (1, 2, 3, 4);
1769 Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
1770 if (ff) v = v + v -v ;
1772 Vector4f r0 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1773 Vector4f r1 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1774 Vector4f x = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1775 Vector4f r2 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1776 Vector4f r3 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1784 Vector4f result = r0 + r1 + r2 + r3;
1794 if (result.Y != result.Y)
1799 public static int test_24_regs_pressure_a () {
1800 Vector4f a = new Vector4f (1, 2, 3, 4);
1808 public static int test_54_regs_pressure_b () {
1809 Vector4f a = new Vector4f (1, 2, 3, 4);
1813 Vector4f e = a + b + c;
1814 Vector4f f = d - b + a - c;
1815 Vector4f g = a - d * f - c + b;
1816 Vector4f h = a * b - c + e;
1817 Vector4f i = h - g - f - e - d - c - b - a;
1818 Vector4f j = a + b + c + d + e + f + g + h + i;
1823 public static int test_3_single_block_var_is_properly_promoted () {
1824 Vector4f a = new Vector4f (4, 5, 6, 7);
1828 Vector4f b = new Vector4f (1, 2, 3, 4);
1839 static float float_val = 45f;
1841 public static int test_0_sse2_opt_and_simd_intrinsic_proper_regalloc () {
1842 Vector4f v = new Vector4f (1, 2, 3, 4);
1843 float f = float_val;
1852 public static int Main () {
1853 return TestDriver.RunTests (typeof (SimdTests));