if we're intentionally using power-of-two sizing for chunks, don't add the header...
[mono-project/dkf.git] / mono / mini / basic.cs
blobb700efa87e39503de0291560b09a388d4600241e
1 using System;
2 using System.Reflection;
4 /*
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
23 * the IL code looks.
26 class Tests {
28 static int Main () {
29 return TestDriver.RunTests (typeof (Tests));
32 public static int test_0_return () {
33 return 0;
36 public static int test_100000_return_large () {
37 return 100000;
40 public static int test_1_load_bool () {
41 bool a = true;
42 return a? 1: 0;
45 public static int test_0_load_bool_false () {
46 bool a = false;
47 return a? 1: 0;
50 public static int test_200_load_byte () {
51 byte a = 200;
52 return a;
55 public static int test_100_load_sbyte () {
56 sbyte a = 100;
57 return a;
60 public static int test_200_load_short () {
61 short a = 200;
62 return a;
65 public static int test_100_load_ushort () {
66 ushort a = 100;
67 return a;
70 public static int test_3_add_simple () {
71 int a = 1;
72 int b = 2;
73 return a + b;
76 public static int test_3_add_imm () {
77 int a = 1;
78 return a + 2;
81 public static int test_13407573_add_largeimm () {
82 int a = 1;
83 return a + 13407572;
86 public static int test_1_sub_simple () {
87 int a = 1;
88 int b = 2;
89 return b - a;
92 public static int test_1_sub_simple_un () {
93 uint a = 1;
94 uint b = 2;
95 return (int)(b - a);
98 public static int test_1_sub_imm () {
99 int b = 2;
100 return b - 1;
103 public static int test_2_sub_large_imm () {
104 int b = 0xff0f0f;
105 return b - 0xff0f0d;
108 public static int test_0_sub_inv_imm () {
109 int b = 2;
110 return 2 - b;
113 public static int test_2_and () {
114 int b = 2;
115 int a = 3;
116 return b & a;
119 public static int test_0_and_imm () {
120 int b = 2;
121 return b & 0x10;
124 public static int test_0_and_large_imm () {
125 int b = 2;
126 return b & 0x10000000;
129 public static int test_0_and_large_imm2 () {
130 int b = 2;
131 return b & 0x100000f0;
134 public static int test_2_div () {
135 int b = 6;
136 int a = 3;
137 return b / a;
140 public static int test_4_div_imm () {
141 int b = 12;
142 return b / 3;
145 public static int test_4_divun_imm () {
146 uint b = 12;
147 return (int)(b / 3);
150 public static int test_0_div_fold () {
151 int b = -1;
152 return b / 2;
155 public static int test_2_div_fold4 () {
156 int b = -8;
157 return -(b / 4);
160 public static int test_2_div_fold16 () {
161 int b = 32;
162 return b / 16;
165 public static int test_719177_div_destreg () {
166 int year = 1970;
167 return ((365* (year-1)) + ((year-1)/4));
170 public static int test_1_remun_imm () {
171 uint b = 13;
172 return (int)(b % 3);
175 public static int test_2_bigremun_imm () {
176 unchecked {
177 uint b = (uint)-2;
178 return (int)(b % 3);
182 public static int test_2_rem () {
183 int b = 5;
184 int a = 3;
185 return b % a;
188 public static int test_4_rem_imm () {
189 int b = 12;
190 return b % 8;
193 public static int test_0_rem_imm_0 () {
194 int b = 12;
195 return b % 1;
198 public static int test_0_rem_imm_0_neg () {
199 int b = -2;
200 return b % 1;
203 public static int test_4_rem_big_imm () {
204 int b = 10004;
205 return b % 10000;
208 public static int test_9_mul () {
209 int b = 3;
210 int a = 3;
211 return b * a;
214 public static int test_15_mul_imm () {
215 int b = 3;
216 return b * 5;
219 public static int test_24_mul () {
220 int a = 3;
221 int b = 8;
222 int res;
224 res = a * b;
226 return res;
229 public static int test_24_mul_ovf () {
230 int a = 3;
231 int b = 8;
232 int res;
234 checked {
235 res = a * b;
238 return res;
241 public static int test_24_mul_un () {
242 uint a = 3;
243 uint b = 8;
244 uint res;
246 res = a * b;
248 return (int)res;
251 public static int test_24_mul_ovf_un () {
252 uint a = 3;
253 uint b = 8;
254 uint res;
256 checked {
257 res = a * b;
260 return (int)res;
263 public static int test_0_add_ovf1 () {
264 int i, j, k;
266 checked {
267 i = System.Int32.MinValue;
268 j = 0;
269 k = i + j;
272 if (k != System.Int32.MinValue)
273 return 1;
274 return 0;
277 public static int test_0_add_ovf2 () {
278 int i, j, k;
280 checked {
281 i = System.Int32.MaxValue;
282 j = 0;
283 k = i + j;
286 if (k != System.Int32.MaxValue)
287 return 2;
288 return 0;
291 public static int test_0_add_ovf3 () {
292 int i, j, k;
294 checked {
295 i = System.Int32.MinValue;
296 j = System.Int32.MaxValue;
297 k = i + j;
300 if (k != -1)
301 return 3;
302 return 0;
305 public static int test_0_add_ovf4 () {
306 int i, j, k;
308 checked {
309 i = System.Int32.MaxValue;
310 j = System.Int32.MinValue;
311 k = i + j;
314 if (k != -1)
315 return 4;
316 return 0;
319 public static int test_0_add_ovf5 () {
320 int i, j, k;
322 checked {
323 i = System.Int32.MinValue + 1234;
324 j = -1234;
325 k = i + j;
328 if (k != System.Int32.MinValue)
329 return 5;
330 return 0;
333 public static int test_0_add_ovf6 () {
334 int i, j, k;
336 checked {
337 i = System.Int32.MaxValue - 1234;
338 j = 1234;
339 k = i + j;
342 if (k != System.Int32.MaxValue)
343 return 6;
345 return 0;
348 public static int test_0_add_un_ovf () {
349 uint n = (uint)134217728 * 16;
350 uint number = checked (n + (uint)0);
352 return number == n ? 0 : 1;
355 public static int test_0_sub_ovf1 () {
356 int i, j, k;
358 checked {
359 i = System.Int32.MinValue;
360 j = 0;
361 k = i - j;
364 if (k != System.Int32.MinValue)
365 return 1;
367 return 0;
370 public static int test_0_sub_ovf2 () {
371 int i, j, k;
373 checked {
374 i = System.Int32.MaxValue;
375 j = 0;
376 k = i - j;
379 if (k != System.Int32.MaxValue)
380 return 2;
382 return 0;
385 public static int test_0_sub_ovf3 () {
386 int i, j, k;
388 checked {
389 i = System.Int32.MinValue;
390 j = System.Int32.MinValue + 1234;
391 k = i - j;
394 if (k != -1234)
395 return 3;
397 return 0;
400 public static int test_0_sub_ovf4 () {
401 int i, j, k;
403 checked {
404 i = System.Int32.MaxValue;
405 j = 1234;
406 k = i - j;
409 if (k != System.Int32.MaxValue - 1234)
410 return 4;
412 return 0;
415 public static int test_0_sub_ovf5 () {
416 int i, j, k;
418 checked {
419 i = System.Int32.MaxValue - 1234;
420 j = -1234;
421 k = i - j;
424 if (k != System.Int32.MaxValue)
425 return 5;
427 return 0;
430 public static int test_0_sub_ovf6 () {
431 int i, j, k;
433 checked {
434 i = System.Int32.MinValue + 1234;
435 j = 1234;
436 k = i - j;
439 if (k != System.Int32.MinValue)
440 return 6;
442 return 0;
445 public static int test_0_sub_ovf_un () {
446 uint i, j, k;
448 checked {
449 i = System.UInt32.MaxValue;
450 j = 0;
451 k = i - j;
454 if (k != System.UInt32.MaxValue)
455 return 1;
457 checked {
458 i = System.UInt32.MaxValue;
459 j = System.UInt32.MaxValue;
460 k = i - j;
463 if (k != 0)
464 return 2;
466 return 0;
469 public static int test_3_or () {
470 int b = 2;
471 int a = 3;
472 return b | a;
475 public static int test_3_or_un () {
476 uint b = 2;
477 uint a = 3;
478 return (int)(b | a);
481 public static int test_3_or_short_un () {
482 ushort b = 2;
483 ushort a = 3;
484 return (int)(b | a);
487 public static int test_18_or_imm () {
488 int b = 2;
489 return b | 0x10;
492 public static int test_268435458_or_large_imm () {
493 int b = 2;
494 return b | 0x10000000;
497 public static int test_268435459_or_large_imm2 () {
498 int b = 2;
499 return b | 0x10000001;
502 public static int test_1_xor () {
503 int b = 2;
504 int a = 3;
505 return b ^ a;
508 public static int test_1_xor_imm () {
509 int b = 2;
510 return b ^ 3;
513 public static int test_983041_xor_imm_large () {
514 int b = 2;
515 return b ^ 0xf0003;
518 public static int test_1_neg () {
519 int b = -2;
520 b++;
521 return -b;
524 public static int test_2_not () {
525 int b = ~2;
526 b = ~b;
527 return b;
530 public static int test_16_shift () {
531 int b = 2;
532 int a = 3;
533 return b << a;
536 public static int test_16_shift_add () {
537 int b = 2;
538 int a = 3;
539 int c = 0;
540 return b << (a + c);
543 public static int test_16_shift_add2 () {
544 int b = 2;
545 int a = 3;
546 int c = 0;
547 return (b + c) << a;
550 public static int test_16_shift_imm () {
551 int b = 2;
552 return b << 3;
555 public static int test_524288_shift_imm_large () {
556 int b = 2;
557 return b << 18;
560 public static int test_12_shift_imm_inv () {
561 int b = 2;
562 return 3 << 2;
565 public static int test_12_shift_imm_inv_sbyte () {
566 sbyte b = 2;
567 return 3 << 2;
570 public static int test_1_rshift_imm () {
571 int b = 8;
572 return b >> 3;
575 public static int test_2_unrshift_imm () {
576 uint b = 16;
577 return (int)(b >> 3);
580 public static int test_0_bigunrshift_imm () {
581 unchecked {
582 uint b = (uint)-1;
583 b = b >> 1;
584 if (b != 0x7fffffff)
585 return 1;
586 return 0;
590 public static int test_0_bigrshift_imm () {
591 int b = -1;
592 b = b >> 1;
593 if (b != -1)
594 return 1;
595 return 0;
598 public static int test_1_rshift () {
599 int b = 8;
600 int a = 3;
601 return b >> a;
604 public static int test_2_unrshift () {
605 uint b = 16;
606 int a = 3;
607 return (int)(b >> a);
610 public static int test_0_bigunrshift () {
611 unchecked {
612 uint b = (uint)-1;
613 int a = 1;
614 b = b >> a;
615 if (b != 0x7fffffff)
616 return 1;
617 return 0;
621 public static int test_0_bigrshift () {
622 int b = -1;
623 int a = 1;
624 b = b >> a;
625 if (b != -1)
626 return 1;
627 return 0;
630 public static int test_2_cond () {
631 int b = 2, a = 3, c;
632 if (a == b)
633 return 0;
634 return 2;
637 public static int test_2_cond_short () {
638 short b = 2, a = 3, c;
639 if (a == b)
640 return 0;
641 return 2;
644 public static int test_2_cond_sbyte () {
645 sbyte b = 2, a = 3, c;
646 if (a == b)
647 return 0;
648 return 2;
651 public static int test_6_cascade_cond () {
652 int b = 2, a = 3, c;
653 if (a == b)
654 return 0;
655 else if (b > a)
656 return 1;
657 else if (b != b)
658 return 2;
659 else {
660 c = 1;
662 return a + b + c;
665 public static int test_6_cascade_short () {
666 short b = 2, a = 3, c;
667 if (a == b)
668 return 0;
669 else if (b > a)
670 return 1;
671 else if (b != b)
672 return 2;
673 else {
674 c = 1;
676 return a + b + c;
679 public static int test_0_short_sign_extend () {
680 int t1 = 0xffeedd;
681 short s1 = (short)t1;
682 int t2 = s1;
684 if ((uint)t2 != 0xffffeedd)
685 return 1;
686 else
687 return 0;
690 public static int test_127_iconv_to_i1 () {
691 int i = 0x100017f;
692 sbyte s = (sbyte)i;
694 return s;
697 public static int test_384_iconv_to_i2 () {
698 int i = 0x1000180;
699 short s = (short)i;
701 return s;
704 public static int test_15_for_loop () {
705 int i;
706 for (i = 0; i < 15; ++i) {
708 return i;
711 public static int test_11_nested_for_loop () {
712 int i, j = 0; /* mcs bug here if j not set */
713 for (i = 0; i < 15; ++i) {
714 for (j = 200; j >= 5; --j) ;
716 return i - j;
719 public static int test_11_several_nested_for_loops () {
720 int i, j = 0; /* mcs bug here if j not set */
721 for (i = 0; i < 15; ++i) {
722 for (j = 200; j >= 5; --j) ;
724 i = j = 0;
725 for (i = 0; i < 15; ++i) {
726 for (j = 200; j >= 5; --j) ;
728 return i - j;
731 public static int test_0_conv_ovf_i1 () {
732 int c;
734 //for (int j = 0; j < 10000000; j++)
735 checked {
736 c = 127;
737 sbyte b = (sbyte)c;
738 c = -128;
739 b = (sbyte)c;
742 return 0;
745 public static int test_0_conv_ovf_i1_un () {
746 uint c;
748 checked {
749 c = 127;
750 sbyte b = (sbyte)c;
753 return 0;
756 public static int test_0_conv_ovf_i2 () {
757 int c;
759 checked {
760 c = 32767;
761 Int16 b = (Int16)c;
762 c = -32768;
763 b = (Int16)c;
764 unchecked {
765 uint u = 0xfffffffd;
766 c = (int)u;
768 b = (Int16)c;
771 return 0;
774 public static int test_0_conv_ovf_i2_un () {
775 uint c;
777 checked {
778 c = 32767;
779 Int16 b = (Int16)c;
782 return 0;
785 public static int test_0_conv_ovf_u2 () {
786 int c;
788 checked {
789 c = 65535;
790 UInt16 b = (UInt16)c;
793 return 0;
796 public static int test_0_conv_ovf_u2_un () {
797 uint c;
799 checked {
800 c = 65535;
801 UInt16 b = (UInt16)c;
804 return 0;
807 public static int test_0_conv_ovf_u4 () {
808 int c;
810 checked {
811 c = 0x7fffffff;
812 uint b = (uint)c;
815 return 0;
818 public static int test_0_conv_ovf_i4_un () {
819 uint c;
821 checked {
822 c = 0x7fffffff;
823 int b = (int)c;
826 return 0;
829 public static int test_0_bool () {
830 bool val = true;
831 if (val)
832 return 0;
833 return 1;
836 public static int test_1_bool_inverted () {
837 bool val = true;
838 if (!val)
839 return 0;
840 return 1;
843 public static int test_1_bool_assign () {
844 bool val = true;
845 val = !val; // this should produce a ceq
846 if (val)
847 return 0;
848 return 1;
851 public static int test_1_bool_multi () {
852 bool val = true;
853 bool val2 = true;
854 val = !val;
855 if ((val && !val2) && (!val2 && val))
856 return 0;
857 return 1;
860 public static int test_16_spill () {
861 int a = 1;
862 int b = 2;
863 int c = 3;
864 int d = 4;
865 int e = 5;
867 return (1 + (a + (b + (c + (d + e)))));
870 public static int test_1_switch () {
871 int n = 0;
873 switch (n) {
874 case 0: return 1;
875 case 1: return 2;
876 case -1: return 3;
877 default:
878 return 4;
880 return 1;
883 public static int test_0_switch_constprop () {
884 int n = -1;
886 switch (n) {
887 case 0: return 2;
888 case 1: return 3;
889 case 2: return 3;
890 default:
891 return 0;
893 return 3;
896 public static int test_0_switch_constprop2 () {
897 int n = 3;
899 switch (n) {
900 case 0: return 2;
901 case 1: return 3;
902 case 2: return 3;
903 default:
904 return 0;
906 return 3;
909 public static int test_0_while_loop_1 () {
911 int value = 255;
913 do {
914 value = value >> 4;
915 } while (value != 0);
917 return 0;
920 public static int test_0_while_loop_2 () {
921 int value = 255;
922 int position = 5;
924 do {
925 value = value >> 4;
926 } while (value != 0 && position > 1);
928 return 0;
931 public static int test_0_char_conv () {
932 int i = 1;
934 char tc = (char) ('0' + i);
936 if (tc != '1')
937 return 1;
939 return 0;
942 public static int test_3_shift_regalloc () {
943 int shift = 8;
944 int orig = 1;
945 byte value = 0xfe;
947 orig &= ~(0xff << shift);
948 orig |= value << shift;
950 if (orig == 0xfe01)
951 return 3;
952 return 0;
955 enum E {A, B};
957 public static int test_2_optimize_branches () {
958 switch (E.A) {
959 case E.A:
960 if (E.A == E.B) {
962 break;
964 return 2;
967 public static int test_0_checked_byte_cast () {
968 int v = 250;
969 int b = checked ((byte) (v));
971 if (b != 250)
972 return 1;
973 return 0;
976 public static int test_0_checked_byte_cast_un () {
977 uint v = 250;
978 uint b = checked ((byte) (v));
980 if (b != 250)
981 return 1;
982 return 0;
985 public static int test_0_checked_short_cast () {
986 int v = 250;
987 int b = checked ((ushort) (v));
989 if (b != 250)
990 return 1;
991 return 0;
994 public static int test_0_checked_short_cast_un () {
995 uint v = 250;
996 uint b = checked ((ushort) (v));
998 if (b != 250)
999 return 1;
1000 return 0;
1003 public static int test_1_a_eq_b_plus_a () {
1004 int a = 0, b = 1;
1005 a = b + a;
1006 return a;
1009 public static int test_0_comp () {
1010 int a = 0;
1011 int b = -1;
1012 int error = 1;
1013 bool val;
1015 val = a < b;
1016 if (val)
1017 return error;
1018 error++;
1020 val = a > b;
1021 if (!val)
1022 return error;
1023 error ++;
1025 val = a == b;
1026 if (val)
1027 return error;
1028 error ++;
1030 val = a == a;
1031 if (!val)
1032 return error;
1033 error ++;
1035 return 0;
1038 public static int test_0_comp_unsigned () {
1039 uint a = 1;
1040 uint b = 0xffffffff;
1041 int error = 1;
1042 bool val;
1044 val = a < b;
1045 if (!val)
1046 return error;
1047 error++;
1049 val = a <= b;
1050 if (!val)
1051 return error;
1052 error++;
1054 val = a == b;
1055 if (val)
1056 return error;
1057 error++;
1059 val = a >= b;
1060 if (val)
1061 return error;
1062 error++;
1064 val = a > b;
1065 if (val)
1066 return error;
1067 error++;
1069 val = b < a;
1070 if (val)
1071 return error;
1072 error++;
1074 val = b <= a;
1075 if (val)
1076 return error;
1077 error++;
1079 val = b == a;
1080 if (val)
1081 return error;
1082 error++;
1084 val = b > a;
1085 if (!val)
1086 return error;
1087 error++;
1089 val = b >= a;
1090 if (!val)
1091 return error;
1092 error++;
1094 return 0;
1097 public static int test_16_cmov ()
1099 int n = 0;
1100 if (n == 0)
1101 n = 16;
1103 return n;
1106 public static int test_0_and_cmp ()
1108 /* test esi, imm */
1109 int local = 0x01020304;
1111 if ((local & 0x01020304) == 0)
1112 return 7;
1114 if ((local & 0x00000304) == 0)
1115 return 8;
1117 if ((local & 0x00000004) == 0)
1118 return 9;
1120 if ((local & 0x00000300) == 0)
1121 return 10;
1123 if ((local & 0x00020000) == 0)
1124 return 11;
1126 if ((local & 0x01000000) == 0)
1127 return 12;
1129 return 0;
1132 public static int test_0_mul_imm_opt ()
1134 int i;
1136 i = 1;
1137 if ((i * 2) != 2)
1138 return 1;
1139 i = -1;
1140 if ((i * 2) != -2)
1141 return 2;
1142 i = 1;
1143 if ((i * 3) != 3)
1144 return 3;
1145 i = -1;
1146 if ((i * 3) != -3)
1147 return 4;
1148 i = 1;
1149 if ((i * 5) != 5)
1150 return 5;
1151 i = -1;
1152 if ((i * 5) != -5)
1153 return 6;
1154 i = 1;
1155 if ((i * 6) != 6)
1156 return 7;
1157 i = -1;
1158 if ((i * 6) != -6)
1159 return 8;
1160 i = 1;
1161 if ((i * 9) != 9)
1162 return 9;
1163 i = -1;
1164 if ((i * 9) != -9)
1165 return 10;
1166 i = 1;
1167 if ((i * 10) != 10)
1168 return 11;
1169 i = -1;
1170 if ((i * 10) != -10)
1171 return 12;
1172 i = 1;
1173 if ((i * 12) != 12)
1174 return 13;
1175 i = -1;
1176 if ((i * 12) != -12)
1177 return 14;
1178 i = 1;
1179 if ((i * 25) != 25)
1180 return 15;
1181 i = -1;
1182 if ((i * 25) != -25)
1183 return 16;
1184 i = 1;
1185 if ((i * 100) != 100)
1186 return 17;
1187 i = -1;
1188 if ((i * 100) != -100)
1189 return 18;
1191 return 0;
1194 public static int test_0_cne ()
1196 int x = 0;
1197 int y = 1;
1199 bool b = x != y;
1200 bool bb = x != x;
1202 if (!b)
1203 return 1;
1204 if (bb)
1205 return 2;
1207 return 0;
1210 public static int test_0_cmp_regvar_zero ()
1212 int n = 10;
1214 if (!(n > 0 && n >= 0 && n != 0))
1215 return 1;
1216 if (n < 0 || n <= 0 || n == 0)
1217 return 1;
1219 return 0;
1222 public static int test_5_div_un_cfold ()
1224 uint i = 10;
1225 uint j = 2;
1227 return (int)(i / j);
1230 public static int test_1_rem_un_cfold ()
1232 uint i = 11;
1233 uint j = 2;
1235 return (int)(i % j);
1238 public static int test_0_div_opt () {
1239 int i;
1241 // Avoid cfolding this
1242 i = 0;
1243 for (int j = 0; j < 567; ++j)
1244 i ++;
1245 i += 1234000;
1246 if ((i / 2) != 617283)
1247 return 1;
1248 if ((i / 4) != 308641)
1249 return 2;
1250 if ((i / 8) != 154320)
1251 return 3;
1252 if ((i / 16) != 77160)
1253 return 4;
1255 // Avoid cfolding this
1256 i = 0;
1257 for (int j = 0; j < 567; ++j)
1258 i --;
1259 i -= 1234000;
1260 if ((i / 2) != -617283)
1261 return 5;
1262 if ((i / 4) != -308641)
1263 return 6;
1264 if ((i / 8) != -154320)
1265 return 7;
1266 if ((i / 16) != -77160)
1267 return 8;
1269 return 0;
1272 public static int test_0_rem_opt () {
1273 int i;
1275 // Avoid cfolding this
1276 i = 0;
1277 for (int j = 0; j < 29; ++j)
1278 i ++;
1279 if ((i % 2) != 1)
1280 return 1;
1281 if ((i % 4) != 1)
1282 return 2;
1283 if ((i % 8) != 5)
1284 return 3;
1285 if ((i % 16) != 13)
1286 return 4;
1288 // Avoid cfolding this
1289 i = 0;
1290 for (int j = 0; j < 29; ++j)
1291 i --;
1292 if ((i % 2) != -1)
1293 return 5;
1294 if ((i % 4) != -1)
1295 return 6;
1296 if ((i % 8) != -5)
1297 return 7;
1298 if ((i % 16) != -13)
1299 return 8;
1301 return 0;
1304 public static int cmov (int i) {
1305 int j = 0;
1307 if (i > 0)
1308 j = 1;
1310 return j;
1313 public static int cmov2 (int i) {
1314 int j = 0;
1316 if (i <= 0)
1318 else
1319 j = 1;
1321 return j;
1324 public static int test_0_branch_to_cmov_opt () {
1325 if (cmov (0) != 0)
1326 return 1;
1327 if (cmov (1) != 1)
1328 return 2;
1329 if (cmov2 (0) != 0)
1330 return 1;
1331 if (cmov2 (1) != 1)
1332 return 2;
1333 return 0;
1336 public static unsafe int test_0_ishr_sign_extend () {
1337 // Check that ishr does sign extension from bit 31 on 64 bit platforms
1338 uint val = 0xF0000000u;
1340 uint *a = &val;
1341 uint ui = (uint)((int)(*a) >> 2);
1343 if (ui != 0xfc000000)
1344 return 1;
1346 // Same with non-immediates
1347 int amount = 2;
1349 ui = (uint)((int)(*a) >> amount);
1351 if (ui != 0xfc000000)
1352 return 2;
1354 return 0;
1357 public static unsafe int test_0_ishr_sign_extend_cfold () {
1358 int i = 32768;
1359 int j = i << 16;
1360 int k = j >> 16;
1362 return k == -32768 ? 0 : 1;