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_0_rem_imm_0 () {
198 public static int test_4_rem_big_imm () {
203 public static int test_9_mul () {
209 public static int test_15_mul_imm () {
214 public static int test_24_mul () {
224 public static int test_24_mul_ovf () {
236 public static int test_24_mul_un () {
246 public static int test_24_mul_ovf_un () {
258 public static int test_0_add_ovf1 () {
262 i = System.Int32.MinValue;
267 if (k != System.Int32.MinValue)
272 public static int test_0_add_ovf2 () {
276 i = System.Int32.MaxValue;
281 if (k != System.Int32.MaxValue)
286 public static int test_0_add_ovf3 () {
290 i = System.Int32.MinValue;
291 j = System.Int32.MaxValue;
300 public static int test_0_add_ovf4 () {
304 i = System.Int32.MaxValue;
305 j = System.Int32.MinValue;
314 public static int test_0_add_ovf5 () {
318 i = System.Int32.MinValue + 1234;
323 if (k != System.Int32.MinValue)
328 public static int test_0_add_ovf6 () {
332 i = System.Int32.MaxValue - 1234;
337 if (k != System.Int32.MaxValue)
343 public static int test_0_add_un_ovf () {
344 uint n = (uint)134217728 * 16;
345 uint number = checked (n + (uint)0);
347 return number == n ? 0 : 1;
350 public static int test_0_sub_ovf1 () {
354 i = System.Int32.MinValue;
359 if (k != System.Int32.MinValue)
365 public static int test_0_sub_ovf2 () {
369 i = System.Int32.MaxValue;
374 if (k != System.Int32.MaxValue)
380 public static int test_0_sub_ovf3 () {
384 i = System.Int32.MinValue;
385 j = System.Int32.MinValue + 1234;
395 public static int test_0_sub_ovf4 () {
399 i = System.Int32.MaxValue;
404 if (k != System.Int32.MaxValue - 1234)
410 public static int test_0_sub_ovf5 () {
414 i = System.Int32.MaxValue - 1234;
419 if (k != System.Int32.MaxValue)
425 public static int test_0_sub_ovf6 () {
429 i = System.Int32.MinValue + 1234;
434 if (k != System.Int32.MinValue)
440 public static int test_0_sub_ovf_un () {
444 i = System.UInt32.MaxValue;
449 if (k != System.UInt32.MaxValue)
453 i = System.UInt32.MaxValue;
454 j = System.UInt32.MaxValue;
464 public static int test_3_or () {
470 public static int test_3_or_un () {
476 public static int test_3_or_short_un () {
482 public static int test_18_or_imm () {
487 public static int test_268435458_or_large_imm () {
489 return b | 0x10000000;
492 public static int test_268435459_or_large_imm2 () {
494 return b | 0x10000001;
497 public static int test_1_xor () {
503 public static int test_1_xor_imm () {
508 public static int test_983041_xor_imm_large () {
513 public static int test_1_neg () {
519 public static int test_2_not () {
525 public static int test_16_shift () {
531 public static int test_16_shift_add () {
538 public static int test_16_shift_add2 () {
545 public static int test_16_shift_imm () {
550 public static int test_524288_shift_imm_large () {
555 public static int test_12_shift_imm_inv () {
560 public static int test_12_shift_imm_inv_sbyte () {
565 public static int test_1_rshift_imm () {
570 public static int test_2_unrshift_imm () {
572 return (int)(b >> 3);
575 public static int test_0_bigunrshift_imm () {
585 public static int test_0_bigrshift_imm () {
593 public static int test_1_rshift () {
599 public static int test_2_unrshift () {
602 return (int)(b >> a);
605 public static int test_0_bigunrshift () {
616 public static int test_0_bigrshift () {
625 public static int test_2_cond () {
632 public static int test_2_cond_short () {
633 short b = 2, a = 3, c;
639 public static int test_2_cond_sbyte () {
640 sbyte b = 2, a = 3, c;
646 public static int test_6_cascade_cond () {
660 public static int test_6_cascade_short () {
661 short b = 2, a = 3, c;
674 public static int test_0_short_sign_extend () {
676 short s1 = (short)t1;
679 if ((uint)t2 != 0xffffeedd)
685 public static int test_127_iconv_to_i1 () {
692 public static int test_384_iconv_to_i2 () {
699 public static int test_15_for_loop () {
701 for (i = 0; i < 15; ++i) {
706 public static int test_11_nested_for_loop () {
707 int i, j = 0; /* mcs bug here if j not set */
708 for (i = 0; i < 15; ++i) {
709 for (j = 200; j >= 5; --j) ;
714 public static int test_11_several_nested_for_loops () {
715 int i, j = 0; /* mcs bug here if j not set */
716 for (i = 0; i < 15; ++i) {
717 for (j = 200; j >= 5; --j) ;
720 for (i = 0; i < 15; ++i) {
721 for (j = 200; j >= 5; --j) ;
726 public static int test_0_conv_ovf_i1 () {
729 //for (int j = 0; j < 10000000; j++)
740 public static int test_0_conv_ovf_i1_un () {
751 public static int test_0_conv_ovf_i2 () {
769 public static int test_0_conv_ovf_i2_un () {
780 public static int test_0_conv_ovf_u2 () {
785 UInt16 b = (UInt16)c;
791 public static int test_0_conv_ovf_u2_un () {
796 UInt16 b = (UInt16)c;
802 public static int test_0_conv_ovf_u4 () {
813 public static int test_0_conv_ovf_i4_un () {
824 public static int test_0_bool () {
831 public static int test_1_bool_inverted () {
838 public static int test_1_bool_assign () {
840 val = !val; // this should produce a ceq
846 public static int test_1_bool_multi () {
850 if ((val && !val2) && (!val2 && val))
855 public static int test_16_spill () {
862 return (1 + (a + (b + (c + (d + e)))));
865 public static int test_1_switch () {
878 public static int test_0_switch_constprop () {
891 public static int test_0_switch_constprop2 () {
904 public static int test_0_while_loop_1 () {
910 } while (value != 0);
915 public static int test_0_while_loop_2 () {
921 } while (value != 0 && position > 1);
926 public static int test_0_char_conv () {
929 char tc = (char) ('0' + i);
937 public static int test_3_shift_regalloc () {
942 orig &= ~(0xff << shift);
943 orig |= value << shift;
952 public static int test_2_optimize_branches () {
962 public static int test_0_checked_byte_cast () {
964 int b = checked ((byte) (v));
971 public static int test_0_checked_byte_cast_un () {
973 uint b = checked ((byte) (v));
980 public static int test_0_checked_short_cast () {
982 int b = checked ((ushort) (v));
989 public static int test_0_checked_short_cast_un () {
991 uint b = checked ((ushort) (v));
998 public static int test_1_a_eq_b_plus_a () {
1004 public static int test_0_comp () {
1033 public static int test_0_comp_unsigned () {
1035 uint b = 0xffffffff;
1092 public static int test_16_cmov ()
1101 public static int test_0_and_cmp ()
1104 int local = 0x01020304;
1106 if ((local & 0x01020304) == 0)
1109 if ((local & 0x00000304) == 0)
1112 if ((local & 0x00000004) == 0)
1115 if ((local & 0x00000300) == 0)
1118 if ((local & 0x00020000) == 0)
1121 if ((local & 0x01000000) == 0)
1127 public static int test_0_mul_imm_opt ()
1165 if ((i * 10) != -10)
1171 if ((i * 12) != -12)
1177 if ((i * 25) != -25)
1180 if ((i * 100) != 100)
1183 if ((i * 100) != -100)
1189 public static int test_0_cne ()
1205 public static int test_0_cmp_regvar_zero ()
1209 if (!(n > 0 && n >= 0 && n != 0))
1211 if (n < 0 || n <= 0 || n == 0)
1217 public static int test_5_div_un_cfold ()
1222 return (int)(i / j);
1225 public static int test_1_rem_un_cfold ()
1230 return (int)(i % j);
1233 public static int test_0_div_opt () {
1236 // Avoid cfolding this
1238 for (int j = 0; j < 1234567; ++j)
1240 if ((i / 2) != 617283)
1242 if ((i / 4) != 308641)
1244 if ((i / 8) != 154320)
1246 if ((i / 16) != 77160)
1249 // Avoid cfolding this
1251 for (int j = 0; j < 1234567; ++j)
1253 if ((i / 2) != -617283)
1255 if ((i / 4) != -308641)
1257 if ((i / 8) != -154320)
1259 if ((i / 16) != -77160)
1265 public static int test_0_rem_opt () {
1268 // Avoid cfolding this
1270 for (int j = 0; j < 29; ++j)
1281 // Avoid cfolding this
1283 for (int j = 0; j < 29; ++j)
1291 if ((i % 16) != -13)
1297 public static int cmov (int i) {
1306 public static int cmov2 (int i) {
1317 public static int test_0_branch_to_cmov_opt () {
1330 public static int test_2_cprop_bug () {
1333 var cmp = System.Collections.Generic.Comparer<int>.Default ;
1334 if (cmp.Compare (a, 0) > 0)
1336 do { idx++; } while (cmp.Compare (idx - 1, a) == 0);