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_ovf () {
257 i = System.Int32.MinValue;
262 if (k != System.Int32.MinValue)
266 i = System.Int32.MaxValue;
271 if (k != System.Int32.MaxValue)
275 i = System.Int32.MinValue;
276 j = System.Int32.MaxValue;
284 i = System.Int32.MaxValue;
285 j = System.Int32.MinValue;
293 i = System.Int32.MinValue + 1234;
298 if (k != System.Int32.MinValue)
302 i = System.Int32.MaxValue - 1234;
307 if (k != System.Int32.MaxValue)
313 public static int test_0_add_un_ovf () {
314 uint n = (uint)134217728 * 16;
315 uint number = checked (n + (uint)0);
317 return number == n ? 0 : 1;
320 public static int test_0_sub_ovf () {
324 i = System.Int32.MinValue;
329 if (k != System.Int32.MinValue)
333 i = System.Int32.MaxValue;
338 if (k != System.Int32.MaxValue)
342 i = System.Int32.MinValue;
343 j = System.Int32.MinValue + 1234;
351 i = System.Int32.MaxValue;
356 if (k != System.Int32.MaxValue - 1234)
360 i = System.Int32.MaxValue - 1234;
365 if (k != System.Int32.MaxValue)
369 i = System.Int32.MinValue + 1234;
374 if (k != System.Int32.MinValue)
380 public static int test_0_sub_ovf_un () {
384 i = System.UInt32.MaxValue;
389 if (k != System.UInt32.MaxValue)
393 i = System.UInt32.MaxValue;
394 j = System.UInt32.MaxValue;
404 public static int test_3_or () {
410 public static int test_3_or_un () {
416 public static int test_3_or_short_un () {
422 public static int test_18_or_imm () {
427 public static int test_268435458_or_large_imm () {
429 return b | 0x10000000;
432 public static int test_268435459_or_large_imm2 () {
434 return b | 0x10000001;
437 public static int test_1_xor () {
443 public static int test_1_xor_imm () {
448 public static int test_983041_xor_imm_large () {
453 public static int test_1_neg () {
459 public static int test_2_not () {
465 public static int test_16_shift () {
471 public static int test_16_shift_add () {
478 public static int test_16_shift_add2 () {
485 public static int test_16_shift_imm () {
490 public static int test_524288_shift_imm_large () {
495 public static int test_12_shift_imm_inv () {
500 public static int test_12_shift_imm_inv_sbyte () {
505 public static int test_1_rshift_imm () {
510 public static int test_2_unrshift_imm () {
512 return (int)(b >> 3);
515 public static int test_0_bigunrshift_imm () {
525 public static int test_0_bigrshift_imm () {
533 public static int test_1_rshift () {
539 public static int test_2_unrshift () {
542 return (int)(b >> a);
545 public static int test_0_bigunrshift () {
556 public static int test_0_bigrshift () {
565 public static int test_2_cond () {
572 public static int test_2_cond_short () {
573 short b = 2, a = 3, c;
579 public static int test_2_cond_sbyte () {
580 sbyte b = 2, a = 3, c;
586 public static int test_6_cascade_cond () {
600 public static int test_6_cascade_short () {
601 short b = 2, a = 3, c;
614 public static int test_0_short_sign_extend () {
616 short s1 = (short)t1;
619 if ((uint)t2 != 0xffffeedd)
625 public static int test_15_for_loop () {
627 for (i = 0; i < 15; ++i) {
632 public static int test_11_nested_for_loop () {
633 int i, j = 0; /* mcs bug here if j not set */
634 for (i = 0; i < 15; ++i) {
635 for (j = 200; j >= 5; --j) ;
640 public static int test_11_several_nested_for_loops () {
641 int i, j = 0; /* mcs bug here if j not set */
642 for (i = 0; i < 15; ++i) {
643 for (j = 200; j >= 5; --j) ;
646 for (i = 0; i < 15; ++i) {
647 for (j = 200; j >= 5; --j) ;
652 public static int test_0_conv_ovf_i1 () {
655 //for (int j = 0; j < 10000000; j++)
666 public static int test_0_conv_ovf_i1_un () {
677 public static int test_0_conv_ovf_i2 () {
695 public static int test_0_conv_ovf_i2_un () {
706 public static int test_0_conv_ovf_u2 () {
711 UInt16 b = (UInt16)c;
717 public static int test_0_conv_ovf_u2_un () {
722 UInt16 b = (UInt16)c;
728 public static int test_0_conv_ovf_u4 () {
739 public static int test_0_conv_ovf_i4_un () {
750 public static int test_0_bool () {
757 public static int test_1_bool_inverted () {
764 public static int test_1_bool_assign () {
766 val = !val; // this should produce a ceq
772 public static int test_1_bool_multi () {
776 if ((val && !val2) && (!val2 && val))
781 public static int test_16_spill () {
788 return (1 + (a + (b + (c + (d + e)))));
791 public static int test_1_switch () {
804 public static int test_0_switch_constprop () {
817 public static int test_0_switch_constprop2 () {
830 public static int test_0_while_loop_1 () {
836 } while (value != 0);
841 public static int test_0_while_loop_2 () {
847 } while (value != 0 && position > 1);
852 public static int test_0_char_conv () {
855 char tc = (char) ('0' + i);
863 public static int test_3_shift_regalloc () {
868 orig &= ~(0xff << shift);
869 orig |= value << shift;
878 public static int test_2_optimize_branches () {
888 public static int test_0_checked_byte_cast () {
890 int b = checked ((byte) (v));
897 public static int test_0_checked_byte_cast_un () {
899 uint b = checked ((byte) (v));
906 public static int test_0_checked_short_cast () {
908 int b = checked ((ushort) (v));
915 public static int test_0_checked_short_cast_un () {
917 uint b = checked ((ushort) (v));
924 public static int test_1_a_eq_b_plus_a () {
930 public static int test_0_comp () {
959 public static int test_0_comp_unsigned () {
1018 public static int test_16_cmov ()
1027 public static int test_0_and_cmp ()
1030 int local = 0x01020304;
1032 if ((local & 0x01020304) == 0)
1035 if ((local & 0x00000304) == 0)
1038 if ((local & 0x00000004) == 0)
1041 if ((local & 0x00000300) == 0)
1044 if ((local & 0x00020000) == 0)
1047 if ((local & 0x01000000) == 0)
1053 public static int test_0_mul_imm_opt ()
1091 if ((i * 10) != -10)
1097 if ((i * 12) != -12)
1103 if ((i * 25) != -25)
1106 if ((i * 100) != 100)
1109 if ((i * 100) != -100)
1115 public static int test_0_cne ()
1131 public static int test_0_cmp_regvar_zero ()
1135 if (!(n > 0 && n >= 0 && n != 0))
1137 if (n < 0 || n <= 0 || n == 0)
1143 public static int test_5_div_un_cfold ()
1148 return (int)(i / j);
1151 public static int test_1_rem_un_cfold ()
1156 return (int)(i % j);