2 using System.Reflection;
5 * Regression tests for the mono JIT.
7 * Each test needs to be of the form:
9 * static int test_<result>_<name> ();
11 * where <result> is an integer (the value that needs to be returned by
12 * the method to make it pass.
13 * <name> is a user-displayed name used to identify the test.
15 * The tests can be driven in two ways:
16 * *) running the program directly: Main() uses reflection to find and invoke
17 * the test methods (this is useful mostly to check that the tests are correct)
18 * *) with the --regression switch of the jit (this is the preferred way since
19 * all the tests will be run with optimizations on and off)
21 * The reflection logic could be moved to a .dll since we need at least another
22 * regression test file written in IL code to have better control on how
29 return TestDriver.RunTests (typeof (Tests));
32 public static int test_0_return () {
36 public static int test_100000_return_large () {
40 public static int test_1_load_bool () {
45 public static int test_0_load_bool_false () {
50 public static int test_200_load_byte () {
55 public static int test_100_load_sbyte () {
60 public static int test_200_load_short () {
65 public static int test_100_load_ushort () {
70 public static int test_3_add_simple () {
76 public static int test_3_add_imm () {
81 public static int test_13407573_add_largeimm () {
86 public static int test_1_sub_simple () {
92 public static int test_1_sub_simple_un () {
98 public static int test_1_sub_imm () {
103 public static int test_2_sub_large_imm () {
108 public static int test_0_sub_inv_imm () {
113 public static int test_2_and () {
119 public static int test_0_and_imm () {
124 public static int test_0_and_large_imm () {
126 return b & 0x10000000;
129 public static int test_0_and_large_imm2 () {
131 return b & 0x100000f0;
134 public static int test_2_div () {
140 public static int test_4_div_imm () {
145 public static int test_4_divun_imm () {
150 public static int test_0_div_fold () {
155 public static int test_2_div_fold4 () {
160 public static int test_2_div_fold16 () {
165 public static int test_719177_div_destreg () {
167 return ((365* (year-1)) + ((year-1)/4));
170 public static int test_1_remun_imm () {
175 public static int test_2_bigremun_imm () {
182 public static int test_2_rem () {
188 public static int test_4_rem_imm () {
193 public static int test_4_rem_big_imm () {
198 public static int test_9_mul () {
204 public static int test_15_mul_imm () {
209 public static int test_24_mul () {
219 public static int test_24_mul_ovf () {
231 public static int test_24_mul_un () {
241 public static int test_24_mul_ovf_un () {
253 public static int test_0_add_ovf1 () {
257 i = System.Int32.MinValue;
262 if (k != System.Int32.MinValue)
267 public static int test_0_add_ovf2 () {
271 i = System.Int32.MaxValue;
276 if (k != System.Int32.MaxValue)
281 public static int test_0_add_ovf3 () {
285 i = System.Int32.MinValue;
286 j = System.Int32.MaxValue;
295 public static int test_0_add_ovf4 () {
299 i = System.Int32.MaxValue;
300 j = System.Int32.MinValue;
309 public static int test_0_add_ovf5 () {
313 i = System.Int32.MinValue + 1234;
318 if (k != System.Int32.MinValue)
323 public static int test_0_add_ovf6 () {
327 i = System.Int32.MaxValue - 1234;
332 if (k != System.Int32.MaxValue)
338 public static int test_0_add_un_ovf () {
339 uint n = (uint)134217728 * 16;
340 uint number = checked (n + (uint)0);
342 return number == n ? 0 : 1;
345 public static int test_0_sub_ovf1 () {
349 i = System.Int32.MinValue;
354 if (k != System.Int32.MinValue)
360 public static int test_0_sub_ovf2 () {
364 i = System.Int32.MaxValue;
369 if (k != System.Int32.MaxValue)
375 public static int test_0_sub_ovf3 () {
379 i = System.Int32.MinValue;
380 j = System.Int32.MinValue + 1234;
390 public static int test_0_sub_ovf4 () {
394 i = System.Int32.MaxValue;
399 if (k != System.Int32.MaxValue - 1234)
405 public static int test_0_sub_ovf5 () {
409 i = System.Int32.MaxValue - 1234;
414 if (k != System.Int32.MaxValue)
420 public static int test_0_sub_ovf6 () {
424 i = System.Int32.MinValue + 1234;
429 if (k != System.Int32.MinValue)
435 public static int test_0_sub_ovf_un () {
439 i = System.UInt32.MaxValue;
444 if (k != System.UInt32.MaxValue)
448 i = System.UInt32.MaxValue;
449 j = System.UInt32.MaxValue;
459 public static int test_3_or () {
465 public static int test_3_or_un () {
471 public static int test_3_or_short_un () {
477 public static int test_18_or_imm () {
482 public static int test_268435458_or_large_imm () {
484 return b | 0x10000000;
487 public static int test_268435459_or_large_imm2 () {
489 return b | 0x10000001;
492 public static int test_1_xor () {
498 public static int test_1_xor_imm () {
503 public static int test_983041_xor_imm_large () {
508 public static int test_1_neg () {
514 public static int test_2_not () {
520 public static int test_16_shift () {
526 public static int test_16_shift_add () {
533 public static int test_16_shift_add2 () {
540 public static int test_16_shift_imm () {
545 public static int test_524288_shift_imm_large () {
550 public static int test_12_shift_imm_inv () {
555 public static int test_12_shift_imm_inv_sbyte () {
560 public static int test_1_rshift_imm () {
565 public static int test_2_unrshift_imm () {
567 return (int)(b >> 3);
570 public static int test_0_bigunrshift_imm () {
580 public static int test_0_bigrshift_imm () {
588 public static int test_1_rshift () {
594 public static int test_2_unrshift () {
597 return (int)(b >> a);
600 public static int test_0_bigunrshift () {
611 public static int test_0_bigrshift () {
620 public static int test_2_cond () {
627 public static int test_2_cond_short () {
628 short b = 2, a = 3, c;
634 public static int test_2_cond_sbyte () {
635 sbyte b = 2, a = 3, c;
641 public static int test_6_cascade_cond () {
655 public static int test_6_cascade_short () {
656 short b = 2, a = 3, c;
669 public static int test_0_short_sign_extend () {
671 short s1 = (short)t1;
674 if ((uint)t2 != 0xffffeedd)
680 public static int test_127_iconv_to_i1 () {
687 public static int test_384_iconv_to_i2 () {
694 public static int test_15_for_loop () {
696 for (i = 0; i < 15; ++i) {
701 public static int test_11_nested_for_loop () {
702 int i, j = 0; /* mcs bug here if j not set */
703 for (i = 0; i < 15; ++i) {
704 for (j = 200; j >= 5; --j) ;
709 public static int test_11_several_nested_for_loops () {
710 int i, j = 0; /* mcs bug here if j not set */
711 for (i = 0; i < 15; ++i) {
712 for (j = 200; j >= 5; --j) ;
715 for (i = 0; i < 15; ++i) {
716 for (j = 200; j >= 5; --j) ;
721 public static int test_0_conv_ovf_i1 () {
724 //for (int j = 0; j < 10000000; j++)
735 public static int test_0_conv_ovf_i1_un () {
746 public static int test_0_conv_ovf_i2 () {
764 public static int test_0_conv_ovf_i2_un () {
775 public static int test_0_conv_ovf_u2 () {
780 UInt16 b = (UInt16)c;
786 public static int test_0_conv_ovf_u2_un () {
791 UInt16 b = (UInt16)c;
797 public static int test_0_conv_ovf_u4 () {
808 public static int test_0_conv_ovf_i4_un () {
819 public static int test_0_bool () {
826 public static int test_1_bool_inverted () {
833 public static int test_1_bool_assign () {
835 val = !val; // this should produce a ceq
841 public static int test_1_bool_multi () {
845 if ((val && !val2) && (!val2 && val))
850 public static int test_16_spill () {
857 return (1 + (a + (b + (c + (d + e)))));
860 public static int test_1_switch () {
873 public static int test_0_switch_constprop () {
886 public static int test_0_switch_constprop2 () {
899 public static int test_0_while_loop_1 () {
905 } while (value != 0);
910 public static int test_0_while_loop_2 () {
916 } while (value != 0 && position > 1);
921 public static int test_0_char_conv () {
924 char tc = (char) ('0' + i);
932 public static int test_3_shift_regalloc () {
937 orig &= ~(0xff << shift);
938 orig |= value << shift;
947 public static int test_2_optimize_branches () {
957 public static int test_0_checked_byte_cast () {
959 int b = checked ((byte) (v));
966 public static int test_0_checked_byte_cast_un () {
968 uint b = checked ((byte) (v));
975 public static int test_0_checked_short_cast () {
977 int b = checked ((ushort) (v));
984 public static int test_0_checked_short_cast_un () {
986 uint b = checked ((ushort) (v));
993 public static int test_1_a_eq_b_plus_a () {
999 public static int test_0_comp () {
1028 public static int test_0_comp_unsigned () {
1030 uint b = 0xffffffff;
1087 public static int test_16_cmov ()
1096 public static int test_0_and_cmp ()
1099 int local = 0x01020304;
1101 if ((local & 0x01020304) == 0)
1104 if ((local & 0x00000304) == 0)
1107 if ((local & 0x00000004) == 0)
1110 if ((local & 0x00000300) == 0)
1113 if ((local & 0x00020000) == 0)
1116 if ((local & 0x01000000) == 0)
1122 public static int test_0_mul_imm_opt ()
1160 if ((i * 10) != -10)
1166 if ((i * 12) != -12)
1172 if ((i * 25) != -25)
1175 if ((i * 100) != 100)
1178 if ((i * 100) != -100)
1184 public static int test_0_cne ()
1200 public static int test_0_cmp_regvar_zero ()
1204 if (!(n > 0 && n >= 0 && n != 0))
1206 if (n < 0 || n <= 0 || n == 0)
1212 public static int test_5_div_un_cfold ()
1217 return (int)(i / j);
1220 public static int test_1_rem_un_cfold ()
1225 return (int)(i % j);
1228 public static int test_0_div_opt () {
1231 // Avoid cfolding this
1233 for (int j = 0; j < 1234567; ++j)
1235 if ((i / 2) != 617283)
1237 if ((i / 4) != 308641)
1239 if ((i / 8) != 154320)
1241 if ((i / 16) != 77160)
1244 // Avoid cfolding this
1246 for (int j = 0; j < 1234567; ++j)
1248 if ((i / 2) != -617283)
1250 if ((i / 4) != -308641)
1252 if ((i / 8) != -154320)
1254 if ((i / 16) != -77160)
1260 public static int test_0_rem_opt () {
1263 // Avoid cfolding this
1265 for (int j = 0; j < 29; ++j)
1276 // Avoid cfolding this
1278 for (int j = 0; j < 29; ++j)
1286 if ((i % 16) != -13)
1292 public static int cmov (int i) {
1301 public static int cmov2 (int i) {
1312 public static int test_0_branch_to_cmov_opt () {