Reduce TLS accesses. (#11487)
[mono-project.git] / mono / tests / jit-long.cs
blob48276b2764557747673351911e7d7adcbf0bfb2f
1 using System;
3 public class TestJit {
5 public static long test_call (long a, long b) {
6 return a+b;
9 public static int test_shift_1 ()
11 long a = 9;
12 int b = 1;
14 if ((a >> b) != 4)
15 return 1;
17 if ((a >> 63) != 0)
18 return 1;
20 if ((a << 1) != 18)
21 return 1;
23 if ((a << b) != 18)
24 return 1;
26 a = -9;
27 if ((a >> b) != -5)
28 return 1;
30 return 0;
33 public static int test_shift_2 ()
35 unchecked {
36 long c = (long)0x800000ff00000000;
37 long d = (long)0x8ef0abcd00000000;
38 long t;
39 int sa;
41 t = c>>4;
42 Console.WriteLine (t.ToString ("X"));
43 if (t != (long)0xf800000ff0000000)
44 return 1;
46 if ((t << 4) != c)
47 return 1;
49 t = d>>40;
50 Console.WriteLine (t.ToString ("X"));
51 if (t != (long)0xffffffffff8ef0ab)
52 return 1;
54 if ((t << 40) != (long)0x8ef0ab0000000000)
55 return 1;
60 return 0;
63 public static int test_shift_3 ()
65 checked {
66 ulong c = 0x800000ff00000000;
67 ulong d = 0x8ef0abcd00000000;
68 ulong t;
70 t = c >> 4;
71 Console.WriteLine (t.ToString ("X"));
72 if (t != 0x0800000ff0000000)
73 return 1;
75 if ((t << 4) != c)
76 return 1;
78 t = d >> 40;
79 Console.WriteLine (t.ToString ("X"));
80 if (t != 0x8ef0ab)
81 return 1;
83 if ((t << 40) != 0x8ef0ab0000000000)
84 return 1;
87 return 0;
90 public static int test_alu ()
92 long a = 9, b = 6;
94 if ((a + b) != 15)
95 return 1;
97 if ((a - b) != 3)
98 return 1;
100 if ((a & 8) != 8)
101 return 1;
103 if ((a | 2) != 11)
104 return 1;
106 if ((a * b) != 54)
107 return 1;
109 if ((a / 4) != 2)
110 return 1;
112 if ((a % 4) != 1)
113 return 1;
115 if (-a != -9)
116 return 1;
118 b = -1;
119 if (~b != 0)
120 return 1;
122 return 0;
125 public static int test_branch ()
127 long a = 5, b = 5, t;
129 if (a == b) t = 1; else t = 0;
130 if (t != 1) return 1;
132 if (a != b) t = 0; else t = 1;
133 if (t != 1) return 1;
135 if (a >= b) t = 1; else t = 0;
136 if (t != 1) return 1;
138 if (a > b) t = 0; else t = 1;
139 if (t != 1) return 1;
141 if (a <= b) t = 1; else t = 0;
142 if (t != 1) return 1;
144 if (a < b) t = 0; else t = 1;
145 if (t != 1) return 1;
147 return 0;
150 public static int Main() {
151 int num = 0;
153 num++;
154 if (test_shift_1 () != 0)
155 return num;
156 num++;
157 if (test_shift_2 () != 0)
158 return num;
159 num++;
160 if (test_shift_3 () != 0)
161 return num;
163 num++;
164 if (test_call (3, 5) != 8)
165 return num;
167 num++;
168 if (test_branch () != 0)
169 return num;
171 num++;
172 if (test_alu () != 0)
173 return num;
175 return 0;