2009-03-11 Zoltan Varga <vargaz@gmail.com>
[mono-debugger.git] / mono / mini / basic.cs
blob74d1ede1fad72f11ac21e1b961f698dae738bf77
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_4_rem_big_imm () {
199 int b = 10004;
200 return b % 10000;
203 public static int test_9_mul () {
204 int b = 3;
205 int a = 3;
206 return b * a;
209 public static int test_15_mul_imm () {
210 int b = 3;
211 return b * 5;
214 public static int test_24_mul () {
215 int a = 3;
216 int b = 8;
217 int res;
219 res = a * b;
221 return res;
224 public static int test_24_mul_ovf () {
225 int a = 3;
226 int b = 8;
227 int res;
229 checked {
230 res = a * b;
233 return res;
236 public static int test_24_mul_un () {
237 uint a = 3;
238 uint b = 8;
239 uint res;
241 res = a * b;
243 return (int)res;
246 public static int test_24_mul_ovf_un () {
247 uint a = 3;
248 uint b = 8;
249 uint res;
251 checked {
252 res = a * b;
255 return (int)res;
258 public static int test_0_add_ovf1 () {
259 int i, j, k;
261 checked {
262 i = System.Int32.MinValue;
263 j = 0;
264 k = i + j;
267 if (k != System.Int32.MinValue)
268 return 1;
269 return 0;
272 public static int test_0_add_ovf2 () {
273 int i, j, k;
275 checked {
276 i = System.Int32.MaxValue;
277 j = 0;
278 k = i + j;
281 if (k != System.Int32.MaxValue)
282 return 2;
283 return 0;
286 public static int test_0_add_ovf3 () {
287 int i, j, k;
289 checked {
290 i = System.Int32.MinValue;
291 j = System.Int32.MaxValue;
292 k = i + j;
295 if (k != -1)
296 return 3;
297 return 0;
300 public static int test_0_add_ovf4 () {
301 int i, j, k;
303 checked {
304 i = System.Int32.MaxValue;
305 j = System.Int32.MinValue;
306 k = i + j;
309 if (k != -1)
310 return 4;
311 return 0;
314 public static int test_0_add_ovf5 () {
315 int i, j, k;
317 checked {
318 i = System.Int32.MinValue + 1234;
319 j = -1234;
320 k = i + j;
323 if (k != System.Int32.MinValue)
324 return 5;
325 return 0;
328 public static int test_0_add_ovf6 () {
329 int i, j, k;
331 checked {
332 i = System.Int32.MaxValue - 1234;
333 j = 1234;
334 k = i + j;
337 if (k != System.Int32.MaxValue)
338 return 6;
340 return 0;
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 () {
351 int i, j, k;
353 checked {
354 i = System.Int32.MinValue;
355 j = 0;
356 k = i - j;
359 if (k != System.Int32.MinValue)
360 return 1;
362 return 0;
365 public static int test_0_sub_ovf2 () {
366 int i, j, k;
368 checked {
369 i = System.Int32.MaxValue;
370 j = 0;
371 k = i - j;
374 if (k != System.Int32.MaxValue)
375 return 2;
377 return 0;
380 public static int test_0_sub_ovf3 () {
381 int i, j, k;
383 checked {
384 i = System.Int32.MinValue;
385 j = System.Int32.MinValue + 1234;
386 k = i - j;
389 if (k != -1234)
390 return 3;
392 return 0;
395 public static int test_0_sub_ovf4 () {
396 int i, j, k;
398 checked {
399 i = System.Int32.MaxValue;
400 j = 1234;
401 k = i - j;
404 if (k != System.Int32.MaxValue - 1234)
405 return 4;
407 return 0;
410 public static int test_0_sub_ovf5 () {
411 int i, j, k;
413 checked {
414 i = System.Int32.MaxValue - 1234;
415 j = -1234;
416 k = i - j;
419 if (k != System.Int32.MaxValue)
420 return 5;
422 return 0;
425 public static int test_0_sub_ovf6 () {
426 int i, j, k;
428 checked {
429 i = System.Int32.MinValue + 1234;
430 j = 1234;
431 k = i - j;
434 if (k != System.Int32.MinValue)
435 return 6;
437 return 0;
440 public static int test_0_sub_ovf_un () {
441 uint i, j, k;
443 checked {
444 i = System.UInt32.MaxValue;
445 j = 0;
446 k = i - j;
449 if (k != System.UInt32.MaxValue)
450 return 1;
452 checked {
453 i = System.UInt32.MaxValue;
454 j = System.UInt32.MaxValue;
455 k = i - j;
458 if (k != 0)
459 return 2;
461 return 0;
464 public static int test_3_or () {
465 int b = 2;
466 int a = 3;
467 return b | a;
470 public static int test_3_or_un () {
471 uint b = 2;
472 uint a = 3;
473 return (int)(b | a);
476 public static int test_3_or_short_un () {
477 ushort b = 2;
478 ushort a = 3;
479 return (int)(b | a);
482 public static int test_18_or_imm () {
483 int b = 2;
484 return b | 0x10;
487 public static int test_268435458_or_large_imm () {
488 int b = 2;
489 return b | 0x10000000;
492 public static int test_268435459_or_large_imm2 () {
493 int b = 2;
494 return b | 0x10000001;
497 public static int test_1_xor () {
498 int b = 2;
499 int a = 3;
500 return b ^ a;
503 public static int test_1_xor_imm () {
504 int b = 2;
505 return b ^ 3;
508 public static int test_983041_xor_imm_large () {
509 int b = 2;
510 return b ^ 0xf0003;
513 public static int test_1_neg () {
514 int b = -2;
515 b++;
516 return -b;
519 public static int test_2_not () {
520 int b = ~2;
521 b = ~b;
522 return b;
525 public static int test_16_shift () {
526 int b = 2;
527 int a = 3;
528 return b << a;
531 public static int test_16_shift_add () {
532 int b = 2;
533 int a = 3;
534 int c = 0;
535 return b << (a + c);
538 public static int test_16_shift_add2 () {
539 int b = 2;
540 int a = 3;
541 int c = 0;
542 return (b + c) << a;
545 public static int test_16_shift_imm () {
546 int b = 2;
547 return b << 3;
550 public static int test_524288_shift_imm_large () {
551 int b = 2;
552 return b << 18;
555 public static int test_12_shift_imm_inv () {
556 int b = 2;
557 return 3 << 2;
560 public static int test_12_shift_imm_inv_sbyte () {
561 sbyte b = 2;
562 return 3 << 2;
565 public static int test_1_rshift_imm () {
566 int b = 8;
567 return b >> 3;
570 public static int test_2_unrshift_imm () {
571 uint b = 16;
572 return (int)(b >> 3);
575 public static int test_0_bigunrshift_imm () {
576 unchecked {
577 uint b = (uint)-1;
578 b = b >> 1;
579 if (b != 0x7fffffff)
580 return 1;
581 return 0;
585 public static int test_0_bigrshift_imm () {
586 int b = -1;
587 b = b >> 1;
588 if (b != -1)
589 return 1;
590 return 0;
593 public static int test_1_rshift () {
594 int b = 8;
595 int a = 3;
596 return b >> a;
599 public static int test_2_unrshift () {
600 uint b = 16;
601 int a = 3;
602 return (int)(b >> a);
605 public static int test_0_bigunrshift () {
606 unchecked {
607 uint b = (uint)-1;
608 int a = 1;
609 b = b >> a;
610 if (b != 0x7fffffff)
611 return 1;
612 return 0;
616 public static int test_0_bigrshift () {
617 int b = -1;
618 int a = 1;
619 b = b >> a;
620 if (b != -1)
621 return 1;
622 return 0;
625 public static int test_2_cond () {
626 int b = 2, a = 3, c;
627 if (a == b)
628 return 0;
629 return 2;
632 public static int test_2_cond_short () {
633 short b = 2, a = 3, c;
634 if (a == b)
635 return 0;
636 return 2;
639 public static int test_2_cond_sbyte () {
640 sbyte b = 2, a = 3, c;
641 if (a == b)
642 return 0;
643 return 2;
646 public static int test_6_cascade_cond () {
647 int b = 2, a = 3, c;
648 if (a == b)
649 return 0;
650 else if (b > a)
651 return 1;
652 else if (b != b)
653 return 2;
654 else {
655 c = 1;
657 return a + b + c;
660 public static int test_6_cascade_short () {
661 short b = 2, a = 3, c;
662 if (a == b)
663 return 0;
664 else if (b > a)
665 return 1;
666 else if (b != b)
667 return 2;
668 else {
669 c = 1;
671 return a + b + c;
674 public static int test_0_short_sign_extend () {
675 int t1 = 0xffeedd;
676 short s1 = (short)t1;
677 int t2 = s1;
679 if ((uint)t2 != 0xffffeedd)
680 return 1;
681 else
682 return 0;
685 public static int test_127_iconv_to_i1 () {
686 int i = 0x100017f;
687 sbyte s = (sbyte)i;
689 return s;
692 public static int test_384_iconv_to_i2 () {
693 int i = 0x1000180;
694 short s = (short)i;
696 return s;
699 public static int test_15_for_loop () {
700 int i;
701 for (i = 0; i < 15; ++i) {
703 return 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) ;
711 return i - 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) ;
719 i = j = 0;
720 for (i = 0; i < 15; ++i) {
721 for (j = 200; j >= 5; --j) ;
723 return i - j;
726 public static int test_0_conv_ovf_i1 () {
727 int c;
729 //for (int j = 0; j < 10000000; j++)
730 checked {
731 c = 127;
732 sbyte b = (sbyte)c;
733 c = -128;
734 b = (sbyte)c;
737 return 0;
740 public static int test_0_conv_ovf_i1_un () {
741 uint c;
743 checked {
744 c = 127;
745 sbyte b = (sbyte)c;
748 return 0;
751 public static int test_0_conv_ovf_i2 () {
752 int c;
754 checked {
755 c = 32767;
756 Int16 b = (Int16)c;
757 c = -32768;
758 b = (Int16)c;
759 unchecked {
760 uint u = 0xfffffffd;
761 c = (int)u;
763 b = (Int16)c;
766 return 0;
769 public static int test_0_conv_ovf_i2_un () {
770 uint c;
772 checked {
773 c = 32767;
774 Int16 b = (Int16)c;
777 return 0;
780 public static int test_0_conv_ovf_u2 () {
781 int c;
783 checked {
784 c = 65535;
785 UInt16 b = (UInt16)c;
788 return 0;
791 public static int test_0_conv_ovf_u2_un () {
792 uint c;
794 checked {
795 c = 65535;
796 UInt16 b = (UInt16)c;
799 return 0;
802 public static int test_0_conv_ovf_u4 () {
803 int c;
805 checked {
806 c = 0x7fffffff;
807 uint b = (uint)c;
810 return 0;
813 public static int test_0_conv_ovf_i4_un () {
814 uint c;
816 checked {
817 c = 0x7fffffff;
818 int b = (int)c;
821 return 0;
824 public static int test_0_bool () {
825 bool val = true;
826 if (val)
827 return 0;
828 return 1;
831 public static int test_1_bool_inverted () {
832 bool val = true;
833 if (!val)
834 return 0;
835 return 1;
838 public static int test_1_bool_assign () {
839 bool val = true;
840 val = !val; // this should produce a ceq
841 if (val)
842 return 0;
843 return 1;
846 public static int test_1_bool_multi () {
847 bool val = true;
848 bool val2 = true;
849 val = !val;
850 if ((val && !val2) && (!val2 && val))
851 return 0;
852 return 1;
855 public static int test_16_spill () {
856 int a = 1;
857 int b = 2;
858 int c = 3;
859 int d = 4;
860 int e = 5;
862 return (1 + (a + (b + (c + (d + e)))));
865 public static int test_1_switch () {
866 int n = 0;
868 switch (n) {
869 case 0: return 1;
870 case 1: return 2;
871 case -1: return 3;
872 default:
873 return 4;
875 return 1;
878 public static int test_0_switch_constprop () {
879 int n = -1;
881 switch (n) {
882 case 0: return 2;
883 case 1: return 3;
884 case 2: return 3;
885 default:
886 return 0;
888 return 3;
891 public static int test_0_switch_constprop2 () {
892 int n = 3;
894 switch (n) {
895 case 0: return 2;
896 case 1: return 3;
897 case 2: return 3;
898 default:
899 return 0;
901 return 3;
904 public static int test_0_while_loop_1 () {
906 int value = 255;
908 do {
909 value = value >> 4;
910 } while (value != 0);
912 return 0;
915 public static int test_0_while_loop_2 () {
916 int value = 255;
917 int position = 5;
919 do {
920 value = value >> 4;
921 } while (value != 0 && position > 1);
923 return 0;
926 public static int test_0_char_conv () {
927 int i = 1;
929 char tc = (char) ('0' + i);
931 if (tc != '1')
932 return 1;
934 return 0;
937 public static int test_3_shift_regalloc () {
938 int shift = 8;
939 int orig = 1;
940 byte value = 0xfe;
942 orig &= ~(0xff << shift);
943 orig |= value << shift;
945 if (orig == 0xfe01)
946 return 3;
947 return 0;
950 enum E {A, B};
952 public static int test_2_optimize_branches () {
953 switch (E.A) {
954 case E.A:
955 if (E.A == E.B) {
957 break;
959 return 2;
962 public static int test_0_checked_byte_cast () {
963 int v = 250;
964 int b = checked ((byte) (v));
966 if (b != 250)
967 return 1;
968 return 0;
971 public static int test_0_checked_byte_cast_un () {
972 uint v = 250;
973 uint b = checked ((byte) (v));
975 if (b != 250)
976 return 1;
977 return 0;
980 public static int test_0_checked_short_cast () {
981 int v = 250;
982 int b = checked ((ushort) (v));
984 if (b != 250)
985 return 1;
986 return 0;
989 public static int test_0_checked_short_cast_un () {
990 uint v = 250;
991 uint b = checked ((ushort) (v));
993 if (b != 250)
994 return 1;
995 return 0;
998 public static int test_1_a_eq_b_plus_a () {
999 int a = 0, b = 1;
1000 a = b + a;
1001 return a;
1004 public static int test_0_comp () {
1005 int a = 0;
1006 int b = -1;
1007 int error = 1;
1008 bool val;
1010 val = a < b;
1011 if (val)
1012 return error;
1013 error++;
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 == a;
1026 if (!val)
1027 return error;
1028 error ++;
1030 return 0;
1033 public static int test_0_comp_unsigned () {
1034 uint a = 1;
1035 uint b = 0xffffffff;
1036 int error = 1;
1037 bool val;
1039 val = a < b;
1040 if (!val)
1041 return error;
1042 error++;
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 = b < a;
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 return 0;
1092 public static int test_16_cmov ()
1094 int n = 0;
1095 if (n == 0)
1096 n = 16;
1098 return n;
1101 public static int test_0_and_cmp ()
1103 /* test esi, imm */
1104 int local = 0x01020304;
1106 if ((local & 0x01020304) == 0)
1107 return 7;
1109 if ((local & 0x00000304) == 0)
1110 return 8;
1112 if ((local & 0x00000004) == 0)
1113 return 9;
1115 if ((local & 0x00000300) == 0)
1116 return 10;
1118 if ((local & 0x00020000) == 0)
1119 return 11;
1121 if ((local & 0x01000000) == 0)
1122 return 12;
1124 return 0;
1127 public static int test_0_mul_imm_opt ()
1129 int i;
1131 i = 1;
1132 if ((i * 2) != 2)
1133 return 1;
1134 i = -1;
1135 if ((i * 2) != -2)
1136 return 2;
1137 i = 1;
1138 if ((i * 3) != 3)
1139 return 3;
1140 i = -1;
1141 if ((i * 3) != -3)
1142 return 4;
1143 i = 1;
1144 if ((i * 5) != 5)
1145 return 5;
1146 i = -1;
1147 if ((i * 5) != -5)
1148 return 6;
1149 i = 1;
1150 if ((i * 6) != 6)
1151 return 7;
1152 i = -1;
1153 if ((i * 6) != -6)
1154 return 8;
1155 i = 1;
1156 if ((i * 9) != 9)
1157 return 9;
1158 i = -1;
1159 if ((i * 9) != -9)
1160 return 10;
1161 i = 1;
1162 if ((i * 10) != 10)
1163 return 11;
1164 i = -1;
1165 if ((i * 10) != -10)
1166 return 12;
1167 i = 1;
1168 if ((i * 12) != 12)
1169 return 13;
1170 i = -1;
1171 if ((i * 12) != -12)
1172 return 14;
1173 i = 1;
1174 if ((i * 25) != 25)
1175 return 15;
1176 i = -1;
1177 if ((i * 25) != -25)
1178 return 16;
1179 i = 1;
1180 if ((i * 100) != 100)
1181 return 17;
1182 i = -1;
1183 if ((i * 100) != -100)
1184 return 18;
1186 return 0;
1189 public static int test_0_cne ()
1191 int x = 0;
1192 int y = 1;
1194 bool b = x != y;
1195 bool bb = x != x;
1197 if (!b)
1198 return 1;
1199 if (bb)
1200 return 2;
1202 return 0;
1205 public static int test_0_cmp_regvar_zero ()
1207 int n = 10;
1209 if (!(n > 0 && n >= 0 && n != 0))
1210 return 1;
1211 if (n < 0 || n <= 0 || n == 0)
1212 return 1;
1214 return 0;
1217 public static int test_5_div_un_cfold ()
1219 uint i = 10;
1220 uint j = 2;
1222 return (int)(i / j);
1225 public static int test_1_rem_un_cfold ()
1227 uint i = 11;
1228 uint j = 2;
1230 return (int)(i % j);
1233 public static int test_0_div_opt () {
1234 int i;
1236 // Avoid cfolding this
1237 i = 0;
1238 for (int j = 0; j < 1234567; ++j)
1239 i ++;
1240 if ((i / 2) != 617283)
1241 return 1;
1242 if ((i / 4) != 308641)
1243 return 2;
1244 if ((i / 8) != 154320)
1245 return 3;
1246 if ((i / 16) != 77160)
1247 return 4;
1249 // Avoid cfolding this
1250 i = 0;
1251 for (int j = 0; j < 1234567; ++j)
1252 i --;
1253 if ((i / 2) != -617283)
1254 return 5;
1255 if ((i / 4) != -308641)
1256 return 6;
1257 if ((i / 8) != -154320)
1258 return 7;
1259 if ((i / 16) != -77160)
1260 return 8;
1262 return 0;
1265 public static int test_0_rem_opt () {
1266 int i;
1268 // Avoid cfolding this
1269 i = 0;
1270 for (int j = 0; j < 29; ++j)
1271 i ++;
1272 if ((i % 2) != 1)
1273 return 1;
1274 if ((i % 4) != 1)
1275 return 2;
1276 if ((i % 8) != 5)
1277 return 3;
1278 if ((i % 16) != 13)
1279 return 4;
1281 // Avoid cfolding this
1282 i = 0;
1283 for (int j = 0; j < 29; ++j)
1284 i --;
1285 if ((i % 2) != -1)
1286 return 5;
1287 if ((i % 4) != -1)
1288 return 6;
1289 if ((i % 8) != -5)
1290 return 7;
1291 if ((i % 16) != -13)
1292 return 8;
1294 return 0;
1297 public static int cmov (int i) {
1298 int j = 0;
1300 if (i > 0)
1301 j = 1;
1303 return j;
1306 public static int cmov2 (int i) {
1307 int j = 0;
1309 if (i <= 0)
1311 else
1312 j = 1;
1314 return j;
1317 public static int test_0_branch_to_cmov_opt () {
1318 if (cmov (0) != 0)
1319 return 1;
1320 if (cmov (1) != 1)
1321 return 2;
1322 if (cmov2 (0) != 0)
1323 return 1;
1324 if (cmov2 (1) != 1)
1325 return 2;
1326 return 0;