X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Fbasic.cs;h=984f1ac27f084f91d38bd2616ad1ff7e998d46a3;hb=7f6370f8491aa78c7ced5af5970c2ccc14e4d011;hp=7f349f2ab388a31581e9c1805d1c28b93250965d;hpb=5136bd47ed2afb68c78082873680dd8b888f2664;p=mono.git diff --git a/mono/mini/basic.cs b/mono/mini/basic.cs index 7f349f2ab38..984f1ac27f0 100644 --- a/mono/mini/basic.cs +++ b/mono/mini/basic.cs @@ -23,11 +23,18 @@ using System.Reflection; * the IL code looks. */ -class Tests { - - static int Main () { - return TestDriver.RunTests (typeof (Tests)); - } +#if __MOBILE__ +class BasicTests +#else +class Tests +#endif +{ + +#if !__MOBILE__ + public static int Main (string[] args) { + return TestDriver.RunTests (typeof (Tests), args); + } +#endif public static int test_0_return () { return 0; @@ -195,6 +202,11 @@ class Tests { return b % 1; } + public static int test_0_rem_imm_0_neg () { + int b = -2; + return b % 1; + } + public static int test_4_rem_big_imm () { int b = 10004; return b % 10000; @@ -1235,8 +1247,9 @@ class Tests { // Avoid cfolding this i = 0; - for (int j = 0; j < 1234567; ++j) + for (int j = 0; j < 567; ++j) i ++; + i += 1234000; if ((i / 2) != 617283) return 1; if ((i / 4) != 308641) @@ -1248,8 +1261,9 @@ class Tests { // Avoid cfolding this i = 0; - for (int j = 0; j < 1234567; ++j) + for (int j = 0; j < 567; ++j) i --; + i -= 1234000; if ((i / 2) != -617283) return 5; if ((i / 4) != -308641) @@ -1262,6 +1276,105 @@ class Tests { return 0; } + public static int test_0_udiv_opt () { + uint i; + + // Avoid cfolding this + i = 0; + for (int j = 0; j < 567; ++j) + i ++; + i += 1234000; + if ((i / 2) != 617283) + return 1; + if ((i / 4) != 308641) + return 2; + if ((i / 8) != 154320) + return 3; + if ((i / 16) != 77160) + return 4; + + return 0; + } + + public static int test_0_signed_ct_div () { + int n = 2147483647; + bool divide_by_zero = false; + bool overflow = false; + + if ((n / 2147483647) != 1) + return 1; + if ((n / -2147483647) != -1) + return 2; + n = -n; + if ((n / 2147483647) != -1) + return 3; + n--; /* MinValue */ + if ((n / -2147483648) != 1) + return 4; + if ((n / 2147483647) != -1) + return 5; + if ((n / 1) != n) + return 6; + + try { + int r = n / (-1); + } catch (OverflowException) { + overflow = true; + } + if (!overflow) + return 7; + + try { + int r = n / 0; + } catch (DivideByZeroException) { + divide_by_zero = true; + } + if (!divide_by_zero) + return 8; + + if ((n / 35) != -61356675) + return 9; + if ((n / -35) != 61356675) + return 10; + n = -(n + 1); /* MaxValue */ + if ((n / 35) != 61356675) + return 11; + if ((n / -35) != -61356675) + return 12; + + return 0; + } + + public static int test_0_unsigned_ct_div () { + uint n = 4294967295; + bool divide_by_zero = false; + + if ((n / 4294967295) != 1) + return 1; + n--; + if ((n / 4294967295) != 0) + return 2; + n++; + if ((n / 4294967294) != 1) + return 3; + if ((n / 1) != n) + return 4; + + try { + uint a = n / 0; + } catch (DivideByZeroException) { + divide_by_zero = true; + } + + if (!divide_by_zero) + return 5; + + if ((n / 35) != 122713351) + return 9; + + return 0; + } + public static int test_0_rem_opt () { int i; @@ -1326,19 +1439,32 @@ class Tests { return 0; } - //repro for #506915 - struct Bug506915 { public int val; } - static int test_2_ldobj_stobj_optization (string[] args) - { - int i = 99; - var a = new Bug506915 (); - var b = new Bug506915 (); - if (i.GetHashCode () == 99) - i = 44; - var array = new Bug506915 [2]; - array [0].val = 2; - array [1] = (i == 0) ? a : array [0]; - - return array [1].val; + public static unsafe int test_0_ishr_sign_extend () { + // Check that ishr does sign extension from bit 31 on 64 bit platforms + uint val = 0xF0000000u; + + uint *a = &val; + uint ui = (uint)((int)(*a) >> 2); + + if (ui != 0xfc000000) + return 1; + + // Same with non-immediates + int amount = 2; + + ui = (uint)((int)(*a) >> amount); + + if (ui != 0xfc000000) + return 2; + + return 0; + } + + public static unsafe int test_0_ishr_sign_extend_cfold () { + int i = 32768; + int j = i << 16; + int k = j >> 16; + + return k == -32768 ? 0 : 1; } }