4 public class SimdTests {
6 public static unsafe int test_vector16sb_sub_sat () {
7 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
8 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
10 Vector16sb c = Vector16sb.SubWithSaturation (a, b);
31 public static unsafe int test_vector16sb_add_sat () {
32 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
33 Vector16sb b = new Vector16sb (100, -100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
35 Vector16sb c = Vector16sb.AddWithSaturation (a, b);
56 public static unsafe int test_vector16sb_cmp_gt () {
57 Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
58 Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
60 Vector16sb c = Vector16sb.CompareGreaterThan (a, b);
80 public static int test_0_vector4ui_pack_with_sat () {
81 Vector4ui a = new Vector4ui (0xF0000000,0xF0000,3,4);
82 Vector4ui b = new Vector4ui (5,6,7,8);
84 Vector8us c = Vector4ui.SignedPackWithUnsignedSaturation (a, b);
105 public static int test_0_vector8us_pack_with_sat () {
106 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
107 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
108 Vector16b c = Vector8us.SignedPackWithUnsignedSaturation (a, b);
123 public static int test_0_vector8us_mul_high () {
124 Vector8us a = new Vector8us (0xFF00, 2, 3, 0, 5, 6, 5, 4);
125 Vector8us b = new Vector8us (0xFF00, 2, 1, 2, 3, 6, 5, 6);
126 Vector8us c = Vector8us.MultiplyStoreHigh (a, b);
147 public static int test_0_vector8us_cmpeq () {
148 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
149 Vector8us b = new Vector8us (9, 2, 1, 2, 3, 6, 5, 6);
150 Vector8us c = Vector8us.CompareEqual (a, b);
172 public static int test_0_vector4ui_cmpeq () {
173 Vector4ui a = new Vector4ui (6,1,6,3);
174 Vector4ui b = new Vector4ui (3,4,6,7);
175 Vector4ui c = Vector4ui.CompareEqual (a, b);
181 if (c.Z != 0xFFFFFFFF)
188 public static int test_0_vector4ui_shuffle () {
189 Vector4ui a = new Vector4ui (1,2,3,4);
190 Vector4ui c = Vector4ui.Shuffle (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
203 public static int test_0_vector4ui_extract_mask () {
204 Vector4ui a = new Vector4ui (0xFF00FF00,0x0F0FAA99,0,0);
205 int c = Vector4ui.ExtractByteMask (a);
212 public static int test_0_vector4ui_min () {
213 Vector4ui a = new Vector4ui (6,1,6,3);
214 Vector4ui b = new Vector4ui (3,4,6,7);
215 Vector4ui c = Vector4ui.Min (a, b);
228 public static int test_0_vector4ui_max () {
229 Vector4ui a = new Vector4ui (6,1,6,3);
230 Vector4ui b = new Vector4ui (3,4,6,7);
231 Vector4ui c = Vector4ui.Max (a, b);
244 public static int vector16b_cmpeq () {
245 Vector16b a = new Vector16b (1,0,9,0,0,0,0,0,0,0,0,0,0,0,0,1);
246 Vector16b b = new Vector16b (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
247 Vector16b c = Vector16b.CompareEqual (a, b);
285 public static int vector16b_sum_abs_diff () {
286 Vector16b a = new Vector16b (100,20,20,20,0,0,0,0,0,0,0,0,0,0, 0, 0);
287 Vector16sb b = new Vector16sb (0, 10,10,10,0,0,0,0,0,0,0,0,0,0,10,10);
288 Vector8us c = Vector16b.SumOfAbsoluteDifferences (a, b);
310 public static int test_0_vector16b_extract_mask () {
311 Vector16b a = new Vector16b (0xF0,0,0xF0,0,0,0,0xF0,0xAA,0x0F,0,0xFF,0,0,0,0,0);
312 int c = Vector16b.ExtractByteMask (a);
319 public static int test_0_vector16b_min () {
320 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
321 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
322 Vector16b c = Vector16b.Min (a, b);
359 public static int test_0_vector16b_max () {
360 Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
361 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
362 Vector16b c = Vector16b.Max (a, b);
398 public static int test_0_vector16b_avg () {
399 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
400 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
401 Vector16b c = Vector16b.Average (a, b);
439 static unsafe Vector8us bad_method_regression_2 (Vector16b va, Vector16b vb) {
440 Vector8us res = new Vector8us ();
441 byte *a = (byte*)&va;
442 byte *b = (byte*)&vb;
445 for (int i = 0; i < 8; ++i)
446 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
447 res.V0 = (ushort)tmp;
450 for (int i = 0; i < 8; ++i)
451 tmp += System.Math.Abs ((int)*a++ - (int)*b++);
452 res.V4 = (ushort)tmp;
456 /*This bug was caused the simplifier not taking notice of LDADDR on the remaining blocks.*/
457 public static int test_2_local_simplifier_regression_other_blocks () {
458 Vector16b a = new Vector16b (1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1);
459 Vector16b b = new Vector16b (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
460 Vector8us res = bad_method_regression_2 (a,b);
461 return (int)res.V0 + res.V4;
464 static unsafe Vector8us bad_method_regression (Vector16b va, Vector16b vb) {
465 Vector8us res = new Vector8us ();
466 byte *a = (byte*)&va;
467 byte *b = (byte*)&vb;
468 *((ushort*)&res) = 10;
479 /*This bug was caused the simplifier not taking notice of LDADDR on the first block.*/
480 public static int test_10_local_simplifier_regression_first_block () {
481 Vector16b a = new Vector16b ();
482 Vector16b b = new Vector16b ();
483 Vector8us res = bad_method_regression (a,b);
488 public static int test_0_vecto8us_extract_mask () {
489 Vector8us a = new Vector8us (0xF0F0, 0x700F, 0xAABB, 0x0000, 0x00F0, 0xF0F0, 0, 0);
490 int c = Vector8us.ExtractByteMask (a);
497 public static int test_0_vecto8us_shuffle_low () {
498 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
499 Vector8us c = Vector8us.ShuffleLow (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
520 public static int test_0_vecto8us_shuffle_high () {
521 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
522 Vector8us c = Vector8us.ShuffleHigh (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
544 public static int test_0_vecto8us_max () {
545 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
546 Vector8us b = new Vector8us (9, 1, 1, 2, 9, 6, 5, 1000);
547 Vector8us c = Vector8us.Max (a, b);
569 public static int test_0_vecto8us_min () {
570 Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
571 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
572 Vector8us c = Vector8us.Min (a, b);
593 public static int test_0_vecto8us_avg () {
594 Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
595 Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
596 Vector8us c = Vector8us.Average (a, b);
617 static void store_helper (ref Vector4f x) {
619 k = new Vector4f(9,9,9,9);
623 public static int test_0_vector4f_byref_store ()
626 k = new Vector4f(1,2,3,4);
627 store_helper (ref k);
633 public static int test_0_vector4f_init_array_element ()
635 Vector4f[] v = new Vector4f[1];
636 v[0] = new Vector4f(9,9,9,9);
642 public static int test_0_vector4f_dup_high () {
643 Vector4f a = new Vector4f (1, 2, 3, 4);
644 Vector4f c = Vector4f.DuplicateHigh(a);
657 public static int test_0_vector4f_dup_low () {
658 Vector4f a = new Vector4f (1, 2, 3, 4);
659 Vector4f c = Vector4f.DuplicateLow (a);
673 public static int test_0_vector4f_interleave_high () {
674 Vector4f a = new Vector4f (1, 2, 3, 4);
675 Vector4f b = new Vector4f (5, 6, 7, 8);
676 Vector4f c = Vector4f.InterleaveHigh (a, b);
689 public static int test_0_vector4f_interleave_low () {
690 Vector4f a = new Vector4f (1, 2, 3, 4);
691 Vector4f b = new Vector4f (5, 6, 7, 8);
692 Vector4f c = Vector4f.InterleaveLow (a, b);
705 public static int test_0_vector4f_rcp () {
706 Vector4f a = new Vector4f (1, 2, 4, 8);
707 Vector4f c = Vector4f.Reciprocal (a);
709 //Test with ranges due to the terrible precision.
710 if (c.X < (1 - 0.01f) || c.X > (1 + 0.01f))
712 if (c.Y < (0.5 - 0.01f) || c.Y > (0.5 + 0.01f))
714 if (c.Z < (0.25 - 0.01f) || c.Z > (0.25 + 0.01f))
716 if (c.W < (0.125 - 0.01f) || c.W > (0.125 + 0.01f))
721 public static int test_0_vector4f_xor () {
722 Vector4f a = new Vector4f (1, 2, 3, 4);
723 Vector4f b = new Vector4f (1, 3, 3, 8);
726 if (((Vector4ui)c).X != 0)
728 if (((Vector4ui)c).Y != 0x400000)
730 if (((Vector4ui)c).Z != 0)
732 if (((Vector4ui)c).W != 0x1800000)
737 public static int test_0_vector4f_or () {
738 Vector4f a = new Vector4f (1, 2, 3, 4);
739 Vector4f b = new Vector4f (1, 3, 3, 8);
742 if (((Vector4ui)c).X != 0x3F800000)
744 if (((Vector4ui)c).Y != 0x40400000)
746 if (((Vector4ui)c).Z != 0x40400000)
748 if (((Vector4ui)c).W != 0x41800000)
752 public static int test_0_vector4f_andn () {
753 Vector4f a = new Vector4f (1, 2, 3, 4);
754 Vector4f b = new Vector4f (1, 3, 3, 8);
755 Vector4f c = Vector4f.AndNot (a ,b);
757 if (((Vector4ui)c).X != 0)
759 if (((Vector4ui)c).Y != 0x400000)
761 if (((Vector4ui)c).Z != 0)
763 if (((Vector4ui)c).W != 0x1000000)
768 public static int test_0_vector4f_and () {
769 Vector4f a = new Vector4f (1, 2, 3, 4);
770 Vector4f b = new Vector4f (1, 3, 3, 8);
773 if (((Vector4ui)c).X != 0x3F800000)
775 if (((Vector4ui)c).Y != 0x40000000)
777 if (((Vector4ui)c).Z != 0x40400000)
779 if (((Vector4ui)c).W != 0x40000000)
784 public static int test_0_vector4f_cmpord () {
785 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
786 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
787 Vector4f c = Vector4f.CompareOrdered (a, b);
789 if (((Vector4ui)c).X != 0)
791 if (((Vector4ui)c).Y != 0)
793 if (((Vector4ui)c).Z != 0xFFFFFFFF)
795 if (((Vector4ui)c).W != 0xFFFFFFFF)
800 public static int test_0_vector4f_cmpnle () {
801 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
802 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
803 Vector4f c = Vector4f.CompareNotLessEqual (a, b);
805 if (((Vector4ui)c).X != 0xFFFFFFFF)
807 if (((Vector4ui)c).Y != 0xFFFFFFFF)
809 if (((Vector4ui)c).Z != 0)
811 if (((Vector4ui)c).W != 0)
816 public static int test_0_vector4f_cmpnlt () {
817 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
818 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
819 Vector4f c = Vector4f.CompareNotLessThan (a, b);
821 if (((Vector4ui)c).X != 0xFFFFFFFF)
823 if (((Vector4ui)c).Y != 0xFFFFFFFF)
825 if (((Vector4ui)c).Z != 0xFFFFFFFF)
827 if (((Vector4ui)c).W != 0)
832 public static int test_0_vector4f_cmpneq () {
833 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
834 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
835 Vector4f c = Vector4f.CompareNotEqual (a, b);
837 if (((Vector4ui)c).X != 0xFFFFFFFF)
839 if (((Vector4ui)c).Y != 0xFFFFFFFF)
841 if (((Vector4ui)c).Z != 0)
843 if (((Vector4ui)c).W != 0xFFFFFFFF)
848 public static int test_0_vector4f_cmpunord () {
849 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
850 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
851 Vector4f c = Vector4f.CompareUnordered (a, b);
853 if (((Vector4ui)c).X != 0xFFFFFFFF)
855 if (((Vector4ui)c).Y != 0xFFFFFFFF)
857 if (((Vector4ui)c).Z != 0)
859 if (((Vector4ui)c).W != 0)
864 public static int test_0_vector4f_cmple () {
865 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
866 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
867 Vector4f c = Vector4f.CompareLessEqual (a, b);
869 if (((Vector4ui)c).X != 0)
871 if (((Vector4ui)c).Y != 0)
873 if (((Vector4ui)c).Z != 0xFFFFFFFF)
875 if (((Vector4ui)c).W != 0xFFFFFFFF)
880 public static int test_0_vector4f_cmplt () {
881 Vector4f a = new Vector4f (float.NaN, 2, 3, 4);
882 Vector4f b = new Vector4f (1, float.NaN, 3, 6);
883 Vector4f c = Vector4f.CompareLessThan (a, b);
885 if (((Vector4ui)c).X != 0)
887 if (((Vector4ui)c).Y != 0)
889 if (((Vector4ui)c).Z != 0)
891 if (((Vector4ui)c).W != 0xFFFFFFFF)
896 public static int test_0_vector4f_cmpeq () {
897 Vector4f a = new Vector4f (float.NaN, 2, 3, 6);
898 Vector4f b = new Vector4f (1, float.NaN, 3, 4);
899 Vector4f c = Vector4f.CompareEqual (a, b);
901 if (((Vector4ui)c).X != 0)
903 if (((Vector4ui)c).Y != 0)
905 if (((Vector4ui)c).Z != 0xFFFFFFFF)
907 if (((Vector4ui)c).W != 0)
912 public static int test_0_vector4ui_sar () {
913 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
915 Vector4ui c = Vector4ui.ShiftRightArithmetic (a, 2);
917 if (c.X != 0xFC000000)
928 public static int test_0_vector4ui_unpack_high () {
929 Vector4ui a = new Vector4ui (1,2,3,4);
930 Vector4ui b = new Vector4ui (5,6,7,8);
932 Vector4ui c = Vector4ui.UnpackHigh(a, b);
945 public static int test_0_vector4ui_unpack_low () {
946 Vector4ui a = new Vector4ui (1,2,3,4);
947 Vector4ui b = new Vector4ui (5,6,7,8);
949 Vector4ui c = Vector4ui.UnpackLow (a, b);
962 public static int test_0_vector4ui_xor () {
963 Vector4ui a = new Vector4ui (1,2,3,4);
964 Vector4ui b = new Vector4ui (7,5,3,1);
979 public static int test_0_vector4ui_or () {
980 Vector4ui a = new Vector4ui (1,2,3,4);
981 Vector4ui b = new Vector4ui (7,5,3,1);
995 public static int test_0_vector4ui_and () {
996 Vector4ui a = new Vector4ui (1,2,3,4);
997 Vector4ui b = new Vector4ui (7,5,3,1);
1012 public static int test_0_vector4ui_shr () {
1013 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
1015 Vector4ui c = a >> 2;
1017 if (c.X != 0x3C000000)
1028 public static int test_0_vector4ui_shl () {
1029 Vector4ui a = new Vector4ui (10,20,3,40);
1031 Vector4ui c = a << 2;
1044 public static int test_0_vector4ui_mul () {
1045 Vector4ui a = new Vector4ui (0x8888,20,3,40);
1046 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1048 Vector4ui c = a * b;
1050 if (c.X != 0xffff7800)
1060 public static int test_0_vector4ui_sub () {
1061 Vector4ui a = new Vector4ui (1,20,3,40);
1062 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1064 Vector4ui c = a - b;
1066 if (c.X != 0xff0101)
1077 public static int test_0_vector4ui_add () {
1078 Vector4ui a = new Vector4ui (0xFF00FF00u,2,3,4);
1079 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
1081 Vector4ui c = a + b;
1083 if (c.X != 0xfe01fe00)
1095 static int test_0_vector4ui_accessors () {
1096 Vector4ui a = new Vector4ui (1,2,3,4);
1122 static int test_0_vector8us_sub_sat () {
1123 Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
1124 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1125 Vector8us c = Vector8us.SubWithSaturation (a, b);
1146 static int test_0_vector8us_add_sat () {
1147 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1148 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1149 Vector8us c = Vector8us.AddWithSaturation (a, b);
1170 static int test_0_vector8us_unpack_low () {
1171 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1172 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
1173 Vector8us c = Vector8us.UnpackLow (a, b);
1195 static int test_0_vector8us_shift_left () {
1196 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1198 Vector8us c = a << amt;
1209 static int test_0_vector8us_shift_right_arithmetic () {
1210 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
1212 Vector8us c = Vector8us.ShiftRightArithmetic (a, amt);
1223 static int test_0_vector8us_shift_variable_offset () {
1225 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1227 Vector8us c = b >> off;
1244 static int test_0_vector8us_shift_operand_is_live_after_op () {
1245 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1247 Vector8us c = b >> 2;
1263 static int test_0_vector8us_shr_constant () {
1264 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
1265 Vector8us c = a >> 2;
1276 static int test_0_vector8us_mul () {
1277 Vector8us a = new Vector8us (0x0F00,4,5,6,7,8,9,10);
1278 Vector8us b = new Vector8us (0x0888,1,2,3,4,5,6,8);
1280 Vector8us c = a * b;
1290 static int test_0_vector8us_add () {
1291 Vector8us a = new Vector8us (0xFF00,4,5,6,7,8,9,10);
1292 Vector8us b = new Vector8us (0x8888,1,2,3,4,5,6,8);
1294 Vector8us c = a + b;
1305 static int test_0_vector8us_sub () {
1306 Vector8us a = new Vector8us (3,4,5,6,7,8,9,10);
1307 Vector8us b = new Vector8us (10,1,2,3,4,5,6,8);
1309 Vector8us c = a - b;
1321 static int test_0_vector8us_accessors () {
1322 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
1370 static int test_0_vector16b_unpack_high () {
1371 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1372 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1373 Vector16b c = Vector16b.UnpackHigh (a, b);
1394 static int test_0_vector16b_unpack_low () {
1395 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1396 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1397 Vector16b c = Vector16b.UnpackLow (a, b);
1418 static int test_0_vector16b_sub_sat () {
1419 Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1420 Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1421 Vector16b c = Vector16b.SubWithSaturation (a, b);
1432 static int test_0_vector16b_add_sat () {
1433 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1434 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1435 Vector16b c = Vector16b.AddWithSaturation (a, b);
1446 static int test_0_vector16b_add_ovf () {
1447 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1448 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
1449 Vector16b c = a + b;
1460 static int test_0_vector16b_accessors () {
1461 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
1548 public static int test_0_accessors () {
1549 Vector4f a = new Vector4f (1, 2, 3, 4);
1561 public static int test_0_packed_add_with_stack_tmp () {
1562 Vector4f a = new Vector4f (1, 2, 3, 4);
1563 Vector4f b = new Vector4f (5, 6, 7, 8);
1564 Vector4f c = new Vector4f (-1, -3, -4, -5);
1565 Vector4f d = a + b + c;
1577 public static int test_0_simple_packed_add () {
1578 Vector4f a = new Vector4f (1, 2, 3, 4);
1579 Vector4f b = new Vector4f (5, 6, 7, 8);
1593 public static int test_0_simple_packed_sub () {
1594 Vector4f a = new Vector4f (1, 2, 3, 4);
1595 Vector4f b = new Vector4f (5, 6, 7, 8);
1608 public static int test_0_simple_packed_mul () {
1609 Vector4f a = new Vector4f (1, 2, 3, 4);
1610 Vector4f b = new Vector4f (5, 6, 7, 8);
1623 public static int test_0_simple_packed_div () {
1624 Vector4f a = new Vector4f (2, 2, 3, 4);
1625 Vector4f b = new Vector4f (20, 10, 33, 12);
1638 public static int test_0_simple_packed_sqrt () {
1639 Vector4f a = new Vector4f (16, 4, 9, 25);
1640 a = Vector4f.Sqrt (a);
1652 public static int test_0_simple_packed_invsqrt () {
1653 Vector4f a = new Vector4f (16, 4, 100, 25);
1654 //this function has VERY low precision
1655 a = Vector4f.InvSqrt (a);
1656 if (a.X < (1/4f - 0.01f) || a.X > (1/4f + 0.01f))
1658 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
1660 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
1662 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
1667 public static int test_0_simple_packed_min () {
1668 Vector4f a = new Vector4f (16, -4, 9, 25);
1669 Vector4f b = new Vector4f (5, 3, 9, 0);
1670 Vector4f c = Vector4f.Min (a, b);
1682 public static int test_0_simple_packed_max () {
1683 Vector4f a = new Vector4f (16, -4, 9, 25);
1684 Vector4f b = new Vector4f (5, 3, 9, 0);
1685 Vector4f c = Vector4f.Max (a, b);
1697 public static int test_0_simple_packed_hadd () {
1698 Vector4f a = new Vector4f (5, 5, 6, 6);
1699 Vector4f b = new Vector4f (7, 7, 8, 8);
1700 Vector4f c = Vector4f.HorizontalAdd (a, b);
1712 public static int test_0_simple_packed_hsub () {
1713 Vector4f a = new Vector4f (5, 2, 6, 1);
1714 Vector4f b = new Vector4f (7, 0, 8, 3);
1715 Vector4f c = Vector4f.HorizontalSub (a, b);
1727 public static int test_0_simple_packed_addsub () {
1728 Vector4f a = new Vector4f (5, 2, 6, 1);
1729 Vector4f b = new Vector4f (7, 0, 8, 3);
1730 Vector4f c = Vector4f.AddSub (a, b);
1742 public static int test_0_simple_packed_shuffle () {
1743 Vector4f a = new Vector4f (1, 2, 3, 4);
1744 a = Vector4f.Shuffle(a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1756 public static int test_0_packed_shuffle_with_reg_pressure () {
1757 Vector4f v = new Vector4f (1, 2, 3, 4);
1758 Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
1759 if (ff) v = v + v -v ;
1761 Vector4f r0 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1762 Vector4f r1 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1763 Vector4f x = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1764 Vector4f r2 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1765 Vector4f r3 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
1773 Vector4f result = r0 + r1 + r2 + r3;
1783 if (result.Y != result.Y)
1788 public static int test_24_regs_pressure_a () {
1789 Vector4f a = new Vector4f (1, 2, 3, 4);
1797 public static int test_54_regs_pressure_b () {
1798 Vector4f a = new Vector4f (1, 2, 3, 4);
1802 Vector4f e = a + b + c;
1803 Vector4f f = d - b + a - c;
1804 Vector4f g = a - d * f - c + b;
1805 Vector4f h = a * b - c + e;
1806 Vector4f i = h - g - f - e - d - c - b - a;
1807 Vector4f j = a + b + c + d + e + f + g + h + i;
1812 public static int test_3_single_block_var_is_properly_promoted () {
1813 Vector4f a = new Vector4f (4, 5, 6, 7);
1817 Vector4f b = new Vector4f (1, 2, 3, 4);
1828 static float float_val = 45f;
1830 public static int test_0_sse2_opt_and_simd_intrinsic_proper_regalloc () {
1831 Vector4f v = new Vector4f (1, 2, 3, 4);
1832 float f = float_val;
1841 public static int Main () {
1842 return TestDriver.RunTests (typeof (SimdTests));