X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Fbasic.cs;h=45e449430939e74bc54eae78956383f035d0c612;hb=f35a601c56f922bdb8e351645c810607d933159e;hp=671f0ccc459f67d5c1123e32ee5c0b6ac85e6b57;hpb=3d2ecbf6bfb5191d9329be75b6f8b79088b16c5a;p=mono.git diff --git a/mono/mini/basic.cs b/mono/mini/basic.cs index 671f0ccc459..45e44943093 100644 --- a/mono/mini/basic.cs +++ b/mono/mini/basic.cs @@ -152,6 +152,16 @@ class Tests { return b / 2; } + public static int test_2_div_fold4 () { + int b = -8; + return -(b / 4); + } + + public static int test_2_div_fold16 () { + int b = 32; + return b / 16; + } + public static int test_719177_div_destreg () { int year = 1970; return ((365* (year-1)) + ((year-1)/4)); @@ -240,7 +250,7 @@ class Tests { return (int)res; } - public static int test_0_add_ovf () { + public static int test_0_add_ovf1 () { int i, j, k; checked { @@ -251,6 +261,11 @@ class Tests { if (k != System.Int32.MinValue) return 1; + return 0; + } + + public static int test_0_add_ovf2 () { + int i, j, k; checked { i = System.Int32.MaxValue; @@ -260,6 +275,11 @@ class Tests { if (k != System.Int32.MaxValue) return 2; + return 0; + } + + public static int test_0_add_ovf3 () { + int i, j, k; checked { i = System.Int32.MinValue; @@ -269,6 +289,11 @@ class Tests { if (k != -1) return 3; + return 0; + } + + public static int test_0_add_ovf4 () { + int i, j, k; checked { i = System.Int32.MaxValue; @@ -278,6 +303,11 @@ class Tests { if (k != -1) return 4; + return 0; + } + + public static int test_0_add_ovf5 () { + int i, j, k; checked { i = System.Int32.MinValue + 1234; @@ -287,6 +317,11 @@ class Tests { if (k != System.Int32.MinValue) return 5; + return 0; + } + + public static int test_0_add_ovf6 () { + int i, j, k; checked { i = System.Int32.MaxValue - 1234; @@ -307,6 +342,120 @@ class Tests { return number == n ? 0 : 1; } + public static int test_0_sub_ovf1 () { + int i, j, k; + + checked { + i = System.Int32.MinValue; + j = 0; + k = i - j; + } + + if (k != System.Int32.MinValue) + return 1; + + return 0; + } + + public static int test_0_sub_ovf2 () { + int i, j, k; + + checked { + i = System.Int32.MaxValue; + j = 0; + k = i - j; + } + + if (k != System.Int32.MaxValue) + return 2; + + return 0; + } + + public static int test_0_sub_ovf3 () { + int i, j, k; + + checked { + i = System.Int32.MinValue; + j = System.Int32.MinValue + 1234; + k = i - j; + } + + if (k != -1234) + return 3; + + return 0; + } + + public static int test_0_sub_ovf4 () { + int i, j, k; + + checked { + i = System.Int32.MaxValue; + j = 1234; + k = i - j; + } + + if (k != System.Int32.MaxValue - 1234) + return 4; + + return 0; + } + + public static int test_0_sub_ovf5 () { + int i, j, k; + + checked { + i = System.Int32.MaxValue - 1234; + j = -1234; + k = i - j; + } + + if (k != System.Int32.MaxValue) + return 5; + + return 0; + } + + public static int test_0_sub_ovf6 () { + int i, j, k; + + checked { + i = System.Int32.MinValue + 1234; + j = 1234; + k = i - j; + } + + if (k != System.Int32.MinValue) + return 6; + + return 0; + } + + public static int test_0_sub_ovf_un () { + uint i, j, k; + + checked { + i = System.UInt32.MaxValue; + j = 0; + k = i - j; + } + + if (k != System.UInt32.MaxValue) + return 1; + + checked { + i = System.UInt32.MaxValue; + j = System.UInt32.MaxValue; + k = i - j; + } + + if (k != 0) + return 2; + + return 0; + } + public static int test_3_or () { int b = 2; int a = 3; @@ -641,6 +790,17 @@ class Tests { return 0; } + + public static int test_0_conv_ovf_i4_un () { + uint c; + + checked { + c = 0x7fffffff; + int b = (int)c; + } + + return 0; + } public static int test_0_bool () { bool val = true; @@ -918,33 +1078,9 @@ class Tests { return n; } - - public static int my_flags; + public static int test_0_and_cmp () { - - /* various forms of test [mem], imm */ - - my_flags = 0x01020304; - - if ((my_flags & 0x01020304) == 0) - return 1; - - if ((my_flags & 0x00000304) == 0) - return 2; - - if ((my_flags & 0x00000004) == 0) - return 3; - - if ((my_flags & 0x00000300) == 0) - return 4; - - if ((my_flags & 0x00020000) == 0) - return 5; - - if ((my_flags & 0x01000000) == 0) - return 6; - /* test esi, imm */ int local = 0x01020304; @@ -965,6 +1101,68 @@ class Tests { if ((local & 0x01000000) == 0) return 12; + + return 0; + } + + public static int test_0_mul_imm_opt () + { + int i; + + i = 1; + if ((i * 2) != 2) + return 1; + i = -1; + if ((i * 2) != -2) + return 2; + i = 1; + if ((i * 3) != 3) + return 3; + i = -1; + if ((i * 3) != -3) + return 4; + i = 1; + if ((i * 5) != 5) + return 5; + i = -1; + if ((i * 5) != -5) + return 6; + i = 1; + if ((i * 6) != 6) + return 7; + i = -1; + if ((i * 6) != -6) + return 8; + i = 1; + if ((i * 9) != 9) + return 9; + i = -1; + if ((i * 9) != -9) + return 10; + i = 1; + if ((i * 10) != 10) + return 11; + i = -1; + if ((i * 10) != -10) + return 12; + i = 1; + if ((i * 12) != 12) + return 13; + i = -1; + if ((i * 12) != -12) + return 14; + i = 1; + if ((i * 25) != 25) + return 15; + i = -1; + if ((i * 25) != -25) + return 16; + i = 1; + if ((i * 100) != 100) + return 17; + i = -1; + if ((i * 100) != -100) + return 18; return 0; } @@ -984,22 +1182,7 @@ class Tests { return 0; } - - static byte b; - public static int test_0_byte_compares () - { - b = 0xff; - if (b == -1) - return 1; - b = 0; - if (!(b < System.Byte.MaxValue)) - return 2; - - if (!(b <= System.Byte.MaxValue)) - return 3; - - return 0; - } + public static int test_0_cmp_regvar_zero () { int n = 10; @@ -1012,4 +1195,84 @@ class Tests { return 0; } + public static int test_5_div_un_cfold () + { + uint i = 10; + uint j = 2; + + return (int)(i / j); + } + + public static int test_1_rem_un_cfold () + { + uint i = 11; + uint j = 2; + + 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; + } + }