Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / mini / basic-simd.cs
index 755071e519a7223591306a0a50571b2e352839fc..f8fdcebaf9b220170a913328bda60bf8e77ead3b 100644 (file)
@@ -2,6 +2,325 @@ using System;
 using Mono.Simd;
 
 public class SimdTests {
+       static int ddd;
+       static void InitByRef (out Vector4i v) {
+               v = new Vector4i (99);
+               if (ddd > 10)
+                       throw new Exception ("ddd");
+       }
+
+       static int test_0_vector4i_one_element_ctor_with_byref ()
+       {
+               Vector4i a;
+               InitByRef (out a);
+               if (a.X != 99)
+                       return 1;
+               if (a.Y != 99)
+                       return 2;
+               if (a.Z != 99)
+                       return 3;
+               if (a.W != 99)
+                       return 4;
+               return 0;
+       }
+       
+       static int test_0_vector2d_one_element_ctor () {
+               Vector2d a = new Vector2d (99);
+               if (a.X != 99)
+                       return 1;
+               if (a.Y != 99)
+                       return 2;
+               return 0;
+       }
+
+       static int test_0_vector2ul_one_element_ctor () {
+               Vector2ul a = new Vector2ul (99);
+
+               if (a.X != 99)
+                       return 1;
+               if (a.Y != 99)
+                       return 2;
+               return 0;
+       }
+
+       static int test_0_vector2l_one_element_ctor () {
+               Vector2l a = new Vector2l (99);
+
+               if (a.X != 99)
+                       return 1;
+               if (a.Y != 99)
+                       return 2;
+               return 0;
+       }
+
+       static int test_0_vector4f_one_element_ctor () {
+               Vector4f a = new Vector4f (99);
+
+               if (a.X != 99)
+                       return 1;
+               if (a.Y != 99)
+                       return 2;
+               if (a.Z != 99)
+                       return 3;
+               if (a.W != 99)
+                       return 4;
+               return 0;
+       }
+
+       static int test_0_vector4ui_one_element_ctor () {
+               Vector4ui a = new Vector4ui (99);
+
+               if (a.X != 99)
+                       return 1;
+               if (a.Y != 99)
+                       return 2;
+               if (a.Z != 99)
+                       return 3;
+               if (a.W != 99)
+                       return 4;
+               return 0;
+       }
+
+       static int test_0_vector4i_one_element_ctor () {
+               Vector4i a = new Vector4i (99);
+
+               if (a.X != 99)
+                       return 1;
+               if (a.Y != 99)
+                       return 2;
+               if (a.Z != 99)
+                       return 3;
+               if (a.W != 99)
+                       return 4;
+               return 0;
+       }
+
+       static int test_0_vector8us_one_element_ctor () {
+               Vector8us a = new Vector8us (99);
+
+               if (a.V0 != 99)
+                       return 1;
+               if (a.V1 != 99)
+                       return 2;
+               if (a.V2 != 99)
+                       return 3;
+               if (a.V3 != 99)
+                       return 4;
+               if (a.V4 != 99)
+                       return 5;
+               if (a.V5 != 99)
+                       return 6;
+               if (a.V6 != 99)
+                       return 7;
+               if (a.V7 != 99)
+                       return 8;
+               return 0;
+       }
+
+       static int test_0_vector8s_one_element_ctor () {
+               Vector8s a = new Vector8s (99);
+
+               if (a.V0 != 99)
+                       return 1;
+               if (a.V1 != 99)
+                       return 2;
+               if (a.V2 != 99)
+                       return 3;
+               if (a.V3 != 99)
+                       return 4;
+               if (a.V4 != 99)
+                       return 5;
+               if (a.V5 != 99)
+                       return 6;
+               if (a.V6 != 99)
+                       return 7;
+               if (a.V7 != 99)
+                       return 8;
+               return 0;
+       }
+
+       static int test_0_vector16sb_one_element_ctor () {
+               Vector16sb a = new Vector16sb (99);
+
+               if (a.V0 != 99)
+                       return 1;
+               if (a.V1 != 99)
+                       return 2;
+               if (a.V2 != 99)
+                       return 3;
+               if (a.V3 != 99)
+                       return 4;
+               if (a.V4 != 99)
+                       return 5;
+               if (a.V5 != 99)
+                       return 6;
+               if (a.V6 != 99)
+                       return 7;
+               if (a.V7 != 99)
+                       return 8;
+               if (a.V8 != 99)
+                       return 9;
+               if (a.V9 != 99)
+                       return 10;
+               if (a.V10 != 99)
+                       return 11;
+               if (a.V11 != 99)
+                       return 12;
+               if (a.V12 != 99)
+                       return 13;
+               if (a.V13 != 99)
+                       return 14;
+               if (a.V14 != 99)
+                       return 15;
+               if (a.V15 != 99)
+                       return 16;
+               return 0;
+       }
+
+       static int test_0_vector16b_one_element_ctor () {
+               Vector16b a = new Vector16b (99);
+
+               if (a.V0 != 99)
+                       return 1;
+               if (a.V1 != 99)
+                       return 2;
+               if (a.V2 != 99)
+                       return 3;
+               if (a.V3 != 99)
+                       return 4;
+               if (a.V4 != 99)
+                       return 5;
+               if (a.V5 != 99)
+                       return 6;
+               if (a.V6 != 99)
+                       return 7;
+               if (a.V7 != 99)
+                       return 8;
+               if (a.V8 != 99)
+                       return 9;
+               if (a.V9 != 99)
+                       return 10;
+               if (a.V10 != 99)
+                       return 11;
+               if (a.V11 != 99)
+                       return 12;
+               if (a.V12 != 99)
+                       return 13;
+               if (a.V13 != 99)
+                       return 14;
+               if (a.V14 != 99)
+                       return 15;
+               if (a.V15 != 99)
+                       return 16;
+               return 0;
+       }
+
+       public static unsafe int test_0_sizeof_returns_16_2d ()
+       {
+               double[] array = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+               fixed (double *ptr = &array [0]) {
+                       Vector2d *f = (Vector2d*)ptr;
+                       Vector2d a = *f++;
+                       Vector2d b = *f++;
+                       Vector2d c = *f++;
+                       Vector2d d = *f++;
+
+                       if (a.X != 1 || a.Y  != 2)
+                               return 1;
+                       if (b.X != 3 || b.Y  != 4)
+                               return 2;
+                       if (c.X != 5 || c.Y  != 6)
+                               return 3;
+                       if (d.X != 7 || d.Y  != 8)
+                               return 4;
+               }
+               return 0;
+       }
+
+       public static unsafe int test_0_sizeof_returns_16_4f ()
+       {
+               float[] array = new float[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
+               fixed (float *ptr = &array [0]) {
+                       Vector4f *f = (Vector4f*)ptr;
+                       Vector4f a = *f++;
+                       Vector4f b = *f++;
+                       Vector4f c = *f++;
+                       Vector4f d = *f++;
+
+                       if (a.X != 1 || a.W  != 4)
+                               return 1;
+                       if (b.X != 5 || b.W  != 8)
+                               return 2;
+                       if (c.X != 9 || c.W  != 12)
+                               return 3;
+                       if (d.X != 13 || d.W  != 16)
+                               return 4;
+               }
+               return 0;
+       }
+
+       public static unsafe int test_0_sizeof_returns_16_8d ()
+       {
+               short[] array = new short[40];
+               for (int i = 0; i < 40; ++i)
+                       array [i] = (short) (i + 1);
+
+               fixed (short *ptr = &array [0]) {
+                       Vector8s *f = (Vector8s*)ptr;
+                       Vector8s a = *f++;
+                       Vector8s b = *f++;
+                       Vector8s c = *f++;
+                       Vector8s d = *f++;
+
+                       if (a.V0 != 1 || a.V7  != 8)
+                               return 1;
+                       if (b.V0 != 9 || b.V7  != 16)
+                               return 2;
+                       if (c.V0 != 17 || c.V7  != 24)
+                               return 3;
+                       if (d.V0 != 25 || d.V7  != 32)
+                               return 4;
+               }
+               return 0;
+       }
+
+       public static unsafe int test_0_sizeof_returns_16_16b ()
+       {
+               byte[] array = new byte[80];
+               for (int i = 0; i < 80; ++i)
+                       array [i] = (byte) (i + 1);
+
+               fixed (byte *ptr = &array [0]) {
+                       Vector16b *f = (Vector16b*)ptr;
+                       Vector16b a = *f++;
+                       Vector16b b = *f++;
+                       Vector16b c = *f++;
+                       Vector16b d = *f++;
+
+                       if (a.V0 != 1 || a.V15  != 16)
+                               return 1;
+                       if (b.V0 != 17 || b.V15  != 32)
+                               return 2;
+                       if (c.V0 != 33 || c.V15  != 48)
+                               return 3;
+                       if (d.V0 != 49 || d.V15  != 64)
+                               return 4;
+               }
+               return 0;
+       }       
+       public static int test_0_bug_462457 ()
+       {
+               Vector4f sum = new Vector4f(0,0,0,0);
+               Vector4f add = new Vector4f(1.0F,1.0F,1.0F,1.0F);
+
+               for (int i = 0; i < 10; ++i)
+                               sum = sum + add;
+
+               if (sum.X != 10f)
+                       return 1;
+               return 0;
+       }
+
        public static int test_0_vector16b_operator_neq () {
                Vector16b a = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
                Vector16b b = new Vector16b(1,2,3,5,5,6,7,8,1,2,3,5,5,6,7,8);
@@ -238,12 +557,12 @@ public class SimdTests {
                if (a.Y != 2)
                        return 2;
 
-               a.X = 500000000000055l;
-               a.Y = -12345678900l;
+               a.X = 500000000000055L;
+               a.Y = -12345678900L;
 
-               if (a.X != 500000000000055l)
+               if (a.X != 500000000000055L)
                        return 3;
-               if (a.Y != -12345678900l)
+               if (a.Y != -12345678900L)
                        return 4;
                return 0;
        }
@@ -376,7 +695,7 @@ public class SimdTests {
                Vector2l a = new Vector2l (10, 5);
                Vector2l b = new Vector2l (-1, 5);
 
-               Vector2l c = Vector2l.CompareGreaterThan (a, b);
+               Vector2l c = a.CompareGreaterThan (b);
        
                if (c.X != -1)
                        return 1;
@@ -389,7 +708,7 @@ public class SimdTests {
                Vector2l a = new Vector2l (0xFF,          5);
                Vector2l b = new Vector2l (0xFF000000FFL, 5);
 
-               Vector2l c = Vector2l.CompareEqual (a, b);
+               Vector2l c = a.CompareEqual (b);
        
                if (c.X != 0)
                        return 1;
@@ -401,7 +720,7 @@ public class SimdTests {
        public static unsafe int test_0_vector2l_srl () {
                Vector2l a = new Vector2l (1, 6);
 
-               Vector2l c = Vector2l.LogicalRightShift (a, 1);
+               Vector2l c = a.LogicalRightShift (1);
        
                if (c.X != 0)
                        return 1;
@@ -414,7 +733,7 @@ public class SimdTests {
                Vector2l a = new Vector2l (1, 6);
                Vector2l b = new Vector2l (3, 4);
 
-               Vector2l c = Vector2l.UnpackHigh (a, b);
+               Vector2l c = a.UnpackHigh (b);
        
                if (c.X != 6)
                        return 1;
@@ -427,7 +746,7 @@ public class SimdTests {
                Vector2l a = new Vector2l (1, 6);
                Vector2l b = new Vector2l (3, 4);
 
-               Vector2l c = Vector2l.UnpackLow (a, b);
+               Vector2l c = a.UnpackLow (b);
        
                if (c.X != 1)
                        return 1;
@@ -756,11 +1075,11 @@ public class SimdTests {
                return 0;
        }
 
-       public static unsafe int test_vector8s_pack_signed_sat () {
+       public static unsafe int test_0_vector8s_pack_signed_sat () {
                Vector8s a = new Vector8s (-200, 200, 3, 0, 5, 6, 5, 4);
                Vector8s b = new Vector8s (9, 2, 1, 2, 3, 6, 5, 6);
 
-               Vector16sb c = Vector8s.PackWithSignedSaturation (a, b);
+               Vector16sb c = a.PackWithSignedSaturation (b);
 
                if (c.V0 != -128)
                        return 1;
@@ -770,11 +1089,11 @@ public class SimdTests {
                return 0;
        }
 
-       public static unsafe int test_vector16sb_sub_sat () {
+       public static unsafe int test_0_vector16sb_sub_sat () {
                Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
                Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
 
-               Vector16sb c = Vector16sb.SubtractWithSaturation (a, b);
+               Vector16sb c = a.SubtractWithSaturation (b);
 
                if (c.V0 != 127)
                        return 1;
@@ -795,11 +1114,11 @@ public class SimdTests {
                return 0;
        }
 
-       public static unsafe int test_vector16sb_add_sat () {
+       public static unsafe int test_0_vector16sb_add_sat () {
                Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
                Vector16sb b = new Vector16sb (100, -100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
 
-               Vector16sb c = Vector16sb.AddWithSaturation (a, b);
+               Vector16sb c = a.AddWithSaturation (b);
 
                if (c.V0 != 127)
                        return 1;
@@ -820,11 +1139,11 @@ public class SimdTests {
                return 0;
        }
 
-       public static unsafe int test_vector16sb_cmp_gt () {
+       public static unsafe int test_0_vector16sb_cmp_gt () {
                Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
                Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15);
 
-               Vector16sb c = Vector16sb.CompareGreaterThan (a, b);
+               Vector16sb c = a.CompareGreaterThan (b);
 
                if (c.V0 != -1)
                        return 1;
@@ -848,7 +1167,7 @@ public class SimdTests {
                Vector4ui a = new Vector4ui (0xF0000000,0xF0000,3,4);
                Vector4ui b = new Vector4ui (5,6,7,8);
 
-               Vector8us c = Vector4ui.SignedPackWithUnsignedSaturation (a, b);
+               Vector8us c = a.SignedPackWithUnsignedSaturation (b);
 
                if (c.V0 != 0)
                        return 1;
@@ -872,7 +1191,7 @@ public class SimdTests {
        public static int test_0_vector8us_pack_with_sat () {
                Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
                Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
-               Vector16b c = Vector8us.SignedPackWithUnsignedSaturation (a, b);
+               Vector16b c = a.SignedPackWithUnsignedSaturation (b);
 
                if (c.V0 != 0)
                        return 1;
@@ -890,7 +1209,7 @@ public class SimdTests {
        public static int test_0_vector8us_mul_high () {
                Vector8us a = new Vector8us (0xFF00, 2, 3, 0, 5, 6, 5, 4);
                Vector8us b = new Vector8us (0xFF00, 2, 1, 2, 3, 6, 5, 6);
-               Vector8us c = Vector8us.MultiplyStoreHigh (a, b);
+               Vector8us c = a.MultiplyStoreHigh (b);
 
                if (c.V0 != 0xFE01)
                        return 1;
@@ -914,7 +1233,7 @@ public class SimdTests {
        public static int test_0_vector8us_cmpeq () {
                Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
                Vector8us b = new Vector8us (9, 2, 1, 2, 3, 6, 5, 6);
-               Vector8us c = Vector8us.CompareEqual (a, b);
+               Vector8us c = a.CompareEqual (b);
 
                if (c.V0 != 0)
                        return 1;
@@ -939,7 +1258,7 @@ public class SimdTests {
        public static int test_0_vector4ui_cmpeq () {
                Vector4ui a = new Vector4ui (6,1,6,3);
                Vector4ui b = new Vector4ui (3,4,6,7);
-               Vector4ui c = Vector4ui.CompareEqual (a, b);
+               Vector4ui c = a.CompareEqual (b);
 
                if (c.X != 0)
                        return 1;
@@ -954,7 +1273,7 @@ public class SimdTests {
 
        public static int test_0_vector4ui_shuffle () {
                Vector4ui a = new Vector4ui (1,2,3,4);
-               Vector4ui c = Vector4ui.Shuffle (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
+               Vector4ui c = a.Shuffle (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
 
                if (c.X != 2)
                        return 1;
@@ -970,7 +1289,7 @@ public class SimdTests {
        public static int test_0_vector4ui_min () {
                Vector4ui a = new Vector4ui (6,1,6,3);
                Vector4ui b = new Vector4ui (3,4,6,7);
-               Vector4ui c = Vector4ui.Min (a, b);
+               Vector4ui c = a.Min (b);
 
                if (c.X != 3)
                        return 1;
@@ -986,7 +1305,7 @@ public class SimdTests {
        public static int test_0_vector4ui_max () {
                Vector4ui a = new Vector4ui (6,1,6,3);
                Vector4ui b = new Vector4ui (3,4,6,7);
-               Vector4ui c = Vector4ui.Max (a, b);
+               Vector4ui c = a.Max (b);
 
                if (c.X != 6)
                        return 1;
@@ -1002,7 +1321,7 @@ public class SimdTests {
        public static int vector16b_cmpeq () {
                Vector16b a = new Vector16b (1,0,9,0,0,0,0,0,0,0,0,0,0,0,0,1);
                Vector16b b = new Vector16b (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
-               Vector16b c = Vector16b.CompareEqual (a, b);
+               Vector16b c = a.CompareEqual (b);
 
                if (c.V0 != 0)
                        return 1;
@@ -1043,7 +1362,7 @@ public class SimdTests {
        public static int vector16b_sum_abs_diff () {
                Vector16b a = new Vector16b (100,20,20,20,0,0,0,0,0,0,0,0,0,0, 0, 0);
                Vector16sb b = new Vector16sb (0,  10,10,10,0,0,0,0,0,0,0,0,0,0,10,10);
-               Vector8us c = Vector16b.SumOfAbsoluteDifferences (a, b);
+               Vector8us c = a.SumOfAbsoluteDifferences (b);
 
                if (c.V0 != 130)
                        return 1;
@@ -1067,7 +1386,7 @@ public class SimdTests {
 
        public static int test_0_vector16b_extract_mask () {
                Vector16b a = new Vector16b (0xF0,0,0xF0,0,0,0,0xF0,0xAA,0x0F,0,0xFF,0,0,0,0,0);
-               int c = Vector16b.ExtractByteMask (a);
+               int c = a.ExtractByteMask ();
 
                if (c != 0x4C5)
                        return 1;
@@ -1077,7 +1396,7 @@ public class SimdTests {
        public static int test_0_vector16b_min () {
                Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
                Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
-               Vector16b c = Vector16b.Min (a, b);
+               Vector16b c = a.Min (b);
 
                if (c.V0 != 0)
                        return 1;
@@ -1117,7 +1436,7 @@ public class SimdTests {
        public static int test_0_vector16b_max () {
                Vector16b a = new Vector16b (0,12,20,12,4,5,6,7,8,9,10,11,12,13,14,15);
                Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
-               Vector16b c = Vector16b.Max (a, b);
+               Vector16b c = a.Max (b);
 
                if (c.V0 != 9)
                        return 1;
@@ -1156,7 +1475,7 @@ public class SimdTests {
        public static int test_0_vector16b_avg () {
                Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
                Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
-               Vector16b c = Vector16b.Average (a, b);
+               Vector16b c = a.Average (b);
 
                if (c.V0 != 5)
                        return 1;
@@ -1244,7 +1563,7 @@ public class SimdTests {
        
        public static int test_0_vecto8us_shuffle_low () {
                Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
-               Vector8us c = Vector8us.ShuffleLow (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
+               Vector8us c = a.ShuffleLow (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
 
                if (c.V0 != 2)
                        return 1;
@@ -1267,7 +1586,7 @@ public class SimdTests {
 
        public static int test_0_vecto8us_shuffle_high () {
                Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
-               Vector8us c = Vector8us.ShuffleHigh (a, ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
+               Vector8us c = a.ShuffleHigh (ShuffleSel.XFromY | ShuffleSel.YFromW | ShuffleSel.ZFromX | ShuffleSel.WFromZ);
 
                if (c.V0 != 1)
                        return 1;
@@ -1292,7 +1611,7 @@ public class SimdTests {
        public static int test_0_vecto8us_max () {
                Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
                Vector8us b = new Vector8us (9, 1, 1, 2, 9, 6, 5, 1000);
-               Vector8us c = Vector8us.Max (a, b);
+               Vector8us c = a.Max (b);
 
                if (c.V0 != 9)
                        return 1;
@@ -1317,7 +1636,7 @@ public class SimdTests {
        public static int test_0_vecto8us_min () {
                Vector8us a = new Vector8us (1, 2, 3, 0, 5, 6, 5, 4);
                Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
-               Vector8us c = Vector8us.Min (a, b);
+               Vector8us c = a.Min (b);
 
                if (c.V0 != 1)
                        return 1;
@@ -1341,7 +1660,7 @@ public class SimdTests {
        public static int test_0_vecto8us_avg () {
                Vector8us a = new Vector8us (1, 2, 3, 4, 5, 6, 7, 8);
                Vector8us b = new Vector8us (9, 1, 1, 2, 3, 4, 5, 6);
-               Vector8us c = Vector8us.Average (a, b);
+               Vector8us c = a.Average (b);
 
                if (c.V0 != 5)
                        return 1;
@@ -1660,7 +1979,7 @@ public class SimdTests {
        public static int test_0_vector4ui_sar () {
                Vector4ui a = new Vector4ui (0xF0000000u,20,3,40);
                
-               Vector4ui c = Vector4ui.ArithmeticRightShift (a, 2);
+               Vector4ui c = a.ArithmeticRightShift (2);
        
                if (c.X != 0xFC000000)
                        return 1;
@@ -1677,7 +1996,7 @@ public class SimdTests {
                Vector4ui a = new Vector4ui (1,2,3,4);
                Vector4ui b = new Vector4ui (5,6,7,8);
                
-               Vector4ui c = Vector4ui.UnpackHigh(a, b);
+               Vector4ui c = a.UnpackHigh(b);
        
                if (c.X != 3)
                        return 1;
@@ -1694,7 +2013,7 @@ public class SimdTests {
                Vector4ui a = new Vector4ui (1,2,3,4);
                Vector4ui b = new Vector4ui (5,6,7,8);
                
-               Vector4ui c = Vector4ui.UnpackLow (a, b);
+               Vector4ui c = a.UnpackLow (b);
        
                if (c.X != 1)
                        return 1;
@@ -1870,7 +2189,7 @@ public class SimdTests {
        static int test_0_vector8us_sub_sat () {
                Vector8us a = new Vector8us (0xF000,1,20,3,4,5,6,7);
                Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
-               Vector8us c = Vector8us.SubtractWithSaturation (a, b);
+               Vector8us c = a.SubtractWithSaturation (b);
 
                if (c.V0 != 0)
                        return 1;
@@ -1894,7 +2213,7 @@ public class SimdTests {
        static int test_0_vector8us_add_sat () {
                Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
                Vector8us b = new Vector8us (0xFF00,4,5,6,7,8,9,10);
-               Vector8us c = Vector8us.AddWithSaturation (a, b);
+               Vector8us c = a.AddWithSaturation (b);
 
                if (c.V0 != 0xFFFF)
                        return 1;
@@ -1918,7 +2237,7 @@ public class SimdTests {
        static int test_0_vector8us_unpack_low () {
                Vector8us a = new Vector8us (0,1,2,3,4,5,6,7);
                Vector8us b = new Vector8us (3,4,5,6,7,8,9,10);
-               Vector8us c = Vector8us.UnpackLow (a, b);
+               Vector8us c = a.UnpackLow (b);
 
                if (c.V0 != 0)
                        return 1;
@@ -1957,7 +2276,7 @@ public class SimdTests {
        static int test_0_vector8us_shift_right_arithmetic () {
                Vector8us a = new Vector8us (0xFF00,1,2,3,4,5,6,7);
                int amt = 2;
-               Vector8us c = Vector8us.ArithmeticRightShift (a, amt);
+               Vector8us c = a.ArithmeticRightShift (amt);
        
                if (c.V0 != 0xFFC0)
                        return 1;
@@ -2118,7 +2437,7 @@ public class SimdTests {
        static int test_0_vector16b_unpack_high () {
                Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
                Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
-               Vector16b c = Vector16b.UnpackHigh (a, b);
+               Vector16b c = a.UnpackHigh (b);
 
                if (c.V0 != 8)
                        return 1;
@@ -2142,7 +2461,7 @@ public class SimdTests {
        static int test_0_vector16b_unpack_low () {
                Vector16b a = new Vector16b (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
                Vector16b b = new Vector16b (9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
-               Vector16b c = Vector16b.UnpackLow (a, b);
+               Vector16b c = a.UnpackLow (b);
 
                if (c.V0 != 0)
                        return 1;
@@ -2166,7 +2485,7 @@ public class SimdTests {
        static int test_0_vector16b_sub_sat () {
                Vector16b a = new Vector16b (100,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
                Vector16b b = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
-               Vector16b c = Vector16b.SubtractWithSaturation (a, b);
+               Vector16b c = a.SubtractWithSaturation (b);
 
                if (c.V0 != 0)
                        return 1;
@@ -2180,7 +2499,7 @@ public class SimdTests {
        static int test_0_vector16b_add_sat () {
                Vector16b a = new Vector16b (200,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
                Vector16b b = new Vector16b (200,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8);
-               Vector16b c = Vector16b.AddWithSaturation (a, b);
+               Vector16b c = a.AddWithSaturation (b);
 
                if (c.V0 != 255)
                        return 1;
@@ -2533,6 +2852,16 @@ public class SimdTests {
                return 0;
        }
        
+       public static int test_0_double_packed_sqrt () {
+               Vector2d a = new Vector2d (16, 4);
+               a = a.Sqrt ();
+               if (a.X != 4f)
+                       return 1;
+               if (a.Y != 2f)
+                       return 2;
+               return 0;
+       }
+
        public static int test_24_regs_pressure_a () {
                Vector4f a = new Vector4f (1, 2, 3, 4);
                Vector4f b = a + a;
@@ -2556,6 +2885,152 @@ public class SimdTests {
                return (int)j.Z;
        }
 
+       public static int test_8_regs_pressure_c () {
+               Vector4f a = new Vector4f (1, 2, 3, 4);
+               Vector4f b = a + a;
+               Vector4f c = b - a;
+               Vector4f d = c - a;
+               Vector4f e = a + b + c;
+               Vector4f f = d - b + a - c;
+               Vector4f g = a - d * f - c + b;
+               Vector4f h = a * b - c + e;
+               Vector4f i = h - g - f - e - d - c - b - a;
+               Vector4f j = a + b + c + d + e + f + g + h + i;
+               Vector4f k = j - i - h + e + d - a + b - f + g;
+               Vector4f l = k * c - j * b - i * e + f - g; 
+               Vector4f m = l - k + j - i + e + f;
+               Vector4f n = m - j + g - i + e * b + a * d;
+               Vector4f o = k + j + i * b;
+               Vector4f p = m + j + i + e + l;
+               Vector4f q = l * m + j + k;
+               Vector4f r = p * a + o * b + j * c + m * d + l * e;
+               Vector4f s = a - b - c - d - e - f - g - h - i - j - k - l - m - p - o - q - r;
+               Vector4f t = a + b + c + d + e + f + g + h + i + j + k + l + m + p + o + q + r + s;
+               return (int)t.W;
+       }
+
+       public static int test_0_regs_pressure_fp_and_simd_share_bank_1 () {
+               Vector4f a = new Vector4f (4, 3, 2, 1);
+               float aF = 10f;
+               Vector4f b = a + a;
+               float bF = aF + aF;
+               Vector4f c = b - a;
+               float cF = bF - aF;
+               Vector4f d = c - a;
+               float dF = cF - aF;
+               Vector4f e = a + b + c;
+               float eF = aF + bF + cF;
+               Vector4f f = d - b + a - c;
+               float fF = dF - bF + aF - cF;
+               Vector4f g = a - d * f - c + b;
+               float gF = aF - dF * fF - cF + bF;
+               Vector4f h = a * b - c + e;
+               float hF = aF * bF - cF + eF;
+               Vector4f i = h - g - f - e - d - c - b - a;
+               float iF = hF - gF - fF - eF - dF - cF - bF - aF;
+               Vector4f j = a + b + c + d + e + f + g + h + i;
+               float jF = aF + bF + cF + dF + eF + fF + gF + hF + iF;
+
+               if (j.X != 88f)
+                       return 1;
+
+               if(jF != 460f)
+                       return 2;
+
+               return 0;
+       }
+
+       public static int test_0_regs_pressure_fp_and_simd_share_bank_2 () {
+               Vector4f a = new Vector4f (4, 3, 2, 1);
+               float aF = 10f;
+               Vector4f b = a + a;
+               float bF = aF + aF;
+               Vector4f c = b - a;
+               float cF = bF - aF;
+               Vector4f d = c - a;
+               float dF = cF - aF;
+               Vector4f e = a + b + c;
+               float eF = aF + bF + cF;
+               Vector4f f = d - b + a - c;
+               float fF = dF - bF + aF - cF;
+               Vector4f g = a - d * f - c + b;
+               float gF = aF - dF * fF - cF + bF;
+               Vector4f h = a * b - c + e;
+               float hF = aF * bF - cF + eF;
+               Vector4f i = h - g - f - e - d - c - b - a;
+               float iF = hF - gF - fF - eF - dF - cF - bF - aF;
+               Vector4f j = a + b + c + d + e + f + g + h + i;
+               float jF = aF + bF + cF + dF + eF + fF + gF + hF + iF;
+               Vector4f k = j - i - h + e + d - a + b - f + g;
+               float kF = jF - iF - hF + eF + dF - aF + bF - fF + gF;
+               Vector4f l = k * c - j * b - i * e + f - g; 
+               float lF = kF * cF - jF * bF - iF * eF + fF - gF;
+               Vector4f m = l - k + j - i + e + f;
+               float mF = lF - kF + jF - iF + eF + fF;
+               Vector4f n = m - j + g - i + e * b + a * d;
+               float nF = mF - jF + gF - iF + eF * bF + aF * dF;
+               Vector4f o = k + j + i * b;
+               float oF = kF + jF + iF * bF;
+               Vector4f p = m + j + i + e + l;
+               float pF = mF + jF + iF + eF + lF;
+               Vector4f q = l * m + j + k;
+               float qF = lF * mF + jF + kF;
+               Vector4f r = p * a + o * b + j * c + m * d + l * e;
+               float rF = pF * aF + oF * bF + jF * cF + mF * dF + lF * eF;
+               Vector4f s = a - b - c - d - e - f - g - h - i - j - k - l - m - p - o - q - r;
+               float sF = aF - bF - cF - dF - eF - fF - gF - hF - iF - jF - kF - lF - mF - pF - oF - qF - rF;
+               Vector4f t = a + b + c + d + e + f + g + h + i + j + k + l + m + p + o + q + r + s;
+               float tF = aF + bF + cF + dF + eF + fF + gF + hF + iF + jF + kF + lF + mF + pF + oF + qF + rF + sF;
+
+               if (t.X != 8f)
+                       return 1;
+
+               if(tF != 14f)
+                       return 2;
+
+               return 0;
+       }
+
+
+       public static void call_simd_fp () {
+               Vector4f a = new Vector4f (20f, 22f, 23f, 24f);
+               float b = 25f;
+               Vector4f c = new Vector4f (26f, 27f, 28f, 29f);
+               float d = 30f;
+
+               b += d;
+               a += c;
+       }
+       public static int test_0_call_fp_and_simd_share_bank () {
+
+               float a = 1f;
+               Vector4f b = new Vector4f (2f, 3f, 4f, 5f);
+               float c = 6f;
+               Vector4f d = new Vector4f (7f, 8f, 9f, 10f);
+
+               a += c;
+
+               b += d;
+               
+               call_simd_fp ();
+               if (a != 7f)
+                       return 1;
+               if (b.X != 9f)
+                       return 2;
+               if (c != 6f)
+                       return 3;
+               if (d.X != 7f)
+                       return 4;
+               if (b.W != 15f)
+                       return 5;
+               if (d.W != 10f)
+                       return 6;
+               
+
+               return 0;
+       }
+
+
        static bool ff;
        public static int test_3_single_block_var_is_properly_promoted () {
                Vector4f a = new Vector4f (4, 5, 6, 7);
@@ -2586,8 +3061,251 @@ public class SimdTests {
                return 0;
        }
 
-       public static int Main () {
-               return TestDriver.RunTests (typeof (SimdTests));
+       public static int test_0_sse41_vector8s_min () {
+               Vector8s v = new Vector8s(2);
+               Vector8s v2 = new Vector8s(1);
+               v = v.Min(v2);
+               if (v.V0 != 1 || v.V1 != 1 || v.V2 != 1 || v.V3 != 1 || v.V4 != 1 || v.V5 != 1 || v.V6 != 1 || v.V7 != 1)
+                       return 1;
+               return 0;
+       }
+
+       public static int test_0_simd_const_indexer_simple () {
+               Vector4f v = new Vector4f (1, 2, 3, 4);
+               
+               if (v[0] != 1) 
+                       return 1;
+               if (v[1] != 2) 
+                       return 2;
+               if (v[2] != 3) 
+                       return 3;
+               if (v[3] != 4) 
+                       return 4;
+               return 0;
+       }
+
+       public static int test_0_simd_var_indexer_simple () {
+               Vector4f v = new Vector4f (1, 2, 3, 4);
+
+               int index = 0;
+               
+               if (v[index++] != 1) 
+                       return 1;
+               if (v[index++] != 2) 
+                       return 2;
+               if (v[index++] != 3) 
+                       return 3;
+               if (v[index] != 4) 
+                       return 4;
+               return 0;
+       }
+
+       public static int test_0_simd_const_indexer_double () {
+               Vector2d v = new Vector2d (1, 2);
+               
+               if (v[0] != 1) 
+                       return 1;
+               if (v[1] != 2) 
+                       return 2;
+               return 0;
+       }
+
+       public static int test_0_simd_var_indexer_double () {
+               Vector2d v = new Vector2d (1, 2);
+
+               int index = 0;
+               
+               if (v[index++] != 1) 
+                       return 1;
+               if (v[index] != 2) 
+                       return 2;
+               return 0;
+       }
+
+
+       public static int test_0_scala_vector4f_mul () {
+               Vector4f a = new Vector4f (1, 2, 3, 4);
+               Vector4f b = 2 * a;
+               Vector4f c = a * 3;
+
+               if (b.X != 2f || b.Y != 4f || b.Z != 6f || b.W != 8f )
+                       return 1;
+               if (c.X != 3f || c.Y != 6f || c.Z != 9f || c.W != 12f )
+                       return 1;
+
+               return 0;
+       }
+
+       static void CallMethodThatClobbersRegs () {
+               Vector4f a = new Vector4f (9,9,9,9);
+               Vector4f b = new Vector4f (9,9,9,9);
+               a = a + b;
+       }
+
+       public static int test_0_call_spills_regs_correctly () {
+               Vector4f a = new Vector4f (1,2,3,4);
+               Vector4f b = new Vector4f (5,6,7,8);
+
+               CallMethodThatClobbersRegs ();
+
+               bool b0 = a.X == 1f;
+               bool b1 = b.X == 5f;
+               if (!b0 || !b1)
+                       return 1;
+               return 0;
+       }
+
+       public static int test_0_shuffle_with_two_args_pd () {
+               Vector2d a = new Vector2d (1,2);
+               Vector2d b = new Vector2d (5,6);
+
+               Vector2d c = a.Shuffle (b, 0x2);
+               if (c.X != 1)
+                       return 1;
+               if (c.Y != 6)
+                       return 2;
+               return 0;
+       }
+
+       public static int test_0_shuffle_with_two_args_ps () {
+               Vector4f a = new Vector4f (1, 2, 3, 4);
+               Vector4f b = new Vector4f (5, 6, 7, 8);
+
+               Vector4f c = a.Shuffle (b, ShuffleSel.ExpandY);
+               if (c.X != 2)
+                       return 1;
+               if (c.Y != 2)
+                       return 2;
+               if (c.Z != 6)
+                       return 3;
+               if (c.W != 6)
+                       return 4;
+               return 0;
+       }
+
+       public static int test_0_i_to_d () {
+               var a = new Vector4i (1, 2, 3, 4);
+               var b = a.ConvertToDouble ();
+               if (b.X != 1)
+                       return 1;
+               if (b.Y != 2)
+                       return 2;
+               return 0;
+       }
+
+       public static int test_0_i_to_f () {
+               var a = new Vector4i (1, 2, 3, 4);
+               var b = a.ConvertToFloat ();
+               if (b.X != 1)
+                       return 1;
+               if (b.Y != 2)
+                       return 2;
+               if (b.Z != 3)
+                       return 3;
+               if (b.W != 4)
+                       return 4;
+               return 0;
+       }
+
+       public static int test_0_d_to_i () {
+               var a = new Vector2d (1.4, 2.6);
+               var b = a.ConvertToInt ();
+               if (b.X != 1)
+                       return 1;
+               if (b.Y != 3)
+                       return 2;
+               if (b.Z != 0)
+                       return 3;
+               if (b.W != 0)
+                       return 4;
+               return 0;
+       }
+
+       public static int test_0_d_to_f () {
+               var a = new Vector2d (1, 2);
+               var b = a.ConvertToFloat ();
+               if (b.X != 1)
+                       return 1;
+               if (b.Y != 2)
+                       return 2;
+               if (b.Z != 0)
+                       return 3;
+               if (b.W != 0)
+                       return 4;
+               return 0;
+       }
+
+       public static int test_0_f_to_i () {
+               var a = new Vector4f (1.1f, 2.2f, 3.5f, 4.6f);
+               var b = a.ConvertToInt ();
+               if (b.X != 1)
+                       return 1;
+               if (b.Y != 2)
+                       return 2;
+               if (b.Z != 4)
+                       return 3;
+               if (b.W != 5)
+                       return 4;
+               return 0;
+       }
+
+       public static int test_0_f_to_d () {
+               var a = new Vector4f (1,2,3,4);
+               var b = a.ConvertToDouble ();
+               if (b.X != 1)
+                       return 1;
+               if (b.Y != 2)
+                       return 2;
+               return 0;
+       }
+
+       public static int test_0_d_to_i_trunc () {
+               var a = new Vector2d (1.4, 2.6);
+               var b = a.ConvertToIntTruncated ();
+               if (b.X != 1)
+                       return 1;
+               if (b.Y != 2)
+                       return 2;
+               if (b.Z != 0)
+                       return 3;
+               if (b.W != 0)
+                       return 4;
+               return 0;
+       }
+
+       public static int test_0_f_to_i_trunc () {
+               var a = new Vector4f (1.1f, 2.2f, 3.5f, 4.6f);
+               var b = a.ConvertToIntTruncated ();
+               if (b.X != 1)
+                       return 1;
+               if (b.Y != 2)
+                       return 2;
+               if (b.Z != 3)
+                       return 3;
+               if (b.W != 4)
+                       return 4;
+               return 0;
+       }
+
+       class BoxedVector2d
+       {
+           public Vector2d v;
+       }
+
+       public static int test_0_vector2d_set_x () {
+               var bv = new BoxedVector2d ();
+               var xy = new Vector2d ();
+               xy.X = bv.v.X;
+
+               if (xy.X != 0)
+                       return 1;
+               if (xy.Y != 0)
+                       return 2;
+               return 0;
+       }
+
+       public static int Main (String[] args) {
+               return TestDriver.RunTests (typeof (SimdTests), args);
        }
 }