4 public class SimdTests {
5 public static int test_0_vector4ui_sar () {
6 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
8 Vector4ui c = Vector4ui.ShiftRightArithmetic (a, 2);
10 if (c.X != 0xFC000000)
21 public static int test_0_vector4ui_unpack_high () {
22 Vector4ui a = new Vector4ui (1,2,3,4);
23 Vector4ui b = new Vector4ui (5,6,7,8);
25 Vector4ui c = Vector4ui.UnpackHigh(a, b);
38 public static int test_0_vector4ui_unpack_low () {
39 Vector4ui a = new Vector4ui (1,2,3,4);
40 Vector4ui b = new Vector4ui (5,6,7,8);
42 Vector4ui c = Vector4ui.UnpackLow (a, b);
55 public static int test_0_vector4ui_xor () {
56 Vector4ui a = new Vector4ui (1,2,3,4);
57 Vector4ui b = new Vector4ui (7,5,3,1);
72 public static int test_0_vector4ui_or () {
73 Vector4ui a = new Vector4ui (1,2,3,4);
74 Vector4ui b = new Vector4ui (7,5,3,1);
88 public static int test_0_vector4ui_and () {
89 Vector4ui a = new Vector4ui (1,2,3,4);
90 Vector4ui b = new Vector4ui (7,5,3,1);
105 public static int test_0_vector4ui_shr () {
106 Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
108 Vector4ui c = a >> 2;
110 if (c.X != 0x3C000000)
121 public static int test_0_vector4ui_shl () {
122 Vector4ui a = new Vector4ui (10,20,3,40);
124 Vector4ui c = a << 2;
137 public static int test_0_vector4ui_mul () {
138 Vector4ui a = new Vector4ui (0x8888,20,3,40);
139 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
143 if (c.X != 0xffff7800)
153 public static int test_0_vector4ui_sub () {
154 Vector4ui a = new Vector4ui (1,20,3,40);
155 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
170 public static int test_0_vector4ui_add () {
171 Vector4ui a = new Vector4ui (0xFF00FF00u,2,3,4);
172 Vector4ui b = new Vector4ui (0xFF00FF00u,2,3,4);
176 if (c.X != 0xfe01fe00)
188 static int test_0_vector4ui_accessors () {
189 Vector4ui a = new Vector4ui (1,2,3,4);
215 static int test_0_vector8us_sub_sat () {
216 Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
217 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
218 Vector8us c = Vector8us.SubWithSaturation (a, b);
239 static int test_0_vector8us_add_sat () {
240 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
241 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
242 Vector8us c = Vector8us.AddWithSaturation (a, b);
263 static int test_0_vector8us_unpack_low () {
264 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
265 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
266 Vector8us c = Vector8us.UnpackLow (a, b);
288 static int test_0_vector8us_shift_left () {
289 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
291 Vector8us c = a << amt;
302 static int test_0_vector8us_shift_right_arithmetic () {
303 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
305 Vector8us c = Vector8us.ShiftRightArithmetic (a, amt);
316 static int test_0_vector8us_shift_variable_offset () {
318 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
320 Vector8us c = b >> off;
337 static int test_0_vector8us_shift_operand_is_live_after_op () {
338 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
340 Vector8us c = b >> 2;
356 static int test_0_vector8us_shr_constant () {
357 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
358 Vector8us c = a >> 2;
369 static int test_0_vector8us_mul () {
370 Vector8us a = new Vector8us (0x0F00,4,5,6,7,8,9,10);
371 Vector8us b = new Vector8us (0x0888,1,2,3,4,5,6,8);
383 static int test_0_vector8us_add () {
384 Vector8us a = new Vector8us (0xFF00,4,5,6,7,8,9,10);
385 Vector8us b = new Vector8us (0x8888,1,2,3,4,5,6,8);
398 static int test_0_vector8us_sub () {
399 Vector8us a = new Vector8us (3,4,5,6,7,8,9,10);
400 Vector8us b = new Vector8us (10,1,2,3,4,5,6,8);
414 static int test_0_vector8us_accessors () {
415 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
463 static int test_0_vector16b_unpack_high () {
464 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
465 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
466 Vector16b c = Vector16b.UnpackHigh (a, b);
487 static int test_0_vector16b_unpack_low () {
488 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
489 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
490 Vector16b c = Vector16b.UnpackLow (a, b);
511 static int test_0_vector16b_sar () {
512 Vector16b a = new Vector16b (0xF0,20,3,40,0,0,0,0,0,0,0,0,0,0,0,0);
514 Vector16b c = Vector16b.ShiftRightArithmetic (a, 2);
526 static int test_0_vector16b_sub_sat () {
527 Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
528 Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
529 Vector16b c = Vector16b.SubWithSaturation (a, b);
540 static int test_0_vector16b_add_sat () {
541 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
542 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
543 Vector16b c = Vector16b.AddWithSaturation (a, b);
554 static int test_0_vector16b_add_ovf () {
555 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
556 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
568 static int test_0_vector16b_accessors () {
569 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
656 public static int test_0_accessors () {
657 Vector4f a = new Vector4f (1, 2, 3, 4);
669 public static int test_0_packed_add_with_stack_tmp () {
670 Vector4f a = new Vector4f (1, 2, 3, 4);
671 Vector4f b = new Vector4f (5, 6, 7, 8);
672 Vector4f c = new Vector4f (-1, -3, -4, -5);
673 Vector4f d = a + b + c;
685 public static int test_0_simple_packed_add () {
686 Vector4f a = new Vector4f (1, 2, 3, 4);
687 Vector4f b = new Vector4f (5, 6, 7, 8);
701 public static int test_0_simple_packed_sub () {
702 Vector4f a = new Vector4f (1, 2, 3, 4);
703 Vector4f b = new Vector4f (5, 6, 7, 8);
716 public static int test_0_simple_packed_mul () {
717 Vector4f a = new Vector4f (1, 2, 3, 4);
718 Vector4f b = new Vector4f (5, 6, 7, 8);
731 public static int test_0_simple_packed_div () {
732 Vector4f a = new Vector4f (2, 2, 3, 4);
733 Vector4f b = new Vector4f (20, 10, 33, 12);
746 public static int test_0_simple_packed_sqrt () {
747 Vector4f a = new Vector4f (16, 4, 9, 25);
748 a = Vector4f.Sqrt (a);
760 public static int test_0_simple_packed_invsqrt () {
761 Vector4f a = new Vector4f (16, 4, 100, 25);
762 //this function has VERY low precision
763 a = Vector4f.InvSqrt (a);
764 if (a.X < (1/4f - 0.01f) || a.X > (1/4f + 0.01f))
766 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
768 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
770 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
775 public static int test_0_simple_packed_min () {
776 Vector4f a = new Vector4f (16, -4, 9, 25);
777 Vector4f b = new Vector4f (5, 3, 9, 0);
778 Vector4f c = Vector4f.Min (a, b);
790 public static int test_0_simple_packed_max () {
791 Vector4f a = new Vector4f (16, -4, 9, 25);
792 Vector4f b = new Vector4f (5, 3, 9, 0);
793 Vector4f c = Vector4f.Max (a, b);
805 public static int test_0_simple_packed_hadd () {
806 Vector4f a = new Vector4f (5, 5, 6, 6);
807 Vector4f b = new Vector4f (7, 7, 8, 8);
808 Vector4f c = Vector4f.HorizontalAdd (a, b);
820 public static int test_0_simple_packed_hsub () {
821 Vector4f a = new Vector4f (5, 2, 6, 1);
822 Vector4f b = new Vector4f (7, 0, 8, 3);
823 Vector4f c = Vector4f.HorizontalSub (a, b);
835 public static int test_0_simple_packed_addsub () {
836 Vector4f a = new Vector4f (5, 2, 6, 1);
837 Vector4f b = new Vector4f (7, 0, 8, 3);
838 Vector4f c = Vector4f.AddSub (a, b);
850 public static int test_0_simple_packed_shuffle () {
851 Vector4f a = new Vector4f (1, 2, 3, 4);
852 a = Vector4f.Shuffle(a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
864 public static int test_0_packed_shuffle_with_reg_pressure () {
865 Vector4f v = new Vector4f (1, 2, 3, 4);
866 Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
867 if (ff) v = v + v -v ;
869 Vector4f r0 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
870 Vector4f r1 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
871 Vector4f x = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
872 Vector4f r2 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
873 Vector4f r3 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
881 Vector4f result = r0 + r1 + r2 + r3;
891 if (result.Y != result.Y)
896 public static int test_24_regs_pressure_a () {
897 Vector4f a = new Vector4f (1, 2, 3, 4);
905 public static int test_54_regs_pressure_b () {
906 Vector4f a = new Vector4f (1, 2, 3, 4);
910 Vector4f e = a + b + c;
911 Vector4f f = d - b + a - c;
912 Vector4f g = a - d * f - c + b;
913 Vector4f h = a * b - c + e;
914 Vector4f i = h - g - f - e - d - c - b - a;
915 Vector4f j = a + b + c + d + e + f + g + h + i;
920 public static int test_3_single_block_var_is_properly_promoted () {
921 Vector4f a = new Vector4f (4, 5, 6, 7);
925 Vector4f b = new Vector4f (1, 2, 3, 4);
936 static float float_val = 45f;
938 public static int test_0_sse2_opt_and_simd_intrinsic_proper_regalloc () {
939 Vector4f v = new Vector4f (1, 2, 3, 4);
949 public static int Main () {
950 return TestDriver.RunTests (typeof (SimdTests));