4 public class SimdTests {
5 static int test_0_vector8us_pack () {
6 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
7 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
8 Vector16b c = Vector8us.PackWithUnsignedSaturation (a, b);
25 static int test_0_vector8us_sub_sat () {
26 Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
27 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
28 Vector8us c = Vector8us.SubWithSaturation (a, b);
49 static int test_0_vector8us_add_sat () {
50 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
51 Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
52 Vector8us c = Vector8us.AddWithSaturation (a, b);
73 static int test_0_vector8us_unpack_low () {
74 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
75 Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
76 Vector8us c = Vector8us.UnpackLow (a, b);
98 static int test_0_vector8us_shift_left () {
99 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
101 Vector8us c = a << amt;
112 static int test_0_vector8us_shift_right_arithmetic () {
113 Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
115 Vector8us c = Vector8us.ShiftRightArithmetic (a, amt);
126 static int test_0_vector8us_shift_variable_offset () {
128 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
130 Vector8us c = b >> off;
147 static int test_0_vector8us_shift_operand_is_live_after_op () {
148 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
150 Vector8us c = b >> 2;
166 static int test_0_vector8us_shr_constant () {
167 Vector8us a = new Vector8us (0xF000,1,2,3,4,5,6,7);
168 Vector8us c = a >> 2;
179 static int test_0_vector8us_mul () {
180 Vector8us a = new Vector8us (0x0F00,4,5,6,7,8,9,10);
181 Vector8us b = new Vector8us (0x0888,1,2,3,4,5,6,8);
193 static int test_0_vector8us_add () {
194 Vector8us a = new Vector8us (0xFF00,4,5,6,7,8,9,10);
195 Vector8us b = new Vector8us (0x8888,1,2,3,4,5,6,8);
208 static int test_0_vector8us_sub () {
209 Vector8us a = new Vector8us (3,4,5,6,7,8,9,10);
210 Vector8us b = new Vector8us (10,1,2,3,4,5,6,8);
224 static int test_0_vector8us_accessors () {
225 Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
273 static int test_0_vector16b_unpack_high () {
274 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
275 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
276 Vector16b c = Vector16b.UnpackHigh (a, b);
297 static int test_0_vector16b_unpack_low () {
298 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
299 Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
300 Vector16b c = Vector16b.UnpackLow (a, b);
321 static int test_0_vector16b_sub_sat () {
322 Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
323 Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
324 Vector16b c = Vector16b.SubWithSaturation (a, b);
335 static int test_0_vector16b_add_sat () {
336 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
337 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
338 Vector16b c = Vector16b.AddWithSaturation (a, b);
349 static int test_0_vector16b_add_ovf () {
350 Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
351 Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
363 static int test_0_vector16b_accessors () {
364 Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
451 public static int test_0_accessors () {
452 Vector4f a = new Vector4f (1, 2, 3, 4);
464 public static int test_0_packed_add_with_stack_tmp () {
465 Vector4f a = new Vector4f (1, 2, 3, 4);
466 Vector4f b = new Vector4f (5, 6, 7, 8);
467 Vector4f c = new Vector4f (-1, -3, -4, -5);
468 Vector4f d = a + b + c;
480 public static int test_0_simple_packed_add () {
481 Vector4f a = new Vector4f (1, 2, 3, 4);
482 Vector4f b = new Vector4f (5, 6, 7, 8);
496 public static int test_0_simple_packed_sub () {
497 Vector4f a = new Vector4f (1, 2, 3, 4);
498 Vector4f b = new Vector4f (5, 6, 7, 8);
511 public static int test_0_simple_packed_mul () {
512 Vector4f a = new Vector4f (1, 2, 3, 4);
513 Vector4f b = new Vector4f (5, 6, 7, 8);
526 public static int test_0_simple_packed_div () {
527 Vector4f a = new Vector4f (2, 2, 3, 4);
528 Vector4f b = new Vector4f (20, 10, 33, 12);
541 public static int test_0_simple_packed_sqrt () {
542 Vector4f a = new Vector4f (16, 4, 9, 25);
543 a = Vector4f.Sqrt (a);
555 public static int test_0_simple_packed_invsqrt () {
556 Vector4f a = new Vector4f (16, 4, 100, 25);
557 //this function has VERY low precision
558 a = Vector4f.InvSqrt (a);
559 if (a.X < (1/4f - 0.01f) || a.X > (1/4f + 0.01f))
561 if (a.Y < (1/2f - 0.01f) || a.Y > (1/2f + 0.01f))
563 if (a.Z < (1/10f - 0.01f) || a.Z > (1/10f + 0.01f))
565 if (a.W < (1/5f - 0.01f) || a.W > (1/5f + 0.01f))
570 public static int test_0_simple_packed_min () {
571 Vector4f a = new Vector4f (16, -4, 9, 25);
572 Vector4f b = new Vector4f (5, 3, 9, 0);
573 Vector4f c = Vector4f.Min (a, b);
585 public static int test_0_simple_packed_max () {
586 Vector4f a = new Vector4f (16, -4, 9, 25);
587 Vector4f b = new Vector4f (5, 3, 9, 0);
588 Vector4f c = Vector4f.Max (a, b);
600 public static int test_0_simple_packed_hadd () {
601 Vector4f a = new Vector4f (5, 5, 6, 6);
602 Vector4f b = new Vector4f (7, 7, 8, 8);
603 Vector4f c = Vector4f.HorizontalAdd (a, b);
615 public static int test_0_simple_packed_hsub () {
616 Vector4f a = new Vector4f (5, 2, 6, 1);
617 Vector4f b = new Vector4f (7, 0, 8, 3);
618 Vector4f c = Vector4f.HorizontalSub (a, b);
630 public static int test_0_simple_packed_addsub () {
631 Vector4f a = new Vector4f (5, 2, 6, 1);
632 Vector4f b = new Vector4f (7, 0, 8, 3);
633 Vector4f c = Vector4f.AddSub (a, b);
645 public static int test_0_simple_packed_shuffle () {
646 Vector4f a = new Vector4f (1, 2, 3, 4);
647 a = Vector4f.Shuffle(a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
659 public static int test_0_packed_shuffle_with_reg_pressure () {
660 Vector4f v = new Vector4f (1, 2, 3, 4);
661 Vector4f m0 = v + v, m1 = v - v, m2 = v * v, m3 = v + v + v;
662 if (ff) v = v + v -v ;
664 Vector4f r0 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
665 Vector4f r1 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
666 Vector4f x = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
667 Vector4f r2 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
668 Vector4f r3 = Vector4f.Shuffle (v, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
676 Vector4f result = r0 + r1 + r2 + r3;
686 if (result.Y != result.Y)
691 public static int test_24_regs_pressure_a () {
692 Vector4f a = new Vector4f (1, 2, 3, 4);
700 public static int test_54_regs_pressure_b () {
701 Vector4f a = new Vector4f (1, 2, 3, 4);
705 Vector4f e = a + b + c;
706 Vector4f f = d - b + a - c;
707 Vector4f g = a - d * f - c + b;
708 Vector4f h = a * b - c + e;
709 Vector4f i = h - g - f - e - d - c - b - a;
710 Vector4f j = a + b + c + d + e + f + g + h + i;
715 public static int test_3_single_block_var_is_properly_promoted () {
716 Vector4f a = new Vector4f (4, 5, 6, 7);
720 Vector4f b = new Vector4f (1, 2, 3, 4);
731 static float float_val = 45f;
733 public static int test_0_sse2_opt_and_simd_intrinsic_proper_regalloc () {
734 Vector4f v = new Vector4f (1, 2, 3, 4);
744 public static int Main () {
745 return TestDriver.RunTests (typeof (SimdTests));