blob: 5479818ae77d7504303467fa258bce20424105a5 [file] [log] [blame]
David Brazdilee690a32014-12-01 17:04:16 +00001/*
Roland Levillain6a92a032015-07-23 12:15:01 +01002 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
David Brazdilee690a32014-12-01 17:04:16 +000016
David Brazdil4846d132015-01-15 19:07:08 +000017public class Main {
David Brazdilee690a32014-12-01 17:04:16 +000018
Roland Levillain3b55ebb2015-05-08 13:13:19 +010019 public static void assertFalse(boolean condition) {
20 if (condition) {
21 throw new Error();
22 }
23 }
24
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +000025 public static void assertIntEquals(int expected, int result) {
26 if (expected != result) {
27 throw new Error("Expected: " + expected + ", found: " + result);
28 }
29 }
30
31 public static void assertLongEquals(long expected, long result) {
32 if (expected != result) {
33 throw new Error("Expected: " + expected + ", found: " + result);
34 }
35 }
36
Mark Mendelle82549b2015-05-06 10:55:34 -040037 public static void assertFloatEquals(float expected, float result) {
38 if (expected != result) {
39 throw new Error("Expected: " + expected + ", found: " + result);
40 }
41 }
42
43 public static void assertDoubleEquals(double expected, double result) {
44 if (expected != result) {
45 throw new Error("Expected: " + expected + ", found: " + result);
46 }
47 }
48
Roland Levillainb65eb502015-07-23 12:11:42 +010049
David Brazdilee690a32014-12-01 17:04:16 +000050 /**
Roland Levillainb65eb502015-07-23 12:11:42 +010051 * Exercise constant folding on negation.
David Brazdilee690a32014-12-01 17:04:16 +000052 */
53
David Brazdila06d66a2015-05-28 11:14:54 +010054 /// CHECK-START: int Main.IntNegation() constant_folding (before)
55 /// CHECK-DAG: <<Const42:i\d+>> IntConstant 42
56 /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Const42>>]
57 /// CHECK-DAG: Return [<<Neg>>]
David Brazdilee690a32014-12-01 17:04:16 +000058
David Brazdila06d66a2015-05-28 11:14:54 +010059 /// CHECK-START: int Main.IntNegation() constant_folding (after)
60 /// CHECK-DAG: <<ConstN42:i\d+>> IntConstant -42
61 /// CHECK-DAG: Return [<<ConstN42>>]
David Brazdilee690a32014-12-01 17:04:16 +000062
Roland Levillainb65eb502015-07-23 12:11:42 +010063 /// CHECK-START: int Main.IntNegation() constant_folding (after)
64 /// CHECK-NOT: Neg
65
David Brazdilee690a32014-12-01 17:04:16 +000066 public static int IntNegation() {
67 int x, y;
68 x = 42;
69 y = -x;
70 return y;
71 }
72
Roland Levillainc90bc7c2014-12-11 12:14:33 +000073 /// CHECK-START: long Main.LongNegation() constant_folding (before)
74 /// CHECK-DAG: <<Const42:j\d+>> LongConstant 42
75 /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Const42>>]
76 /// CHECK-DAG: Return [<<Neg>>]
77
78 /// CHECK-START: long Main.LongNegation() constant_folding (after)
79 /// CHECK-DAG: <<ConstN42:j\d+>> LongConstant -42
80 /// CHECK-DAG: Return [<<ConstN42>>]
81
82 /// CHECK-START: long Main.LongNegation() constant_folding (after)
83 /// CHECK-NOT: Neg
84
85 public static long LongNegation() {
86 long x, y;
87 x = 42L;
88 y = -x;
89 return y;
90 }
91
Roland Levillainb65eb502015-07-23 12:11:42 +010092
David Brazdilee690a32014-12-01 17:04:16 +000093 /**
Roland Levillainb65eb502015-07-23 12:11:42 +010094 * Exercise constant folding on addition.
David Brazdilee690a32014-12-01 17:04:16 +000095 */
96
David Brazdila06d66a2015-05-28 11:14:54 +010097 /// CHECK-START: int Main.IntAddition1() constant_folding (before)
98 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
99 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
100 /// CHECK-DAG: <<Add:i\d+>> Add [<<Const1>>,<<Const2>>]
101 /// CHECK-DAG: Return [<<Add>>]
David Brazdilee690a32014-12-01 17:04:16 +0000102
David Brazdila06d66a2015-05-28 11:14:54 +0100103 /// CHECK-START: int Main.IntAddition1() constant_folding (after)
104 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3
105 /// CHECK-DAG: Return [<<Const3>>]
David Brazdilee690a32014-12-01 17:04:16 +0000106
Roland Levillainb65eb502015-07-23 12:11:42 +0100107 /// CHECK-START: int Main.IntAddition1() constant_folding (after)
108 /// CHECK-NOT: Add
109
David Brazdilee690a32014-12-01 17:04:16 +0000110 public static int IntAddition1() {
111 int a, b, c;
112 a = 1;
113 b = 2;
114 c = a + b;
115 return c;
116 }
117
David Brazdila06d66a2015-05-28 11:14:54 +0100118 /// CHECK-START: int Main.IntAddition2() constant_folding (before)
119 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
120 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
121 /// CHECK-DAG: <<Const5:i\d+>> IntConstant 5
122 /// CHECK-DAG: <<Const6:i\d+>> IntConstant 6
David Brazdil57e863c2016-01-11 10:27:13 +0000123 /// CHECK-DAG: <<Const11:i\d+>> IntConstant 11
David Brazdila06d66a2015-05-28 11:14:54 +0100124 /// CHECK-DAG: <<Add1:i\d+>> Add [<<Const1>>,<<Const2>>]
David Brazdil57e863c2016-01-11 10:27:13 +0000125 /// CHECK-DAG: Add [<<Const5>>,<<Const6>>]
126 /// CHECK-DAG: <<Add3:i\d+>> Add [<<Add1>>,<<Const11>>]
David Brazdila06d66a2015-05-28 11:14:54 +0100127 /// CHECK-DAG: Return [<<Add3>>]
David Brazdilee690a32014-12-01 17:04:16 +0000128
David Brazdila06d66a2015-05-28 11:14:54 +0100129 /// CHECK-START: int Main.IntAddition2() constant_folding (after)
130 /// CHECK-DAG: <<Const14:i\d+>> IntConstant 14
131 /// CHECK-DAG: Return [<<Const14>>]
David Brazdilee690a32014-12-01 17:04:16 +0000132
Roland Levillainb65eb502015-07-23 12:11:42 +0100133 /// CHECK-START: int Main.IntAddition2() constant_folding (after)
134 /// CHECK-NOT: Add
135
David Brazdilee690a32014-12-01 17:04:16 +0000136 public static int IntAddition2() {
137 int a, b, c;
138 a = 1;
139 b = 2;
140 a += b;
141 b = 5;
142 c = 6;
143 b += c;
144 c = a + b;
145 return c;
146 }
147
Roland Levillainb65eb502015-07-23 12:11:42 +0100148 /// CHECK-START: long Main.LongAddition() constant_folding (before)
149 /// CHECK-DAG: <<Const1:j\d+>> LongConstant 1
150 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2
151 /// CHECK-DAG: <<Add:j\d+>> Add [<<Const1>>,<<Const2>>]
152 /// CHECK-DAG: Return [<<Add>>]
153
154 /// CHECK-START: long Main.LongAddition() constant_folding (after)
155 /// CHECK-DAG: <<Const3:j\d+>> LongConstant 3
156 /// CHECK-DAG: Return [<<Const3>>]
157
158 /// CHECK-START: long Main.LongAddition() constant_folding (after)
159 /// CHECK-NOT: Add
160
161 public static long LongAddition() {
162 long a, b, c;
163 a = 1L;
164 b = 2L;
165 c = a + b;
166 return c;
167 }
168
169
David Brazdilee690a32014-12-01 17:04:16 +0000170 /**
Roland Levillainb65eb502015-07-23 12:11:42 +0100171 * Exercise constant folding on subtraction.
David Brazdilee690a32014-12-01 17:04:16 +0000172 */
173
David Brazdila06d66a2015-05-28 11:14:54 +0100174 /// CHECK-START: int Main.IntSubtraction() constant_folding (before)
175 /// CHECK-DAG: <<Const6:i\d+>> IntConstant 6
176 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
177 /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Const6>>,<<Const2>>]
178 /// CHECK-DAG: Return [<<Sub>>]
David Brazdilee690a32014-12-01 17:04:16 +0000179
David Brazdila06d66a2015-05-28 11:14:54 +0100180 /// CHECK-START: int Main.IntSubtraction() constant_folding (after)
181 /// CHECK-DAG: <<Const4:i\d+>> IntConstant 4
182 /// CHECK-DAG: Return [<<Const4>>]
David Brazdilee690a32014-12-01 17:04:16 +0000183
Roland Levillainb65eb502015-07-23 12:11:42 +0100184 /// CHECK-START: int Main.IntSubtraction() constant_folding (after)
185 /// CHECK-NOT: Sub
186
David Brazdilee690a32014-12-01 17:04:16 +0000187 public static int IntSubtraction() {
188 int a, b, c;
David Brazdil4846d132015-01-15 19:07:08 +0000189 a = 6;
David Brazdilee690a32014-12-01 17:04:16 +0000190 b = 2;
191 c = a - b;
192 return c;
193 }
194
David Brazdila06d66a2015-05-28 11:14:54 +0100195 /// CHECK-START: long Main.LongSubtraction() constant_folding (before)
196 /// CHECK-DAG: <<Const6:j\d+>> LongConstant 6
197 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2
198 /// CHECK-DAG: <<Sub:j\d+>> Sub [<<Const6>>,<<Const2>>]
199 /// CHECK-DAG: Return [<<Sub>>]
David Brazdilee690a32014-12-01 17:04:16 +0000200
David Brazdila06d66a2015-05-28 11:14:54 +0100201 /// CHECK-START: long Main.LongSubtraction() constant_folding (after)
202 /// CHECK-DAG: <<Const4:j\d+>> LongConstant 4
203 /// CHECK-DAG: Return [<<Const4>>]
David Brazdilee690a32014-12-01 17:04:16 +0000204
Roland Levillainb65eb502015-07-23 12:11:42 +0100205 /// CHECK-START: long Main.LongSubtraction() constant_folding (after)
206 /// CHECK-NOT: Sub
207
David Brazdilee690a32014-12-01 17:04:16 +0000208 public static long LongSubtraction() {
209 long a, b, c;
David Brazdil4846d132015-01-15 19:07:08 +0000210 a = 6L;
David Brazdilee690a32014-12-01 17:04:16 +0000211 b = 2L;
212 c = a - b;
213 return c;
214 }
215
Roland Levillainb65eb502015-07-23 12:11:42 +0100216
David Brazdilee690a32014-12-01 17:04:16 +0000217 /**
Roland Levillainf7746ad2015-07-22 14:12:01 +0100218 * Exercise constant folding on multiplication.
219 */
220
221 /// CHECK-START: int Main.IntMultiplication() constant_folding (before)
222 /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7
223 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3
224 /// CHECK-DAG: <<Mul:i\d+>> Mul [<<Const7>>,<<Const3>>]
225 /// CHECK-DAG: Return [<<Mul>>]
226
227 /// CHECK-START: int Main.IntMultiplication() constant_folding (after)
228 /// CHECK-DAG: <<Const21:i\d+>> IntConstant 21
229 /// CHECK-DAG: Return [<<Const21>>]
230
231 /// CHECK-START: int Main.IntMultiplication() constant_folding (after)
232 /// CHECK-NOT: Mul
233
234 public static int IntMultiplication() {
235 int a, b, c;
236 a = 7;
237 b = 3;
238 c = a * b;
239 return c;
240 }
241
242 /// CHECK-START: long Main.LongMultiplication() constant_folding (before)
243 /// CHECK-DAG: <<Const7:j\d+>> LongConstant 7
244 /// CHECK-DAG: <<Const3:j\d+>> LongConstant 3
245 /// CHECK-DAG: <<Mul:j\d+>> Mul [<<Const7>>,<<Const3>>]
246 /// CHECK-DAG: Return [<<Mul>>]
247
248 /// CHECK-START: long Main.LongMultiplication() constant_folding (after)
249 /// CHECK-DAG: <<Const21:j\d+>> LongConstant 21
250 /// CHECK-DAG: Return [<<Const21>>]
251
252 /// CHECK-START: long Main.LongMultiplication() constant_folding (after)
253 /// CHECK-NOT: Mul
254
255 public static long LongMultiplication() {
256 long a, b, c;
257 a = 7L;
258 b = 3L;
259 c = a * b;
260 return c;
261 }
262
263
264 /**
265 * Exercise constant folding on division.
266 */
267
268 /// CHECK-START: int Main.IntDivision() constant_folding (before)
269 /// CHECK-DAG: <<Const8:i\d+>> IntConstant 8
270 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3
271 /// CHECK-DAG: <<Div0Chk:i\d+>> DivZeroCheck [<<Const3>>]
272 /// CHECK-DAG: <<Div:i\d+>> Div [<<Const8>>,<<Div0Chk>>]
273 /// CHECK-DAG: Return [<<Div>>]
274
275 /// CHECK-START: int Main.IntDivision() constant_folding (after)
276 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
277 /// CHECK-DAG: Return [<<Const2>>]
278
279 /// CHECK-START: int Main.IntDivision() constant_folding (after)
280 /// CHECK-NOT: DivZeroCheck
281 /// CHECK-NOT: Div
282
283 public static int IntDivision() {
284 int a, b, c;
285 a = 8;
286 b = 3;
287 c = a / b;
288 return c;
289 }
290
291 /// CHECK-START: long Main.LongDivision() constant_folding (before)
292 /// CHECK-DAG: <<Const8:j\d+>> LongConstant 8
293 /// CHECK-DAG: <<Const3:j\d+>> LongConstant 3
294 /// CHECK-DAG: <<Div0Chk:j\d+>> DivZeroCheck [<<Const3>>]
295 /// CHECK-DAG: <<Div:j\d+>> Div [<<Const8>>,<<Div0Chk>>]
296 /// CHECK-DAG: Return [<<Div>>]
297
298 /// CHECK-START: long Main.LongDivision() constant_folding (after)
299 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2
300 /// CHECK-DAG: Return [<<Const2>>]
301
302 /// CHECK-START: long Main.LongDivision() constant_folding (after)
303 /// CHECK-NOT: DivZeroCheck
304 /// CHECK-NOT: Div
305
306 public static long LongDivision() {
307 long a, b, c;
308 a = 8L;
309 b = 3L;
310 c = a / b;
311 return c;
312 }
313
314
315 /**
316 * Exercise constant folding on remainder.
317 */
318
319 /// CHECK-START: int Main.IntRemainder() constant_folding (before)
320 /// CHECK-DAG: <<Const8:i\d+>> IntConstant 8
321 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3
322 /// CHECK-DAG: <<Div0Chk:i\d+>> DivZeroCheck [<<Const3>>]
323 /// CHECK-DAG: <<Rem:i\d+>> Rem [<<Const8>>,<<Div0Chk>>]
324 /// CHECK-DAG: Return [<<Rem>>]
325
326 /// CHECK-START: int Main.IntRemainder() constant_folding (after)
327 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
328 /// CHECK-DAG: Return [<<Const2>>]
329
330 /// CHECK-START: int Main.IntRemainder() constant_folding (after)
331 /// CHECK-NOT: DivZeroCheck
332 /// CHECK-NOT: Rem
333
334 public static int IntRemainder() {
335 int a, b, c;
336 a = 8;
337 b = 3;
338 c = a % b;
339 return c;
340 }
341
342 /// CHECK-START: long Main.LongRemainder() constant_folding (before)
343 /// CHECK-DAG: <<Const8:j\d+>> LongConstant 8
344 /// CHECK-DAG: <<Const3:j\d+>> LongConstant 3
345 /// CHECK-DAG: <<Div0Chk:j\d+>> DivZeroCheck [<<Const3>>]
346 /// CHECK-DAG: <<Rem:j\d+>> Rem [<<Const8>>,<<Div0Chk>>]
347 /// CHECK-DAG: Return [<<Rem>>]
348
349 /// CHECK-START: long Main.LongRemainder() constant_folding (after)
350 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2
351 /// CHECK-DAG: Return [<<Const2>>]
352
353 /// CHECK-START: long Main.LongRemainder() constant_folding (after)
354 /// CHECK-NOT: DivZeroCheck
355 /// CHECK-NOT: Rem
356
357 public static long LongRemainder() {
358 long a, b, c;
359 a = 8L;
360 b = 3L;
361 c = a % b;
362 return c;
363 }
364
365
366 /**
Roland Levillain9867bc72015-08-05 10:21:34 +0100367 * Exercise constant folding on left shift.
368 */
369
370 /// CHECK-START: int Main.ShlIntLong() constant_folding (before)
371 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
372 /// CHECK-DAG: <<Const2L:j\d+>> LongConstant 2
373 /// CHECK-DAG: <<TypeConv:i\d+>> TypeConversion [<<Const2L>>]
374 /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Const1>>,<<TypeConv>>]
375 /// CHECK-DAG: Return [<<Shl>>]
376
377 /// CHECK-START: int Main.ShlIntLong() constant_folding (after)
378 /// CHECK-DAG: <<Const4:i\d+>> IntConstant 4
379 /// CHECK-DAG: Return [<<Const4>>]
380
381 /// CHECK-START: int Main.ShlIntLong() constant_folding (after)
382 /// CHECK-NOT: Shl
383
384 public static int ShlIntLong() {
385 int lhs = 1;
386 long rhs = 2;
387 return lhs << rhs;
388 }
389
390 /// CHECK-START: long Main.ShlLongInt() constant_folding (before)
391 /// CHECK-DAG: <<Const3L:j\d+>> LongConstant 3
392 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
393 /// CHECK-DAG: <<Shl:j\d+>> Shl [<<Const3L>>,<<Const2>>]
394 /// CHECK-DAG: Return [<<Shl>>]
395
396 /// CHECK-START: long Main.ShlLongInt() constant_folding (after)
397 /// CHECK-DAG: <<Const12L:j\d+>> LongConstant 12
398 /// CHECK-DAG: Return [<<Const12L>>]
399
400 /// CHECK-START: long Main.ShlLongInt() constant_folding (after)
401 /// CHECK-NOT: Shl
402
403 public static long ShlLongInt() {
404 long lhs = 3;
405 int rhs = 2;
406 return lhs << rhs;
407 }
408
409
410 /**
411 * Exercise constant folding on right shift.
412 */
413
414 /// CHECK-START: int Main.ShrIntLong() constant_folding (before)
415 /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7
416 /// CHECK-DAG: <<Const2L:j\d+>> LongConstant 2
417 /// CHECK-DAG: <<TypeConv:i\d+>> TypeConversion [<<Const2L>>]
418 /// CHECK-DAG: <<Shr:i\d+>> Shr [<<Const7>>,<<TypeConv>>]
419 /// CHECK-DAG: Return [<<Shr>>]
420
421 /// CHECK-START: int Main.ShrIntLong() constant_folding (after)
422 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
423 /// CHECK-DAG: Return [<<Const1>>]
424
425 /// CHECK-START: int Main.ShrIntLong() constant_folding (after)
426 /// CHECK-NOT: Shr
427
428 public static int ShrIntLong() {
429 int lhs = 7;
430 long rhs = 2;
431 return lhs >> rhs;
432 }
433
434 /// CHECK-START: long Main.ShrLongInt() constant_folding (before)
435 /// CHECK-DAG: <<Const9L:j\d+>> LongConstant 9
436 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
437 /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Const9L>>,<<Const2>>]
438 /// CHECK-DAG: Return [<<Shr>>]
439
440 /// CHECK-START: long Main.ShrLongInt() constant_folding (after)
441 /// CHECK-DAG: <<Const2L:j\d+>> LongConstant 2
442 /// CHECK-DAG: Return [<<Const2L>>]
443
444 /// CHECK-START: long Main.ShrLongInt() constant_folding (after)
445 /// CHECK-NOT: Shr
446
447 public static long ShrLongInt() {
448 long lhs = 9;
449 int rhs = 2;
450 return lhs >> rhs;
451 }
452
453
454 /**
455 * Exercise constant folding on unsigned right shift.
456 */
457
458 /// CHECK-START: int Main.UShrIntLong() constant_folding (before)
459 /// CHECK-DAG: <<ConstM7:i\d+>> IntConstant -7
460 /// CHECK-DAG: <<Const2L:j\d+>> LongConstant 2
461 /// CHECK-DAG: <<TypeConv:i\d+>> TypeConversion [<<Const2L>>]
462 /// CHECK-DAG: <<UShr:i\d+>> UShr [<<ConstM7>>,<<TypeConv>>]
463 /// CHECK-DAG: Return [<<UShr>>]
464
465 /// CHECK-START: int Main.UShrIntLong() constant_folding (after)
466 /// CHECK-DAG: <<ConstRes:i\d+>> IntConstant 1073741822
467 /// CHECK-DAG: Return [<<ConstRes>>]
468
469 /// CHECK-START: int Main.UShrIntLong() constant_folding (after)
470 /// CHECK-NOT: UShr
471
472 public static int UShrIntLong() {
473 int lhs = -7;
474 long rhs = 2;
475 return lhs >>> rhs;
476 }
477
478 /// CHECK-START: long Main.UShrLongInt() constant_folding (before)
479 /// CHECK-DAG: <<ConstM9L:j\d+>> LongConstant -9
480 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
481 /// CHECK-DAG: <<UShr:j\d+>> UShr [<<ConstM9L>>,<<Const2>>]
482 /// CHECK-DAG: Return [<<UShr>>]
483
484 /// CHECK-START: long Main.UShrLongInt() constant_folding (after)
485 /// CHECK-DAG: <<ConstRes:j\d+>> LongConstant 4611686018427387901
486 /// CHECK-DAG: Return [<<ConstRes>>]
487
488 /// CHECK-START: long Main.UShrLongInt() constant_folding (after)
489 /// CHECK-NOT: UShr
490
491 public static long UShrLongInt() {
492 long lhs = -9;
493 int rhs = 2;
494 return lhs >>> rhs;
495 }
496
497
498 /**
499 * Exercise constant folding on logical and.
500 */
501
502 /// CHECK-START: long Main.AndIntLong() constant_folding (before)
503 /// CHECK-DAG: <<Const10:i\d+>> IntConstant 10
504 /// CHECK-DAG: <<Const3L:j\d+>> LongConstant 3
505 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const10>>]
506 /// CHECK-DAG: <<And:j\d+>> And [<<TypeConv>>,<<Const3L>>]
507 /// CHECK-DAG: Return [<<And>>]
508
509 /// CHECK-START: long Main.AndIntLong() constant_folding (after)
510 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2
511 /// CHECK-DAG: Return [<<Const2>>]
512
513 /// CHECK-START: long Main.AndIntLong() constant_folding (after)
514 /// CHECK-NOT: And
515
516 public static long AndIntLong() {
517 int lhs = 10;
518 long rhs = 3;
519 return lhs & rhs;
520 }
521
522 /// CHECK-START: long Main.AndLongInt() constant_folding (before)
523 /// CHECK-DAG: <<Const10L:j\d+>> LongConstant 10
524 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3
525 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const3>>]
David Brazdil57e863c2016-01-11 10:27:13 +0000526 /// CHECK-DAG: <<And:j\d+>> And [<<TypeConv>>,<<Const10L>>]
Roland Levillain9867bc72015-08-05 10:21:34 +0100527 /// CHECK-DAG: Return [<<And>>]
528
529 /// CHECK-START: long Main.AndLongInt() constant_folding (after)
530 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2
531 /// CHECK-DAG: Return [<<Const2>>]
532
533 /// CHECK-START: long Main.AndLongInt() constant_folding (after)
534 /// CHECK-NOT: And
535
536 public static long AndLongInt() {
537 long lhs = 10;
538 int rhs = 3;
539 return lhs & rhs;
540 }
541
542
543 /**
544 * Exercise constant folding on logical or.
545 */
546
547 /// CHECK-START: long Main.OrIntLong() constant_folding (before)
548 /// CHECK-DAG: <<Const10:i\d+>> IntConstant 10
549 /// CHECK-DAG: <<Const3L:j\d+>> LongConstant 3
550 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const10>>]
551 /// CHECK-DAG: <<Or:j\d+>> Or [<<TypeConv>>,<<Const3L>>]
552 /// CHECK-DAG: Return [<<Or>>]
553
554 /// CHECK-START: long Main.OrIntLong() constant_folding (after)
555 /// CHECK-DAG: <<Const11:j\d+>> LongConstant 11
556 /// CHECK-DAG: Return [<<Const11>>]
557
558 /// CHECK-START: long Main.OrIntLong() constant_folding (after)
559 /// CHECK-NOT: Or
560
561 public static long OrIntLong() {
562 int lhs = 10;
563 long rhs = 3;
564 return lhs | rhs;
565 }
566
567 /// CHECK-START: long Main.OrLongInt() constant_folding (before)
568 /// CHECK-DAG: <<Const10L:j\d+>> LongConstant 10
569 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3
570 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const3>>]
David Brazdil57e863c2016-01-11 10:27:13 +0000571 /// CHECK-DAG: <<Or:j\d+>> Or [<<TypeConv>>,<<Const10L>>]
Roland Levillain9867bc72015-08-05 10:21:34 +0100572 /// CHECK-DAG: Return [<<Or>>]
573
574 /// CHECK-START: long Main.OrLongInt() constant_folding (after)
575 /// CHECK-DAG: <<Const11:j\d+>> LongConstant 11
576 /// CHECK-DAG: Return [<<Const11>>]
577
578 /// CHECK-START: long Main.OrLongInt() constant_folding (after)
579 /// CHECK-NOT: Or
580
581 public static long OrLongInt() {
582 long lhs = 10;
583 int rhs = 3;
584 return lhs | rhs;
585 }
586
587
588 /**
589 * Exercise constant folding on logical exclusive or.
590 */
591
592 /// CHECK-START: long Main.XorIntLong() constant_folding (before)
593 /// CHECK-DAG: <<Const10:i\d+>> IntConstant 10
594 /// CHECK-DAG: <<Const3L:j\d+>> LongConstant 3
595 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const10>>]
596 /// CHECK-DAG: <<Xor:j\d+>> Xor [<<TypeConv>>,<<Const3L>>]
597 /// CHECK-DAG: Return [<<Xor>>]
598
599 /// CHECK-START: long Main.XorIntLong() constant_folding (after)
600 /// CHECK-DAG: <<Const9:j\d+>> LongConstant 9
601 /// CHECK-DAG: Return [<<Const9>>]
602
603 /// CHECK-START: long Main.XorIntLong() constant_folding (after)
604 /// CHECK-NOT: Xor
605
606 public static long XorIntLong() {
607 int lhs = 10;
608 long rhs = 3;
609 return lhs ^ rhs;
610 }
611
612 /// CHECK-START: long Main.XorLongInt() constant_folding (before)
613 /// CHECK-DAG: <<Const10L:j\d+>> LongConstant 10
614 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3
615 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const3>>]
David Brazdil57e863c2016-01-11 10:27:13 +0000616 /// CHECK-DAG: <<Xor:j\d+>> Xor [<<TypeConv>>,<<Const10L>>]
Roland Levillain9867bc72015-08-05 10:21:34 +0100617 /// CHECK-DAG: Return [<<Xor>>]
618
619 /// CHECK-START: long Main.XorLongInt() constant_folding (after)
620 /// CHECK-DAG: <<Const9:j\d+>> LongConstant 9
621 /// CHECK-DAG: Return [<<Const9>>]
622
623 /// CHECK-START: long Main.XorLongInt() constant_folding (after)
624 /// CHECK-NOT: Xor
625
626 public static long XorLongInt() {
627 long lhs = 10;
628 int rhs = 3;
629 return lhs ^ rhs;
630 }
631
632
633 /**
Roland Levillainb65eb502015-07-23 12:11:42 +0100634 * Exercise constant folding on constant (static) condition.
David Brazdilee690a32014-12-01 17:04:16 +0000635 */
636
David Brazdila06d66a2015-05-28 11:14:54 +0100637 /// CHECK-START: int Main.StaticCondition() constant_folding (before)
638 /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7
639 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
640 /// CHECK-DAG: <<Cond:z\d+>> GreaterThanOrEqual [<<Const7>>,<<Const2>>]
641 /// CHECK-DAG: If [<<Cond>>]
David Brazdilee690a32014-12-01 17:04:16 +0000642
David Brazdila06d66a2015-05-28 11:14:54 +0100643 /// CHECK-START: int Main.StaticCondition() constant_folding (after)
644 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
645 /// CHECK-DAG: If [<<Const1>>]
David Brazdilee690a32014-12-01 17:04:16 +0000646
Roland Levillainb65eb502015-07-23 12:11:42 +0100647 /// CHECK-START: int Main.StaticCondition() constant_folding (after)
648 /// CHECK-NOT: GreaterThanOrEqual
649
David Brazdilee690a32014-12-01 17:04:16 +0000650 public static int StaticCondition() {
651 int a, b, c;
David Brazdil4846d132015-01-15 19:07:08 +0000652 a = 7;
David Brazdilee690a32014-12-01 17:04:16 +0000653 b = 2;
654 if (a < b)
655 c = a + b;
656 else
657 c = a - b;
658 return c;
659 }
660
Roland Levillainb65eb502015-07-23 12:11:42 +0100661
David Brazdilee690a32014-12-01 17:04:16 +0000662 /**
Vladimir Marko9e23df52015-11-10 17:14:35 +0000663 * Exercise constant folding on constant (static) condition for null references.
664 */
665
666 /// CHECK-START: int Main.StaticConditionNulls() constant_folding_after_inlining (before)
667 /// CHECK-DAG: <<Null:l\d+>> NullConstant
668 /// CHECK-DAG: <<Cond:z\d+>> NotEqual [<<Null>>,<<Null>>]
David Brazdil74eb1b22015-12-14 11:44:01 +0000669 /// CHECK-DAG: Select [{{i\d+}},{{i\d+}},<<Cond>>]
Vladimir Marko9e23df52015-11-10 17:14:35 +0000670
671 /// CHECK-START: int Main.StaticConditionNulls() constant_folding_after_inlining (after)
672 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
David Brazdil74eb1b22015-12-14 11:44:01 +0000673 /// CHECK-DAG: Select [{{i\d+}},{{i\d+}},<<Const0>>]
Vladimir Marko9e23df52015-11-10 17:14:35 +0000674
675 /// CHECK-START: int Main.StaticConditionNulls() constant_folding_after_inlining (after)
676 /// CHECK-NOT: NotEqual
677
678 private static Object getNull() {
679 return null;
680 }
681
682 public static int StaticConditionNulls() {
683 Object a = getNull();
684 Object b = getNull();
685 return (a == b) ? 5 : 2;
686 }
687
688
689 /**
Roland Levillainb65eb502015-07-23 12:11:42 +0100690 * Exercise constant folding on a program with condition
691 * (i.e. jumps) leading to the creation of many blocks.
David Brazdilee690a32014-12-01 17:04:16 +0000692 *
693 * The intent of this test is to ensure that all constant expressions
694 * are actually evaluated at compile-time, thanks to the reverse
695 * (forward) post-order traversal of the the dominator tree.
696 */
697
David Brazdila06d66a2015-05-28 11:14:54 +0100698 /// CHECK-START: int Main.JumpsAndConditionals(boolean) constant_folding (before)
699 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
700 /// CHECK-DAG: <<Const5:i\d+>> IntConstant 5
701 /// CHECK-DAG: <<Add:i\d+>> Add [<<Const5>>,<<Const2>>]
702 /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Const5>>,<<Const2>>]
703 /// CHECK-DAG: <<Phi:i\d+>> Phi [<<Add>>,<<Sub>>]
704 /// CHECK-DAG: Return [<<Phi>>]
David Brazdilee690a32014-12-01 17:04:16 +0000705
David Brazdila06d66a2015-05-28 11:14:54 +0100706 /// CHECK-START: int Main.JumpsAndConditionals(boolean) constant_folding (after)
707 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3
708 /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7
709 /// CHECK-DAG: <<Phi:i\d+>> Phi [<<Const7>>,<<Const3>>]
710 /// CHECK-DAG: Return [<<Phi>>]
David Brazdilee690a32014-12-01 17:04:16 +0000711
Roland Levillainb65eb502015-07-23 12:11:42 +0100712 /// CHECK-START: int Main.JumpsAndConditionals(boolean) constant_folding (after)
713 /// CHECK-NOT: Add
714 /// CHECK-NOT: Sub
715
David Brazdilee690a32014-12-01 17:04:16 +0000716 public static int JumpsAndConditionals(boolean cond) {
717 int a, b, c;
718 a = 5;
719 b = 2;
720 if (cond)
721 c = a + b;
722 else
723 c = a - b;
724 return c;
725 }
David Brazdil4846d132015-01-15 19:07:08 +0000726
Roland Levillainb65eb502015-07-23 12:11:42 +0100727
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000728 /**
729 * Test optimizations of arithmetic identities yielding a constant result.
730 */
731
David Brazdila06d66a2015-05-28 11:14:54 +0100732 /// CHECK-START: int Main.And0(int) constant_folding (before)
733 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
734 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
735 /// CHECK-DAG: <<And:i\d+>> And [<<Arg>>,<<Const0>>]
736 /// CHECK-DAG: Return [<<And>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000737
David Brazdila06d66a2015-05-28 11:14:54 +0100738 /// CHECK-START: int Main.And0(int) constant_folding (after)
739 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
740 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +0100741 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000742
Roland Levillainb65eb502015-07-23 12:11:42 +0100743 /// CHECK-START: int Main.And0(int) constant_folding (after)
744 /// CHECK-NOT: And
745
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000746 public static int And0(int arg) {
747 return arg & 0;
748 }
749
David Brazdila06d66a2015-05-28 11:14:54 +0100750 /// CHECK-START: long Main.Mul0(long) constant_folding (before)
751 /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
752 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0
David Brazdil57e863c2016-01-11 10:27:13 +0000753 /// CHECK-DAG: <<Mul:j\d+>> Mul [<<Const0>>,<<Arg>>]
David Brazdila06d66a2015-05-28 11:14:54 +0100754 /// CHECK-DAG: Return [<<Mul>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000755
David Brazdila06d66a2015-05-28 11:14:54 +0100756 /// CHECK-START: long Main.Mul0(long) constant_folding (after)
757 /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
758 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +0100759 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000760
Roland Levillainb65eb502015-07-23 12:11:42 +0100761 /// CHECK-START: long Main.Mul0(long) constant_folding (after)
762 /// CHECK-NOT: Mul
763
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000764 public static long Mul0(long arg) {
765 return arg * 0;
766 }
767
David Brazdila06d66a2015-05-28 11:14:54 +0100768 /// CHECK-START: int Main.OrAllOnes(int) constant_folding (before)
769 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
770 /// CHECK-DAG: <<ConstF:i\d+>> IntConstant -1
771 /// CHECK-DAG: <<Or:i\d+>> Or [<<Arg>>,<<ConstF>>]
772 /// CHECK-DAG: Return [<<Or>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000773
David Brazdila06d66a2015-05-28 11:14:54 +0100774 /// CHECK-START: int Main.OrAllOnes(int) constant_folding (after)
775 /// CHECK-DAG: <<ConstF:i\d+>> IntConstant -1
David Brazdila06d66a2015-05-28 11:14:54 +0100776 /// CHECK-DAG: Return [<<ConstF>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000777
Roland Levillainb65eb502015-07-23 12:11:42 +0100778 /// CHECK-START: int Main.OrAllOnes(int) constant_folding (after)
779 /// CHECK-NOT: Or
780
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000781 public static int OrAllOnes(int arg) {
782 return arg | -1;
783 }
784
David Brazdila06d66a2015-05-28 11:14:54 +0100785 /// CHECK-START: long Main.Rem0(long) constant_folding (before)
786 /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
787 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0
788 /// CHECK-DAG: <<DivZeroCheck:j\d+>> DivZeroCheck [<<Arg>>]
789 /// CHECK-DAG: <<Rem:j\d+>> Rem [<<Const0>>,<<DivZeroCheck>>]
790 /// CHECK-DAG: Return [<<Rem>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000791
David Brazdila06d66a2015-05-28 11:14:54 +0100792 /// CHECK-START: long Main.Rem0(long) constant_folding (after)
793 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +0100794 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000795
Roland Levillainb65eb502015-07-23 12:11:42 +0100796 /// CHECK-START: long Main.Rem0(long) constant_folding (after)
797 /// CHECK-NOT: Rem
798
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000799 public static long Rem0(long arg) {
800 return 0 % arg;
801 }
802
David Brazdila06d66a2015-05-28 11:14:54 +0100803 /// CHECK-START: int Main.Rem1(int) constant_folding (before)
804 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
805 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
806 /// CHECK-DAG: <<Rem:i\d+>> Rem [<<Arg>>,<<Const1>>]
807 /// CHECK-DAG: Return [<<Rem>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000808
David Brazdila06d66a2015-05-28 11:14:54 +0100809 /// CHECK-START: int Main.Rem1(int) constant_folding (after)
810 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +0100811 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000812
Roland Levillainb65eb502015-07-23 12:11:42 +0100813 /// CHECK-START: int Main.Rem1(int) constant_folding (after)
814 /// CHECK-NOT: Rem
815
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000816 public static int Rem1(int arg) {
817 return arg % 1;
818 }
819
David Brazdila06d66a2015-05-28 11:14:54 +0100820 /// CHECK-START: long Main.RemN1(long) constant_folding (before)
821 /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
822 /// CHECK-DAG: <<ConstN1:j\d+>> LongConstant -1
823 /// CHECK-DAG: <<DivZeroCheck:j\d+>> DivZeroCheck [<<ConstN1>>]
824 /// CHECK-DAG: <<Rem:j\d+>> Rem [<<Arg>>,<<DivZeroCheck>>]
825 /// CHECK-DAG: Return [<<Rem>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000826
David Brazdila06d66a2015-05-28 11:14:54 +0100827 /// CHECK-START: long Main.RemN1(long) constant_folding (after)
828 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +0100829 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000830
Roland Levillainb65eb502015-07-23 12:11:42 +0100831 /// CHECK-START: long Main.RemN1(long) constant_folding (after)
832 /// CHECK-NOT: Rem
833
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000834 public static long RemN1(long arg) {
835 return arg % -1;
836 }
837
David Brazdila06d66a2015-05-28 11:14:54 +0100838 /// CHECK-START: int Main.Shl0(int) constant_folding (before)
839 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
840 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
841 /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Const0>>,<<Arg>>]
842 /// CHECK-DAG: Return [<<Shl>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000843
David Brazdila06d66a2015-05-28 11:14:54 +0100844 /// CHECK-START: int Main.Shl0(int) constant_folding (after)
845 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
846 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +0100847 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000848
Roland Levillainb65eb502015-07-23 12:11:42 +0100849 /// CHECK-START: int Main.Shl0(int) constant_folding (after)
850 /// CHECK-NOT: Shl
851
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000852 public static int Shl0(int arg) {
853 return 0 << arg;
854 }
855
Roland Levillain9867bc72015-08-05 10:21:34 +0100856 /// CHECK-START: long Main.ShlLong0WithInt(int) constant_folding (before)
857 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
858 /// CHECK-DAG: <<Const0L:j\d+>> LongConstant 0
859 /// CHECK-DAG: <<Shl:j\d+>> Shl [<<Const0L>>,<<Arg>>]
860 /// CHECK-DAG: Return [<<Shl>>]
861
862 /// CHECK-START: long Main.ShlLong0WithInt(int) constant_folding (after)
863 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
864 /// CHECK-DAG: <<Const0L:j\d+>> LongConstant 0
865 /// CHECK-DAG: Return [<<Const0L>>]
866
867 /// CHECK-START: long Main.ShlLong0WithInt(int) constant_folding (after)
868 /// CHECK-NOT: Shl
869
870 public static long ShlLong0WithInt(int arg) {
871 long long_zero = 0;
872 return long_zero << arg;
873 }
874
David Brazdila06d66a2015-05-28 11:14:54 +0100875 /// CHECK-START: long Main.Shr0(int) constant_folding (before)
876 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
877 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0
878 /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Const0>>,<<Arg>>]
879 /// CHECK-DAG: Return [<<Shr>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000880
David Brazdila06d66a2015-05-28 11:14:54 +0100881 /// CHECK-START: long Main.Shr0(int) constant_folding (after)
882 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
883 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +0100884 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000885
Roland Levillainb65eb502015-07-23 12:11:42 +0100886 /// CHECK-START: long Main.Shr0(int) constant_folding (after)
887 /// CHECK-NOT: Shr
888
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000889 public static long Shr0(int arg) {
890 return (long)0 >> arg;
891 }
892
David Brazdila06d66a2015-05-28 11:14:54 +0100893 /// CHECK-START: long Main.SubSameLong(long) constant_folding (before)
894 /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
895 /// CHECK-DAG: <<Sub:j\d+>> Sub [<<Arg>>,<<Arg>>]
896 /// CHECK-DAG: Return [<<Sub>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000897
David Brazdila06d66a2015-05-28 11:14:54 +0100898 /// CHECK-START: long Main.SubSameLong(long) constant_folding (after)
899 /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
900 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +0100901 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000902
Roland Levillainb65eb502015-07-23 12:11:42 +0100903 /// CHECK-START: long Main.SubSameLong(long) constant_folding (after)
904 /// CHECK-NOT: Sub
905
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000906 public static long SubSameLong(long arg) {
907 return arg - arg;
908 }
909
David Brazdila06d66a2015-05-28 11:14:54 +0100910 /// CHECK-START: int Main.UShr0(int) constant_folding (before)
911 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
912 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
913 /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Const0>>,<<Arg>>]
914 /// CHECK-DAG: Return [<<UShr>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000915
David Brazdila06d66a2015-05-28 11:14:54 +0100916 /// CHECK-START: int Main.UShr0(int) constant_folding (after)
917 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
918 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +0100919 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000920
Roland Levillainb65eb502015-07-23 12:11:42 +0100921 /// CHECK-START: int Main.UShr0(int) constant_folding (after)
922 /// CHECK-NOT: UShr
923
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000924 public static int UShr0(int arg) {
925 return 0 >>> arg;
926 }
927
David Brazdila06d66a2015-05-28 11:14:54 +0100928 /// CHECK-START: int Main.XorSameInt(int) constant_folding (before)
929 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
930 /// CHECK-DAG: <<Xor:i\d+>> Xor [<<Arg>>,<<Arg>>]
931 /// CHECK-DAG: Return [<<Xor>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000932
David Brazdila06d66a2015-05-28 11:14:54 +0100933 /// CHECK-START: int Main.XorSameInt(int) constant_folding (after)
934 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
935 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +0100936 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000937
Roland Levillainb65eb502015-07-23 12:11:42 +0100938 /// CHECK-START: int Main.XorSameInt(int) constant_folding (after)
939 /// CHECK-NOT: Xor
940
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000941 public static int XorSameInt(int arg) {
942 return arg ^ arg;
943 }
944
David Brazdila06d66a2015-05-28 11:14:54 +0100945 /// CHECK-START: boolean Main.CmpFloatGreaterThanNaN(float) constant_folding (before)
946 /// CHECK-DAG: <<Arg:f\d+>> ParameterValue
947 /// CHECK-DAG: <<ConstNan:f\d+>> FloatConstant nan
948 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
949 /// CHECK-DAG: IntConstant 1
950 /// CHECK-DAG: <<Cmp:i\d+>> Compare [<<Arg>>,<<ConstNan>>]
951 /// CHECK-DAG: <<Le:z\d+>> LessThanOrEqual [<<Cmp>>,<<Const0>>]
952 /// CHECK-DAG: If [<<Le>>]
Roland Levillain3b55ebb2015-05-08 13:13:19 +0100953
David Brazdila06d66a2015-05-28 11:14:54 +0100954 /// CHECK-START: boolean Main.CmpFloatGreaterThanNaN(float) constant_folding (after)
955 /// CHECK-DAG: ParameterValue
956 /// CHECK-DAG: FloatConstant nan
957 /// CHECK-DAG: IntConstant 0
958 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
959 /// CHECK-DAG: If [<<Const1>>]
Roland Levillain3b55ebb2015-05-08 13:13:19 +0100960
David Brazdila06d66a2015-05-28 11:14:54 +0100961 /// CHECK-START: boolean Main.CmpFloatGreaterThanNaN(float) constant_folding (after)
962 /// CHECK-NOT: Compare
963 /// CHECK-NOT: LessThanOrEqual
Roland Levillain3b55ebb2015-05-08 13:13:19 +0100964
965 public static boolean CmpFloatGreaterThanNaN(float arg) {
966 return arg > Float.NaN;
967 }
968
David Brazdila06d66a2015-05-28 11:14:54 +0100969 /// CHECK-START: boolean Main.CmpDoubleLessThanNaN(double) constant_folding (before)
970 /// CHECK-DAG: <<Arg:d\d+>> ParameterValue
971 /// CHECK-DAG: <<ConstNan:d\d+>> DoubleConstant nan
972 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
973 /// CHECK-DAG: IntConstant 1
974 /// CHECK-DAG: <<Cmp:i\d+>> Compare [<<Arg>>,<<ConstNan>>]
975 /// CHECK-DAG: <<Ge:z\d+>> GreaterThanOrEqual [<<Cmp>>,<<Const0>>]
976 /// CHECK-DAG: If [<<Ge>>]
Roland Levillain3b55ebb2015-05-08 13:13:19 +0100977
David Brazdila06d66a2015-05-28 11:14:54 +0100978 /// CHECK-START: boolean Main.CmpDoubleLessThanNaN(double) constant_folding (after)
979 /// CHECK-DAG: ParameterValue
980 /// CHECK-DAG: DoubleConstant nan
981 /// CHECK-DAG: IntConstant 0
982 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
983 /// CHECK-DAG: If [<<Const1>>]
Roland Levillain3b55ebb2015-05-08 13:13:19 +0100984
David Brazdila06d66a2015-05-28 11:14:54 +0100985 /// CHECK-START: boolean Main.CmpDoubleLessThanNaN(double) constant_folding (after)
986 /// CHECK-NOT: Compare
987 /// CHECK-NOT: GreaterThanOrEqual
Roland Levillain3b55ebb2015-05-08 13:13:19 +0100988
989 public static boolean CmpDoubleLessThanNaN(double arg) {
990 return arg < Double.NaN;
991 }
992
Roland Levillainb65eb502015-07-23 12:11:42 +0100993
994 /**
995 * Exercise constant folding on type conversions.
996 */
997
David Brazdila06d66a2015-05-28 11:14:54 +0100998 /// CHECK-START: int Main.ReturnInt33() constant_folding (before)
999 /// CHECK-DAG: <<Const33:j\d+>> LongConstant 33
1000 /// CHECK-DAG: <<Convert:i\d+>> TypeConversion [<<Const33>>]
1001 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001002
David Brazdila06d66a2015-05-28 11:14:54 +01001003 /// CHECK-START: int Main.ReturnInt33() constant_folding (after)
1004 /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33
1005 /// CHECK-DAG: Return [<<Const33>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001006
Roland Levillainb65eb502015-07-23 12:11:42 +01001007 /// CHECK-START: int Main.ReturnInt33() constant_folding (after)
1008 /// CHECK-NOT: TypeConversion
1009
Mark Mendelle82549b2015-05-06 10:55:34 -04001010 public static int ReturnInt33() {
1011 long imm = 33L;
1012 return (int) imm;
1013 }
1014
David Brazdila06d66a2015-05-28 11:14:54 +01001015 /// CHECK-START: int Main.ReturnIntMax() constant_folding (before)
1016 /// CHECK-DAG: <<ConstMax:f\d+>> FloatConstant 1e+34
1017 /// CHECK-DAG: <<Convert:i\d+>> TypeConversion [<<ConstMax>>]
1018 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001019
David Brazdila06d66a2015-05-28 11:14:54 +01001020 /// CHECK-START: int Main.ReturnIntMax() constant_folding (after)
1021 /// CHECK-DAG: <<ConstMax:i\d+>> IntConstant 2147483647
1022 /// CHECK-DAG: Return [<<ConstMax>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001023
Roland Levillainb65eb502015-07-23 12:11:42 +01001024 /// CHECK-START: int Main.ReturnIntMax() constant_folding (after)
1025 /// CHECK-NOT: TypeConversion
1026
Mark Mendelle82549b2015-05-06 10:55:34 -04001027 public static int ReturnIntMax() {
1028 float imm = 1.0e34f;
1029 return (int) imm;
1030 }
1031
David Brazdila06d66a2015-05-28 11:14:54 +01001032 /// CHECK-START: int Main.ReturnInt0() constant_folding (before)
1033 /// CHECK-DAG: <<ConstNaN:d\d+>> DoubleConstant nan
1034 /// CHECK-DAG: <<Convert:i\d+>> TypeConversion [<<ConstNaN>>]
1035 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001036
David Brazdila06d66a2015-05-28 11:14:54 +01001037 /// CHECK-START: int Main.ReturnInt0() constant_folding (after)
1038 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
1039 /// CHECK-DAG: Return [<<Const0>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001040
Roland Levillainb65eb502015-07-23 12:11:42 +01001041 /// CHECK-START: int Main.ReturnInt0() constant_folding (after)
1042 /// CHECK-NOT: TypeConversion
1043
Mark Mendelle82549b2015-05-06 10:55:34 -04001044 public static int ReturnInt0() {
1045 double imm = Double.NaN;
1046 return (int) imm;
1047 }
1048
David Brazdila06d66a2015-05-28 11:14:54 +01001049 /// CHECK-START: long Main.ReturnLong33() constant_folding (before)
1050 /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33
1051 /// CHECK-DAG: <<Convert:j\d+>> TypeConversion [<<Const33>>]
1052 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001053
David Brazdila06d66a2015-05-28 11:14:54 +01001054 /// CHECK-START: long Main.ReturnLong33() constant_folding (after)
1055 /// CHECK-DAG: <<Const33:j\d+>> LongConstant 33
1056 /// CHECK-DAG: Return [<<Const33>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001057
Roland Levillainb65eb502015-07-23 12:11:42 +01001058 /// CHECK-START: long Main.ReturnLong33() constant_folding (after)
1059 /// CHECK-NOT: TypeConversion
1060
Mark Mendelle82549b2015-05-06 10:55:34 -04001061 public static long ReturnLong33() {
1062 int imm = 33;
1063 return (long) imm;
1064 }
1065
David Brazdila06d66a2015-05-28 11:14:54 +01001066 /// CHECK-START: long Main.ReturnLong34() constant_folding (before)
1067 /// CHECK-DAG: <<Const34:f\d+>> FloatConstant 34
1068 /// CHECK-DAG: <<Convert:j\d+>> TypeConversion [<<Const34>>]
1069 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001070
David Brazdila06d66a2015-05-28 11:14:54 +01001071 /// CHECK-START: long Main.ReturnLong34() constant_folding (after)
1072 /// CHECK-DAG: <<Const34:j\d+>> LongConstant 34
1073 /// CHECK-DAG: Return [<<Const34>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001074
Roland Levillainb65eb502015-07-23 12:11:42 +01001075 /// CHECK-START: long Main.ReturnLong34() constant_folding (after)
1076 /// CHECK-NOT: TypeConversion
1077
Mark Mendelle82549b2015-05-06 10:55:34 -04001078 public static long ReturnLong34() {
1079 float imm = 34.0f;
1080 return (long) imm;
1081 }
1082
David Brazdila06d66a2015-05-28 11:14:54 +01001083 /// CHECK-START: long Main.ReturnLong0() constant_folding (before)
1084 /// CHECK-DAG: <<ConstNaN:d\d+>> DoubleConstant nan
1085 /// CHECK-DAG: <<Convert:j\d+>> TypeConversion [<<ConstNaN>>]
1086 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001087
David Brazdila06d66a2015-05-28 11:14:54 +01001088 /// CHECK-START: long Main.ReturnLong0() constant_folding (after)
1089 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0
1090 /// CHECK-DAG: Return [<<Const0>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001091
Roland Levillainb65eb502015-07-23 12:11:42 +01001092 /// CHECK-START: long Main.ReturnLong0() constant_folding (after)
1093 /// CHECK-NOT: TypeConversion
1094
Mark Mendelle82549b2015-05-06 10:55:34 -04001095 public static long ReturnLong0() {
1096 double imm = -Double.NaN;
1097 return (long) imm;
1098 }
1099
David Brazdila06d66a2015-05-28 11:14:54 +01001100 /// CHECK-START: float Main.ReturnFloat33() constant_folding (before)
1101 /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33
1102 /// CHECK-DAG: <<Convert:f\d+>> TypeConversion [<<Const33>>]
1103 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001104
David Brazdila06d66a2015-05-28 11:14:54 +01001105 /// CHECK-START: float Main.ReturnFloat33() constant_folding (after)
1106 /// CHECK-DAG: <<Const33:f\d+>> FloatConstant 33
1107 /// CHECK-DAG: Return [<<Const33>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001108
Roland Levillainb65eb502015-07-23 12:11:42 +01001109 /// CHECK-START: float Main.ReturnFloat33() constant_folding (after)
1110 /// CHECK-NOT: TypeConversion
1111
Mark Mendelle82549b2015-05-06 10:55:34 -04001112 public static float ReturnFloat33() {
1113 int imm = 33;
1114 return (float) imm;
1115 }
1116
David Brazdila06d66a2015-05-28 11:14:54 +01001117 /// CHECK-START: float Main.ReturnFloat34() constant_folding (before)
1118 /// CHECK-DAG: <<Const34:j\d+>> LongConstant 34
1119 /// CHECK-DAG: <<Convert:f\d+>> TypeConversion [<<Const34>>]
1120 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001121
David Brazdila06d66a2015-05-28 11:14:54 +01001122 /// CHECK-START: float Main.ReturnFloat34() constant_folding (after)
1123 /// CHECK-DAG: <<Const34:f\d+>> FloatConstant 34
1124 /// CHECK-DAG: Return [<<Const34>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001125
Roland Levillainb65eb502015-07-23 12:11:42 +01001126 /// CHECK-START: float Main.ReturnFloat34() constant_folding (after)
1127 /// CHECK-NOT: TypeConversion
1128
Mark Mendelle82549b2015-05-06 10:55:34 -04001129 public static float ReturnFloat34() {
1130 long imm = 34L;
1131 return (float) imm;
1132 }
1133
David Brazdila06d66a2015-05-28 11:14:54 +01001134 /// CHECK-START: float Main.ReturnFloat99P25() constant_folding (before)
1135 /// CHECK-DAG: <<Const:d\d+>> DoubleConstant 99.25
1136 /// CHECK-DAG: <<Convert:f\d+>> TypeConversion [<<Const>>]
1137 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001138
David Brazdila06d66a2015-05-28 11:14:54 +01001139 /// CHECK-START: float Main.ReturnFloat99P25() constant_folding (after)
1140 /// CHECK-DAG: <<Const:f\d+>> FloatConstant 99.25
1141 /// CHECK-DAG: Return [<<Const>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001142
Roland Levillainb65eb502015-07-23 12:11:42 +01001143 /// CHECK-START: float Main.ReturnFloat99P25() constant_folding (after)
1144 /// CHECK-NOT: TypeConversion
1145
Mark Mendelle82549b2015-05-06 10:55:34 -04001146 public static float ReturnFloat99P25() {
1147 double imm = 99.25;
1148 return (float) imm;
1149 }
1150
David Brazdila06d66a2015-05-28 11:14:54 +01001151 /// CHECK-START: double Main.ReturnDouble33() constant_folding (before)
1152 /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33
1153 /// CHECK-DAG: <<Convert:d\d+>> TypeConversion [<<Const33>>]
1154 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001155
David Brazdila06d66a2015-05-28 11:14:54 +01001156 /// CHECK-START: double Main.ReturnDouble33() constant_folding (after)
1157 /// CHECK-DAG: <<Const33:d\d+>> DoubleConstant 33
1158 /// CHECK-DAG: Return [<<Const33>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001159
1160 public static double ReturnDouble33() {
1161 int imm = 33;
1162 return (double) imm;
1163 }
1164
David Brazdila06d66a2015-05-28 11:14:54 +01001165 /// CHECK-START: double Main.ReturnDouble34() constant_folding (before)
1166 /// CHECK-DAG: <<Const34:j\d+>> LongConstant 34
1167 /// CHECK-DAG: <<Convert:d\d+>> TypeConversion [<<Const34>>]
1168 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001169
David Brazdila06d66a2015-05-28 11:14:54 +01001170 /// CHECK-START: double Main.ReturnDouble34() constant_folding (after)
1171 /// CHECK-DAG: <<Const34:d\d+>> DoubleConstant 34
1172 /// CHECK-DAG: Return [<<Const34>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001173
Roland Levillainb65eb502015-07-23 12:11:42 +01001174 /// CHECK-START: double Main.ReturnDouble34() constant_folding (after)
1175 /// CHECK-NOT: TypeConversion
1176
Mark Mendelle82549b2015-05-06 10:55:34 -04001177 public static double ReturnDouble34() {
1178 long imm = 34L;
1179 return (double) imm;
1180 }
1181
David Brazdila06d66a2015-05-28 11:14:54 +01001182 /// CHECK-START: double Main.ReturnDouble99P25() constant_folding (before)
1183 /// CHECK-DAG: <<Const:f\d+>> FloatConstant 99.25
1184 /// CHECK-DAG: <<Convert:d\d+>> TypeConversion [<<Const>>]
1185 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001186
David Brazdila06d66a2015-05-28 11:14:54 +01001187 /// CHECK-START: double Main.ReturnDouble99P25() constant_folding (after)
1188 /// CHECK-DAG: <<Const:d\d+>> DoubleConstant 99.25
1189 /// CHECK-DAG: Return [<<Const>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001190
Roland Levillainb65eb502015-07-23 12:11:42 +01001191 /// CHECK-START: double Main.ReturnDouble99P25() constant_folding (after)
1192 /// CHECK-NOT: TypeConversion
1193
Mark Mendelle82549b2015-05-06 10:55:34 -04001194 public static double ReturnDouble99P25() {
1195 float imm = 99.25f;
1196 return (double) imm;
1197 }
1198
Roland Levillainb65eb502015-07-23 12:11:42 +01001199
David Brazdil4846d132015-01-15 19:07:08 +00001200 public static void main(String[] args) {
Roland Levillainb65eb502015-07-23 12:11:42 +01001201 assertIntEquals(-42, IntNegation());
Roland Levillainc90bc7c2014-12-11 12:14:33 +00001202 assertLongEquals(-42L, LongNegation());
Roland Levillainb65eb502015-07-23 12:11:42 +01001203
1204 assertIntEquals(3, IntAddition1());
1205 assertIntEquals(14, IntAddition2());
1206 assertLongEquals(3L, LongAddition());
1207
1208 assertIntEquals(4, IntSubtraction());
1209 assertLongEquals(4L, LongSubtraction());
1210
Roland Levillainf7746ad2015-07-22 14:12:01 +01001211 assertIntEquals(21, IntMultiplication());
1212 assertLongEquals(21L, LongMultiplication());
1213
1214 assertIntEquals(2, IntDivision());
1215 assertLongEquals(2L, LongDivision());
1216
1217 assertIntEquals(2, IntRemainder());
1218 assertLongEquals(2L, LongRemainder());
1219
Roland Levillain9867bc72015-08-05 10:21:34 +01001220 assertIntEquals(4, ShlIntLong());
1221 assertLongEquals(12L, ShlLongInt());
1222
1223 assertIntEquals(1, ShrIntLong());
1224 assertLongEquals(2L, ShrLongInt());
1225
1226 assertIntEquals(1073741822, UShrIntLong());
1227 assertLongEquals(4611686018427387901L, UShrLongInt());
1228
1229 assertLongEquals(2, AndIntLong());
1230 assertLongEquals(2, AndLongInt());
1231
1232 assertLongEquals(11, OrIntLong());
1233 assertLongEquals(11, OrLongInt());
1234
1235 assertLongEquals(9, XorIntLong());
1236 assertLongEquals(9, XorLongInt());
1237
Roland Levillainb65eb502015-07-23 12:11:42 +01001238 assertIntEquals(5, StaticCondition());
Vladimir Marko9e23df52015-11-10 17:14:35 +00001239 assertIntEquals(5, StaticConditionNulls());
Roland Levillainb65eb502015-07-23 12:11:42 +01001240
1241 assertIntEquals(7, JumpsAndConditionals(true));
1242 assertIntEquals(3, JumpsAndConditionals(false));
1243
Roland Levillain3b55ebb2015-05-08 13:13:19 +01001244 int arbitrary = 123456; // Value chosen arbitrarily.
Roland Levillainb65eb502015-07-23 12:11:42 +01001245
1246 assertIntEquals(0, And0(arbitrary));
1247 assertLongEquals(0, Mul0(arbitrary));
1248 assertIntEquals(-1, OrAllOnes(arbitrary));
1249 assertLongEquals(0, Rem0(arbitrary));
1250 assertIntEquals(0, Rem1(arbitrary));
1251 assertLongEquals(0, RemN1(arbitrary));
1252 assertIntEquals(0, Shl0(arbitrary));
Roland Levillain9867bc72015-08-05 10:21:34 +01001253 assertLongEquals(0, ShlLong0WithInt(arbitrary));
Roland Levillainb65eb502015-07-23 12:11:42 +01001254 assertLongEquals(0, Shr0(arbitrary));
1255 assertLongEquals(0, SubSameLong(arbitrary));
1256 assertIntEquals(0, UShr0(arbitrary));
1257 assertIntEquals(0, XorSameInt(arbitrary));
1258
Roland Levillain3b55ebb2015-05-08 13:13:19 +01001259 assertFalse(CmpFloatGreaterThanNaN(arbitrary));
1260 assertFalse(CmpDoubleLessThanNaN(arbitrary));
Roland Levillainb65eb502015-07-23 12:11:42 +01001261
1262 assertIntEquals(33, ReturnInt33());
1263 assertIntEquals(2147483647, ReturnIntMax());
1264 assertIntEquals(0, ReturnInt0());
1265
1266 assertLongEquals(33, ReturnLong33());
1267 assertLongEquals(34, ReturnLong34());
1268 assertLongEquals(0, ReturnLong0());
1269
1270 assertFloatEquals(33, ReturnFloat33());
1271 assertFloatEquals(34, ReturnFloat34());
1272 assertFloatEquals(99.25f, ReturnFloat99P25());
1273
1274 assertDoubleEquals(33, ReturnDouble33());
1275 assertDoubleEquals(34, ReturnDouble34());
1276 assertDoubleEquals(99.25, ReturnDouble99P25());
David Brazdil4846d132015-01-15 19:07:08 +00001277 }
David Brazdilee690a32014-12-01 17:04:16 +00001278}