2008-11-17 Rodrigo Kumpera <rkumpera@novell.com>
[mono.git] / mono / mini / basic.cs
index 1368e79293b2dc938eb85736768cfd4b3248d841..ecbef60b697f76fdaeaeb7af261fb7b56d4faa01 100644 (file)
@@ -675,7 +675,21 @@ class Tests {
                        return 1;
                else
                        return 0;
-       }               
+       }
+
+       public static int test_127_iconv_to_i1 () {
+               int i = 0x100017f;
+               sbyte s = (sbyte)i;
+
+               return s;
+       }
+
+       public static int test_384_iconv_to_i2 () {
+               int i = 0x1000180;
+               short s = (short)i;
+
+               return s;
+       }
        
        public static int test_15_for_loop () {
                int i;
@@ -1210,4 +1224,100 @@ class Tests {
 
                return (int)(i % j);
        }
+
+       public static int test_0_div_opt () {
+               int i;
+
+               // Avoid cfolding this
+               i = 0;
+               for (int j = 0; j < 1234567; ++j)
+                       i ++;
+               if ((i / 2) != 617283)
+                       return 1;
+               if ((i / 4) != 308641)
+                       return 2;
+               if ((i / 8) != 154320)
+                       return 3;
+               if ((i / 16) != 77160)
+                       return 4;
+
+               // Avoid cfolding this
+               i = 0;
+               for (int j = 0; j < 1234567; ++j)
+                       i --;
+               if ((i / 2) != -617283)
+                       return 5;
+               if ((i / 4) != -308641)
+                       return 6;
+               if ((i / 8) != -154320)
+                       return 7;
+               if ((i / 16) != -77160)
+                       return 8;
+
+               return 0;
+       }
+
+       public static int test_0_rem_opt () {
+               int i;
+
+               // Avoid cfolding this
+               i = 0;
+               for (int j = 0; j < 29; ++j)
+                       i ++;
+               if ((i % 2) != 1)
+                       return 1;
+               if ((i % 4) != 1)
+                       return 2;
+               if ((i % 8) != 5)
+                       return 3;
+               if ((i % 16) != 13)
+                       return 4;
+
+               // Avoid cfolding this
+               i = 0;
+               for (int j = 0; j < 29; ++j)
+                       i --;
+               if ((i % 2) != -1)
+                       return 5;
+               if ((i % 4) != -1)
+                       return 6;
+               if ((i % 8) != -5)
+                       return 7;
+               if ((i % 16) != -13)
+                       return 8;
+
+               return 0;
+       }
+
+       public static int cmov (int i) {
+               int j = 0;
+
+               if (i > 0)
+                       j = 1;
+
+               return j;
+       }
+
+       public static int cmov2 (int i) {
+               int j = 0;
+
+               if (i <= 0)
+                       ;
+               else
+                       j = 1;
+
+               return j;
+       }
+               
+       public static int test_0_branch_to_cmov_opt () {
+               if (cmov (0) != 0)
+                       return 1;
+               if (cmov (1) != 1)
+                       return 2;
+               if (cmov2 (0) != 0)
+                       return 1;
+               if (cmov2 (1) != 1)
+                       return 2;
+               return 0;
+       }
 }