blob: c89ab4dffe1b8341514dc3890aca3b2337be0ecc [file] [log] [blame]
David Brazdilee690a32014-12-01 17:04:16 +00001/*
2* 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*/
16
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
David Brazdilee690a32014-12-01 17:04:16 +000037 /**
38 * Tiny three-register program exercising int constant folding
39 * on negation.
40 */
41
David Brazdil4846d132015-01-15 19:07:08 +000042 // CHECK-START: int Main.IntNegation() constant_folding (before)
David Brazdilbe0cc082014-12-31 11:49:30 +000043 // CHECK-DAG: [[Const42:i\d+]] IntConstant 42
44 // CHECK-DAG: [[Neg:i\d+]] Neg [ [[Const42]] ]
45 // CHECK-DAG: Return [ [[Neg]] ]
David Brazdilee690a32014-12-01 17:04:16 +000046
David Brazdil4846d132015-01-15 19:07:08 +000047 // CHECK-START: int Main.IntNegation() constant_folding (after)
David Brazdilbe0cc082014-12-31 11:49:30 +000048 // CHECK-DAG: [[ConstN42:i\d+]] IntConstant -42
49 // CHECK-DAG: Return [ [[ConstN42]] ]
David Brazdilee690a32014-12-01 17:04:16 +000050
51 public static int IntNegation() {
52 int x, y;
53 x = 42;
54 y = -x;
55 return y;
56 }
57
58 /**
59 * Tiny three-register program exercising int constant folding
60 * on addition.
61 */
62
David Brazdil4846d132015-01-15 19:07:08 +000063 // CHECK-START: int Main.IntAddition1() constant_folding (before)
David Brazdilbe0cc082014-12-31 11:49:30 +000064 // CHECK-DAG: [[Const1:i\d+]] IntConstant 1
65 // CHECK-DAG: [[Const2:i\d+]] IntConstant 2
66 // CHECK-DAG: [[Add:i\d+]] Add [ [[Const1]] [[Const2]] ]
67 // CHECK-DAG: Return [ [[Add]] ]
David Brazdilee690a32014-12-01 17:04:16 +000068
David Brazdil4846d132015-01-15 19:07:08 +000069 // CHECK-START: int Main.IntAddition1() constant_folding (after)
David Brazdilbe0cc082014-12-31 11:49:30 +000070 // CHECK-DAG: [[Const3:i\d+]] IntConstant 3
71 // CHECK-DAG: Return [ [[Const3]] ]
David Brazdilee690a32014-12-01 17:04:16 +000072
73 public static int IntAddition1() {
74 int a, b, c;
75 a = 1;
76 b = 2;
77 c = a + b;
78 return c;
79 }
80
81 /**
82 * Small three-register program exercising int constant folding
83 * on addition.
84 */
85
David Brazdil4846d132015-01-15 19:07:08 +000086 // CHECK-START: int Main.IntAddition2() constant_folding (before)
David Brazdilbe0cc082014-12-31 11:49:30 +000087 // CHECK-DAG: [[Const1:i\d+]] IntConstant 1
88 // CHECK-DAG: [[Const2:i\d+]] IntConstant 2
89 // CHECK-DAG: [[Const5:i\d+]] IntConstant 5
90 // CHECK-DAG: [[Const6:i\d+]] IntConstant 6
91 // CHECK-DAG: [[Add1:i\d+]] Add [ [[Const1]] [[Const2]] ]
92 // CHECK-DAG: [[Add2:i\d+]] Add [ [[Const5]] [[Const6]] ]
93 // CHECK-DAG: [[Add3:i\d+]] Add [ [[Add1]] [[Add2]] ]
94 // CHECK-DAG: Return [ [[Add3]] ]
David Brazdilee690a32014-12-01 17:04:16 +000095
David Brazdil4846d132015-01-15 19:07:08 +000096 // CHECK-START: int Main.IntAddition2() constant_folding (after)
David Brazdilbe0cc082014-12-31 11:49:30 +000097 // CHECK-DAG: [[Const14:i\d+]] IntConstant 14
98 // CHECK-DAG: Return [ [[Const14]] ]
David Brazdilee690a32014-12-01 17:04:16 +000099
100 public static int IntAddition2() {
101 int a, b, c;
102 a = 1;
103 b = 2;
104 a += b;
105 b = 5;
106 c = 6;
107 b += c;
108 c = a + b;
109 return c;
110 }
111
112 /**
113 * Tiny three-register program exercising int constant folding
114 * on subtraction.
115 */
116
David Brazdil4846d132015-01-15 19:07:08 +0000117 // CHECK-START: int Main.IntSubtraction() constant_folding (before)
118 // CHECK-DAG: [[Const6:i\d+]] IntConstant 6
David Brazdilbe0cc082014-12-31 11:49:30 +0000119 // CHECK-DAG: [[Const2:i\d+]] IntConstant 2
David Brazdil4846d132015-01-15 19:07:08 +0000120 // CHECK-DAG: [[Sub:i\d+]] Sub [ [[Const6]] [[Const2]] ]
David Brazdilbe0cc082014-12-31 11:49:30 +0000121 // CHECK-DAG: Return [ [[Sub]] ]
David Brazdilee690a32014-12-01 17:04:16 +0000122
David Brazdil4846d132015-01-15 19:07:08 +0000123 // CHECK-START: int Main.IntSubtraction() constant_folding (after)
124 // CHECK-DAG: [[Const4:i\d+]] IntConstant 4
125 // CHECK-DAG: Return [ [[Const4]] ]
David Brazdilee690a32014-12-01 17:04:16 +0000126
127 public static int IntSubtraction() {
128 int a, b, c;
David Brazdil4846d132015-01-15 19:07:08 +0000129 a = 6;
David Brazdilee690a32014-12-01 17:04:16 +0000130 b = 2;
131 c = a - b;
132 return c;
133 }
134
135 /**
136 * Tiny three-register program exercising long constant folding
137 * on addition.
138 */
139
David Brazdil4846d132015-01-15 19:07:08 +0000140 // CHECK-START: long Main.LongAddition() constant_folding (before)
David Brazdilbe0cc082014-12-31 11:49:30 +0000141 // CHECK-DAG: [[Const1:j\d+]] LongConstant 1
142 // CHECK-DAG: [[Const2:j\d+]] LongConstant 2
143 // CHECK-DAG: [[Add:j\d+]] Add [ [[Const1]] [[Const2]] ]
144 // CHECK-DAG: Return [ [[Add]] ]
David Brazdilee690a32014-12-01 17:04:16 +0000145
David Brazdil4846d132015-01-15 19:07:08 +0000146 // CHECK-START: long Main.LongAddition() constant_folding (after)
David Brazdilbe0cc082014-12-31 11:49:30 +0000147 // CHECK-DAG: [[Const3:j\d+]] LongConstant 3
148 // CHECK-DAG: Return [ [[Const3]] ]
David Brazdilee690a32014-12-01 17:04:16 +0000149
150 public static long LongAddition() {
151 long a, b, c;
152 a = 1L;
153 b = 2L;
154 c = a + b;
155 return c;
156 }
157
158 /**
159 * Tiny three-register program exercising long constant folding
160 * on subtraction.
161 */
162
David Brazdil4846d132015-01-15 19:07:08 +0000163 // CHECK-START: long Main.LongSubtraction() constant_folding (before)
164 // CHECK-DAG: [[Const6:j\d+]] LongConstant 6
David Brazdilbe0cc082014-12-31 11:49:30 +0000165 // CHECK-DAG: [[Const2:j\d+]] LongConstant 2
David Brazdil4846d132015-01-15 19:07:08 +0000166 // CHECK-DAG: [[Sub:j\d+]] Sub [ [[Const6]] [[Const2]] ]
David Brazdilbe0cc082014-12-31 11:49:30 +0000167 // CHECK-DAG: Return [ [[Sub]] ]
David Brazdilee690a32014-12-01 17:04:16 +0000168
David Brazdil4846d132015-01-15 19:07:08 +0000169 // CHECK-START: long Main.LongSubtraction() constant_folding (after)
170 // CHECK-DAG: [[Const4:j\d+]] LongConstant 4
171 // CHECK-DAG: Return [ [[Const4]] ]
David Brazdilee690a32014-12-01 17:04:16 +0000172
173 public static long LongSubtraction() {
174 long a, b, c;
David Brazdil4846d132015-01-15 19:07:08 +0000175 a = 6L;
David Brazdilee690a32014-12-01 17:04:16 +0000176 b = 2L;
177 c = a - b;
178 return c;
179 }
180
181 /**
182 * Three-register program with a constant (static) condition.
183 */
184
David Brazdil4846d132015-01-15 19:07:08 +0000185 // CHECK-START: int Main.StaticCondition() constant_folding (before)
186 // CHECK-DAG: [[Const7:i\d+]] IntConstant 7
David Brazdilbe0cc082014-12-31 11:49:30 +0000187 // CHECK-DAG: [[Const2:i\d+]] IntConstant 2
David Brazdil4846d132015-01-15 19:07:08 +0000188 // CHECK-DAG: [[Cond:z\d+]] GreaterThanOrEqual [ [[Const7]] [[Const2]] ]
David Brazdilbe0cc082014-12-31 11:49:30 +0000189 // CHECK-DAG: If [ [[Cond]] ]
David Brazdilee690a32014-12-01 17:04:16 +0000190
David Brazdil4846d132015-01-15 19:07:08 +0000191 // CHECK-START: int Main.StaticCondition() constant_folding (after)
David Brazdilbe0cc082014-12-31 11:49:30 +0000192 // CHECK-DAG: [[Const1:i\d+]] IntConstant 1
193 // CHECK-DAG: If [ [[Const1]] ]
David Brazdilee690a32014-12-01 17:04:16 +0000194
195 public static int StaticCondition() {
196 int a, b, c;
David Brazdil4846d132015-01-15 19:07:08 +0000197 a = 7;
David Brazdilee690a32014-12-01 17:04:16 +0000198 b = 2;
199 if (a < b)
200 c = a + b;
201 else
202 c = a - b;
203 return c;
204 }
205
206 /**
207 * Four-variable program with jumps leading to the creation of many
208 * blocks.
209 *
210 * The intent of this test is to ensure that all constant expressions
211 * are actually evaluated at compile-time, thanks to the reverse
212 * (forward) post-order traversal of the the dominator tree.
213 */
214
David Brazdil4846d132015-01-15 19:07:08 +0000215 // CHECK-START: int Main.JumpsAndConditionals(boolean) constant_folding (before)
David Brazdilbe0cc082014-12-31 11:49:30 +0000216 // CHECK-DAG: [[Const2:i\d+]] IntConstant 2
217 // CHECK-DAG: [[Const5:i\d+]] IntConstant 5
218 // CHECK-DAG: [[Add:i\d+]] Add [ [[Const5]] [[Const2]] ]
219 // CHECK-DAG: [[Sub:i\d+]] Sub [ [[Const5]] [[Const2]] ]
220 // CHECK-DAG: [[Phi:i\d+]] Phi [ [[Add]] [[Sub]] ]
221 // CHECK-DAG: Return [ [[Phi]] ]
David Brazdilee690a32014-12-01 17:04:16 +0000222
David Brazdil4846d132015-01-15 19:07:08 +0000223 // CHECK-START: int Main.JumpsAndConditionals(boolean) constant_folding (after)
David Brazdilbe0cc082014-12-31 11:49:30 +0000224 // CHECK-DAG: [[Const3:i\d+]] IntConstant 3
225 // CHECK-DAG: [[Const7:i\d+]] IntConstant 7
226 // CHECK-DAG: [[Phi:i\d+]] Phi [ [[Const7]] [[Const3]] ]
227 // CHECK-DAG: Return [ [[Phi]] ]
David Brazdilee690a32014-12-01 17:04:16 +0000228
229 public static int JumpsAndConditionals(boolean cond) {
230 int a, b, c;
231 a = 5;
232 b = 2;
233 if (cond)
234 c = a + b;
235 else
236 c = a - b;
237 return c;
238 }
David Brazdil4846d132015-01-15 19:07:08 +0000239
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000240 /**
241 * Test optimizations of arithmetic identities yielding a constant result.
242 */
243
244 // CHECK-START: int Main.And0(int) constant_folding (before)
245 // CHECK-DAG: [[Arg:i\d+]] ParameterValue
246 // CHECK-DAG: [[Const0:i\d+]] IntConstant 0
247 // CHECK-DAG: [[And:i\d+]] And [ [[Arg]] [[Const0]] ]
248 // CHECK-DAG: Return [ [[And]] ]
249
250 // CHECK-START: int Main.And0(int) constant_folding (after)
251 // CHECK-DAG: [[Arg:i\d+]] ParameterValue
252 // CHECK-DAG: [[Const0:i\d+]] IntConstant 0
253 // CHECK-NOT: And
254 // CHECK-DAG: Return [ [[Const0]] ]
255
256 public static int And0(int arg) {
257 return arg & 0;
258 }
259
260 // CHECK-START: long Main.Mul0(long) constant_folding (before)
261 // CHECK-DAG: [[Arg:j\d+]] ParameterValue
262 // CHECK-DAG: [[Const0:j\d+]] LongConstant 0
263 // CHECK-DAG: [[Mul:j\d+]] Mul [ [[Arg]] [[Const0]] ]
264 // CHECK-DAG: Return [ [[Mul]] ]
265
266 // CHECK-START: long Main.Mul0(long) constant_folding (after)
267 // CHECK-DAG: [[Arg:j\d+]] ParameterValue
268 // CHECK-DAG: [[Const0:j\d+]] LongConstant 0
269 // CHECK-NOT: Mul
270 // CHECK-DAG: Return [ [[Const0]] ]
271
272 public static long Mul0(long arg) {
273 return arg * 0;
274 }
275
276 // CHECK-START: int Main.OrAllOnes(int) constant_folding (before)
277 // CHECK-DAG: [[Arg:i\d+]] ParameterValue
278 // CHECK-DAG: [[ConstF:i\d+]] IntConstant -1
279 // CHECK-DAG: [[Or:i\d+]] Or [ [[Arg]] [[ConstF]] ]
280 // CHECK-DAG: Return [ [[Or]] ]
281
282 // CHECK-START: int Main.OrAllOnes(int) constant_folding (after)
283 // CHECK-DAG: [[ConstF:i\d+]] IntConstant -1
284 // CHECK-NOT: Or
285 // CHECK-DAG: Return [ [[ConstF]] ]
286
287 public static int OrAllOnes(int arg) {
288 return arg | -1;
289 }
290
291 // CHECK-START: long Main.Rem0(long) constant_folding (before)
292 // CHECK-DAG: [[Arg:j\d+]] ParameterValue
293 // CHECK-DAG: [[Const0:j\d+]] LongConstant 0
294 // CHECK-DAG: [[DivZeroCheck:j\d+]] DivZeroCheck [ [[Arg]] ]
295 // CHECK-DAG: [[Rem:j\d+]] Rem [ [[Const0]] [[DivZeroCheck]] ]
296 // CHECK-DAG: Return [ [[Rem]] ]
297
298 // CHECK-START: long Main.Rem0(long) constant_folding (after)
299 // CHECK-DAG: [[Const0:j\d+]] LongConstant 0
300 // CHECK-NOT: Rem
301 // CHECK-DAG: Return [ [[Const0]] ]
302
303 public static long Rem0(long arg) {
304 return 0 % arg;
305 }
306
307 // CHECK-START: int Main.Rem1(int) constant_folding (before)
308 // CHECK-DAG: [[Arg:i\d+]] ParameterValue
309 // CHECK-DAG: [[Const1:i\d+]] IntConstant 1
310 // CHECK-DAG: [[Rem:i\d+]] Rem [ [[Arg]] [[Const1]] ]
311 // CHECK-DAG: Return [ [[Rem]] ]
312
313 // CHECK-START: int Main.Rem1(int) constant_folding (after)
314 // CHECK-DAG: [[Const0:i\d+]] IntConstant 0
315 // CHECK-NOT: Rem
316 // CHECK-DAG: Return [ [[Const0]] ]
317
318 public static int Rem1(int arg) {
319 return arg % 1;
320 }
321
322 // CHECK-START: long Main.RemN1(long) constant_folding (before)
323 // CHECK-DAG: [[Arg:j\d+]] ParameterValue
324 // CHECK-DAG: [[ConstN1:j\d+]] LongConstant -1
325 // CHECK-DAG: [[DivZeroCheck:j\d+]] DivZeroCheck [ [[Arg]] ]
326 // CHECK-DAG: [[Rem:j\d+]] Rem [ [[Arg]] [[DivZeroCheck]] ]
327 // CHECK-DAG: Return [ [[Rem]] ]
328
329 // CHECK-START: long Main.RemN1(long) constant_folding (after)
330 // CHECK-DAG: [[Const0:j\d+]] LongConstant 0
331 // CHECK-NOT: Rem
332 // CHECK-DAG: Return [ [[Const0]] ]
333
334 public static long RemN1(long arg) {
335 return arg % -1;
336 }
337
338 // CHECK-START: int Main.Shl0(int) constant_folding (before)
339 // CHECK-DAG: [[Arg:i\d+]] ParameterValue
340 // CHECK-DAG: [[Const0:i\d+]] IntConstant 0
341 // CHECK-DAG: [[Shl:i\d+]] Shl [ [[Const0]] [[Arg]] ]
342 // CHECK-DAG: Return [ [[Shl]] ]
343
344 // CHECK-START: int Main.Shl0(int) constant_folding (after)
345 // CHECK-DAG: [[Arg:i\d+]] ParameterValue
346 // CHECK-DAG: [[Const0:i\d+]] IntConstant 0
347 // CHECK-NOT: Shl
348 // CHECK-DAG: Return [ [[Const0]] ]
349
350 public static int Shl0(int arg) {
351 return 0 << arg;
352 }
353
354 // CHECK-START: long Main.Shr0(int) constant_folding (before)
355 // CHECK-DAG: [[Arg:i\d+]] ParameterValue
356 // CHECK-DAG: [[Const0:j\d+]] LongConstant 0
357 // CHECK-DAG: [[Shr:j\d+]] Shr [ [[Const0]] [[Arg]] ]
358 // CHECK-DAG: Return [ [[Shr]] ]
359
360 // CHECK-START: long Main.Shr0(int) constant_folding (after)
361 // CHECK-DAG: [[Arg:i\d+]] ParameterValue
362 // CHECK-DAG: [[Const0:j\d+]] LongConstant 0
363 // CHECK-NOT: Shr
364 // CHECK-DAG: Return [ [[Const0]] ]
365
366 public static long Shr0(int arg) {
367 return (long)0 >> arg;
368 }
369
370 // CHECK-START: long Main.SubSameLong(long) constant_folding (before)
371 // CHECK-DAG: [[Arg:j\d+]] ParameterValue
372 // CHECK-DAG: [[Sub:j\d+]] Sub [ [[Arg]] [[Arg]] ]
373 // CHECK-DAG: Return [ [[Sub]] ]
374
375 // CHECK-START: long Main.SubSameLong(long) constant_folding (after)
376 // CHECK-DAG: [[Arg:j\d+]] ParameterValue
377 // CHECK-DAG: [[Const0:j\d+]] LongConstant 0
378 // CHECK-NOT: Sub
379 // CHECK-DAG: Return [ [[Const0]] ]
380
381 public static long SubSameLong(long arg) {
382 return arg - arg;
383 }
384
385 // CHECK-START: int Main.UShr0(int) constant_folding (before)
386 // CHECK-DAG: [[Arg:i\d+]] ParameterValue
387 // CHECK-DAG: [[Const0:i\d+]] IntConstant 0
388 // CHECK-DAG: [[UShr:i\d+]] UShr [ [[Const0]] [[Arg]] ]
389 // CHECK-DAG: Return [ [[UShr]] ]
390
391 // CHECK-START: int Main.UShr0(int) constant_folding (after)
392 // CHECK-DAG: [[Arg:i\d+]] ParameterValue
393 // CHECK-DAG: [[Const0:i\d+]] IntConstant 0
394 // CHECK-NOT: UShr
395 // CHECK-DAG: Return [ [[Const0]] ]
396
397 public static int UShr0(int arg) {
398 return 0 >>> arg;
399 }
400
401 // CHECK-START: int Main.XorSameInt(int) constant_folding (before)
402 // CHECK-DAG: [[Arg:i\d+]] ParameterValue
403 // CHECK-DAG: [[Xor:i\d+]] Xor [ [[Arg]] [[Arg]] ]
404 // CHECK-DAG: Return [ [[Xor]] ]
405
406 // CHECK-START: int Main.XorSameInt(int) constant_folding (after)
407 // CHECK-DAG: [[Arg:i\d+]] ParameterValue
408 // CHECK-DAG: [[Const0:i\d+]] IntConstant 0
409 // CHECK-NOT: Xor
410 // CHECK-DAG: Return [ [[Const0]] ]
411
412 public static int XorSameInt(int arg) {
413 return arg ^ arg;
414 }
415
Roland Levillain3b55ebb2015-05-08 13:13:19 +0100416 // CHECK-START: boolean Main.CmpFloatGreaterThanNaN(float) constant_folding (before)
417 // CHECK-DAG: [[Arg:f\d+]] ParameterValue
418 // CHECK-DAG: [[ConstNan:f\d+]] FloatConstant nan
419 // CHECK-DAG: [[Const0:i\d+]] IntConstant 0
420 // CHECK-DAG: IntConstant 1
421 // CHECK-DAG: [[Cmp:i\d+]] Compare [ [[Arg]] [[ConstNan]] ]
422 // CHECK-DAG: [[Le:z\d+]] LessThanOrEqual [ [[Cmp]] [[Const0]] ]
423 // CHECK-DAG: If [ [[Le]] ]
424
425 // CHECK-START: boolean Main.CmpFloatGreaterThanNaN(float) constant_folding (after)
426 // CHECK-DAG: ParameterValue
427 // CHECK-DAG: FloatConstant nan
428 // CHECK-DAG: IntConstant 0
429 // CHECK-DAG: [[Const1:i\d+]] IntConstant 1
430 // CHECK-DAG: If [ [[Const1]] ]
431
432 // CHECK-START: boolean Main.CmpFloatGreaterThanNaN(float) constant_folding (after)
433 // CHECK-NOT: Compare
434 // CHECK-NOT: LessThanOrEqual
435
436 public static boolean CmpFloatGreaterThanNaN(float arg) {
437 return arg > Float.NaN;
438 }
439
440 // CHECK-START: boolean Main.CmpDoubleLessThanNaN(double) constant_folding (before)
441 // CHECK-DAG: [[Arg:d\d+]] ParameterValue
442 // CHECK-DAG: [[ConstNan:d\d+]] DoubleConstant nan
443 // CHECK-DAG: [[Const0:i\d+]] IntConstant 0
444 // CHECK-DAG: IntConstant 1
445 // CHECK-DAG: [[Cmp:i\d+]] Compare [ [[Arg]] [[ConstNan]] ]
446 // CHECK-DAG: [[Ge:z\d+]] GreaterThanOrEqual [ [[Cmp]] [[Const0]] ]
447 // CHECK-DAG: If [ [[Ge]] ]
448
449 // CHECK-START: boolean Main.CmpDoubleLessThanNaN(double) constant_folding (after)
450 // CHECK-DAG: ParameterValue
451 // CHECK-DAG: DoubleConstant nan
452 // CHECK-DAG: IntConstant 0
453 // CHECK-DAG: [[Const1:i\d+]] IntConstant 1
454 // CHECK-DAG: If [ [[Const1]] ]
455
456 // CHECK-START: boolean Main.CmpDoubleLessThanNaN(double) constant_folding (after)
457 // CHECK-NOT: Compare
458 // CHECK-NOT: GreaterThanOrEqual
459
460 public static boolean CmpDoubleLessThanNaN(double arg) {
461 return arg < Double.NaN;
462 }
463
David Brazdil4846d132015-01-15 19:07:08 +0000464 public static void main(String[] args) {
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +0000465 assertIntEquals(IntNegation(), -42);
466 assertIntEquals(IntAddition1(), 3);
467 assertIntEquals(IntAddition2(), 14);
468 assertIntEquals(IntSubtraction(), 4);
469 assertLongEquals(LongAddition(), 3L);
470 assertLongEquals(LongSubtraction(), 4L);
471 assertIntEquals(StaticCondition(), 5);
472 assertIntEquals(JumpsAndConditionals(true), 7);
473 assertIntEquals(JumpsAndConditionals(false), 3);
Roland Levillain3b55ebb2015-05-08 13:13:19 +0100474 int arbitrary = 123456; // Value chosen arbitrarily.
475 assertIntEquals(And0(arbitrary), 0);
476 assertLongEquals(Mul0(arbitrary), 0);
477 assertIntEquals(OrAllOnes(arbitrary), -1);
478 assertLongEquals(Rem0(arbitrary), 0);
479 assertIntEquals(Rem1(arbitrary), 0);
480 assertLongEquals(RemN1(arbitrary), 0);
481 assertIntEquals(Shl0(arbitrary), 0);
482 assertLongEquals(Shr0(arbitrary), 0);
483 assertLongEquals(SubSameLong(arbitrary), 0);
484 assertIntEquals(UShr0(arbitrary), 0);
485 assertIntEquals(XorSameInt(arbitrary), 0);
486 assertFalse(CmpFloatGreaterThanNaN(arbitrary));
487 assertFalse(CmpDoubleLessThanNaN(arbitrary));
David Brazdil4846d132015-01-15 19:07:08 +0000488 }
David Brazdilee690a32014-12-01 17:04:16 +0000489}