blob: 64180d5273c441b888060f0721d8e31d97606336 [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
Roland Levillain31dd3d62016-02-16 12:21:02 +000017import java.lang.reflect.Method;
18
David Brazdil4846d132015-01-15 19:07:08 +000019public class Main {
David Brazdilee690a32014-12-01 17:04:16 +000020
Roland Levillain31dd3d62016-02-16 12:21:02 +000021 // Workaround for b/18051191.
22 class InnerClass {}
23
Roland Levillain3b55ebb2015-05-08 13:13:19 +010024 public static void assertFalse(boolean condition) {
25 if (condition) {
26 throw new Error();
27 }
28 }
29
Vladimir Markoa341f352016-08-31 12:18:20 +010030 public static void assertTrue(boolean condition) {
31 if (!condition) {
32 throw new Error();
33 }
34 }
35
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +000036 public static void assertIntEquals(int expected, int result) {
37 if (expected != result) {
38 throw new Error("Expected: " + expected + ", found: " + result);
39 }
40 }
41
42 public static void assertLongEquals(long expected, long result) {
43 if (expected != result) {
44 throw new Error("Expected: " + expected + ", found: " + result);
45 }
46 }
47
Mark Mendelle82549b2015-05-06 10:55:34 -040048 public static void assertFloatEquals(float expected, float result) {
49 if (expected != result) {
50 throw new Error("Expected: " + expected + ", found: " + result);
51 }
52 }
53
54 public static void assertDoubleEquals(double expected, double result) {
55 if (expected != result) {
56 throw new Error("Expected: " + expected + ", found: " + result);
57 }
58 }
59
David Brazdilf02c3cf2016-02-29 09:14:51 +000060 private static int $inline$int(int x) {
61 return x;
62 }
63
64 private static long $inline$long(long x) {
65 return x;
66 }
67
68 private static float $inline$float(float x) {
69 return x;
70 }
71
72 private static double $inline$double(double x) {
73 return x;
74 }
Roland Levillainb65eb502015-07-23 12:11:42 +010075
Roland Levillain31dd3d62016-02-16 12:21:02 +000076 // Wrappers around methods located in file TestCmp.smali.
77
78 public int smaliCmpLongConstants() throws Exception {
79 Method m = testCmp.getMethod("$opt$CmpLongConstants");
80 return (Integer)m.invoke(null);
81 }
82 public int smaliCmpGtFloatConstants() throws Exception {
83 Method m = testCmp.getMethod("$opt$CmpGtFloatConstants");
84 return (Integer)m.invoke(null);
85 }
86 public int smaliCmpLtFloatConstants() throws Exception {
87 Method m = testCmp.getMethod("$opt$CmpLtFloatConstants");
88 return (Integer)m.invoke(null);
89 }
90 public int smaliCmpGtDoubleConstants() throws Exception {
91 Method m = testCmp.getMethod("$opt$CmpGtDoubleConstants");
92 return (Integer)m.invoke(null);
93 }
94 public int smaliCmpLtDoubleConstants() throws Exception {
95 Method m = testCmp.getMethod("$opt$CmpLtDoubleConstants");
96 return (Integer)m.invoke(null);
97 }
98
99 public int smaliCmpLongSameConstant() throws Exception {
100 Method m = testCmp.getMethod("$opt$CmpLongSameConstant");
101 return (Integer)m.invoke(null);
102 }
103 public int smaliCmpGtFloatSameConstant() throws Exception {
104 Method m = testCmp.getMethod("$opt$CmpGtFloatSameConstant");
105 return (Integer)m.invoke(null);
106 }
107 public int smaliCmpLtFloatSameConstant() throws Exception {
108 Method m = testCmp.getMethod("$opt$CmpLtFloatSameConstant");
109 return (Integer)m.invoke(null);
110 }
111 public int smaliCmpGtDoubleSameConstant() throws Exception {
112 Method m = testCmp.getMethod("$opt$CmpGtDoubleSameConstant");
113 return (Integer)m.invoke(null);
114 }
115 public int smaliCmpLtDoubleSameConstant() throws Exception {
116 Method m = testCmp.getMethod("$opt$CmpLtDoubleSameConstant");
117 return (Integer)m.invoke(null);
118 }
119
120 public int smaliCmpGtFloatConstantWithNaN() throws Exception {
121 Method m = testCmp.getMethod("$opt$CmpGtFloatConstantWithNaN");
122 return (Integer)m.invoke(null);
123 }
124 public int smaliCmpLtFloatConstantWithNaN() throws Exception {
125 Method m = testCmp.getMethod("$opt$CmpLtFloatConstantWithNaN");
126 return (Integer)m.invoke(null);
127 }
128 public int smaliCmpGtDoubleConstantWithNaN() throws Exception {
129 Method m = testCmp.getMethod("$opt$CmpGtDoubleConstantWithNaN");
130 return (Integer)m.invoke(null);
131 }
132 public int smaliCmpLtDoubleConstantWithNaN() throws Exception {
133 Method m = testCmp.getMethod("$opt$CmpLtDoubleConstantWithNaN");
134 return (Integer)m.invoke(null);
135 }
136
137
David Brazdilee690a32014-12-01 17:04:16 +0000138 /**
Roland Levillainb65eb502015-07-23 12:11:42 +0100139 * Exercise constant folding on negation.
David Brazdilee690a32014-12-01 17:04:16 +0000140 */
141
David Brazdila06d66a2015-05-28 11:14:54 +0100142 /// CHECK-START: int Main.IntNegation() constant_folding (before)
143 /// CHECK-DAG: <<Const42:i\d+>> IntConstant 42
144 /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Const42>>]
145 /// CHECK-DAG: Return [<<Neg>>]
David Brazdilee690a32014-12-01 17:04:16 +0000146
David Brazdila06d66a2015-05-28 11:14:54 +0100147 /// CHECK-START: int Main.IntNegation() constant_folding (after)
148 /// CHECK-DAG: <<ConstN42:i\d+>> IntConstant -42
149 /// CHECK-DAG: Return [<<ConstN42>>]
David Brazdilee690a32014-12-01 17:04:16 +0000150
Roland Levillainb65eb502015-07-23 12:11:42 +0100151 /// CHECK-START: int Main.IntNegation() constant_folding (after)
152 /// CHECK-NOT: Neg
153
David Brazdilee690a32014-12-01 17:04:16 +0000154 public static int IntNegation() {
155 int x, y;
156 x = 42;
157 y = -x;
158 return y;
159 }
160
Roland Levillainc90bc7c2014-12-11 12:14:33 +0000161 /// CHECK-START: long Main.LongNegation() constant_folding (before)
162 /// CHECK-DAG: <<Const42:j\d+>> LongConstant 42
163 /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Const42>>]
164 /// CHECK-DAG: Return [<<Neg>>]
165
166 /// CHECK-START: long Main.LongNegation() constant_folding (after)
167 /// CHECK-DAG: <<ConstN42:j\d+>> LongConstant -42
168 /// CHECK-DAG: Return [<<ConstN42>>]
169
170 /// CHECK-START: long Main.LongNegation() constant_folding (after)
171 /// CHECK-NOT: Neg
172
173 public static long LongNegation() {
174 long x, y;
175 x = 42L;
176 y = -x;
177 return y;
178 }
179
Roland Levillain31dd3d62016-02-16 12:21:02 +0000180 /// CHECK-START: float Main.FloatNegation() constant_folding (before)
181 /// CHECK-DAG: <<Const42:f\d+>> FloatConstant 42
182 /// CHECK-DAG: <<Neg:f\d+>> Neg [<<Const42>>]
183 /// CHECK-DAG: Return [<<Neg>>]
184
185 /// CHECK-START: float Main.FloatNegation() constant_folding (after)
186 /// CHECK-DAG: <<ConstN42:f\d+>> FloatConstant -42
187 /// CHECK-DAG: Return [<<ConstN42>>]
188
189 /// CHECK-START: float Main.FloatNegation() constant_folding (after)
190 /// CHECK-NOT: Neg
191
192 public static float FloatNegation() {
193 float x, y;
194 x = 42F;
195 y = -x;
196 return y;
197 }
198
199 /// CHECK-START: double Main.DoubleNegation() constant_folding (before)
200 /// CHECK-DAG: <<Const42:d\d+>> DoubleConstant 42
201 /// CHECK-DAG: <<Neg:d\d+>> Neg [<<Const42>>]
202 /// CHECK-DAG: Return [<<Neg>>]
203
204 /// CHECK-START: double Main.DoubleNegation() constant_folding (after)
205 /// CHECK-DAG: <<ConstN42:d\d+>> DoubleConstant -42
206 /// CHECK-DAG: Return [<<ConstN42>>]
207
208 /// CHECK-START: double Main.DoubleNegation() constant_folding (after)
209 /// CHECK-NOT: Neg
210
211 public static double DoubleNegation() {
212 double x, y;
213 x = 42D;
214 y = -x;
215 return y;
216 }
217
David Brazdilee690a32014-12-01 17:04:16 +0000218 /**
Roland Levillainb65eb502015-07-23 12:11:42 +0100219 * Exercise constant folding on addition.
David Brazdilee690a32014-12-01 17:04:16 +0000220 */
221
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700222 /// CHECK-START: int Main.IntAddition1() constant_folding$after_inlining (before)
David Brazdila06d66a2015-05-28 11:14:54 +0100223 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
224 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
225 /// CHECK-DAG: <<Add:i\d+>> Add [<<Const1>>,<<Const2>>]
226 /// CHECK-DAG: Return [<<Add>>]
David Brazdilee690a32014-12-01 17:04:16 +0000227
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700228 /// CHECK-START: int Main.IntAddition1() constant_folding$after_inlining (after)
David Brazdila06d66a2015-05-28 11:14:54 +0100229 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3
230 /// CHECK-DAG: Return [<<Const3>>]
David Brazdilee690a32014-12-01 17:04:16 +0000231
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700232 /// CHECK-START: int Main.IntAddition1() constant_folding$after_inlining (after)
Roland Levillainb65eb502015-07-23 12:11:42 +0100233 /// CHECK-NOT: Add
234
David Brazdilee690a32014-12-01 17:04:16 +0000235 public static int IntAddition1() {
236 int a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000237 a = $inline$int(1);
238 b = $inline$int(2);
David Brazdilee690a32014-12-01 17:04:16 +0000239 c = a + b;
240 return c;
241 }
242
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700243 /// CHECK-START: int Main.IntAddition2() constant_folding$after_inlining (before)
David Brazdila06d66a2015-05-28 11:14:54 +0100244 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
245 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
246 /// CHECK-DAG: <<Const5:i\d+>> IntConstant 5
247 /// CHECK-DAG: <<Const6:i\d+>> IntConstant 6
248 /// CHECK-DAG: <<Add1:i\d+>> Add [<<Const1>>,<<Const2>>]
David Brazdilf02c3cf2016-02-29 09:14:51 +0000249 /// CHECK-DAG: <<Add2:i\d+>> Add [<<Const5>>,<<Const6>>]
250 /// CHECK-DAG: <<Add3:i\d+>> Add [<<Add1>>,<<Add2>>]
David Brazdila06d66a2015-05-28 11:14:54 +0100251 /// CHECK-DAG: Return [<<Add3>>]
David Brazdilee690a32014-12-01 17:04:16 +0000252
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700253 /// CHECK-START: int Main.IntAddition2() constant_folding$after_inlining (after)
David Brazdila06d66a2015-05-28 11:14:54 +0100254 /// CHECK-DAG: <<Const14:i\d+>> IntConstant 14
255 /// CHECK-DAG: Return [<<Const14>>]
David Brazdilee690a32014-12-01 17:04:16 +0000256
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700257 /// CHECK-START: int Main.IntAddition2() constant_folding$after_inlining (after)
Roland Levillainb65eb502015-07-23 12:11:42 +0100258 /// CHECK-NOT: Add
259
David Brazdilee690a32014-12-01 17:04:16 +0000260 public static int IntAddition2() {
261 int a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000262 a = $inline$int(1);
263 b = $inline$int(2);
David Brazdilee690a32014-12-01 17:04:16 +0000264 a += b;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000265 b = $inline$int(5);
266 c = $inline$int(6);
David Brazdilee690a32014-12-01 17:04:16 +0000267 b += c;
268 c = a + b;
269 return c;
270 }
271
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700272 /// CHECK-START: long Main.LongAddition() constant_folding$after_inlining (before)
Roland Levillainb65eb502015-07-23 12:11:42 +0100273 /// CHECK-DAG: <<Const1:j\d+>> LongConstant 1
274 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2
275 /// CHECK-DAG: <<Add:j\d+>> Add [<<Const1>>,<<Const2>>]
276 /// CHECK-DAG: Return [<<Add>>]
277
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700278 /// CHECK-START: long Main.LongAddition() constant_folding$after_inlining (after)
Roland Levillainb65eb502015-07-23 12:11:42 +0100279 /// CHECK-DAG: <<Const3:j\d+>> LongConstant 3
280 /// CHECK-DAG: Return [<<Const3>>]
281
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700282 /// CHECK-START: long Main.LongAddition() constant_folding$after_inlining (after)
Roland Levillainb65eb502015-07-23 12:11:42 +0100283 /// CHECK-NOT: Add
284
285 public static long LongAddition() {
286 long a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000287 a = $inline$long(1L);
288 b = $inline$long(2L);
Roland Levillainb65eb502015-07-23 12:11:42 +0100289 c = a + b;
290 return c;
291 }
292
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700293 /// CHECK-START: float Main.FloatAddition() constant_folding$after_inlining (before)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000294 /// CHECK-DAG: <<Const1:f\d+>> FloatConstant 1
295 /// CHECK-DAG: <<Const2:f\d+>> FloatConstant 2
296 /// CHECK-DAG: <<Add:f\d+>> Add [<<Const1>>,<<Const2>>]
297 /// CHECK-DAG: Return [<<Add>>]
298
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700299 /// CHECK-START: float Main.FloatAddition() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000300 /// CHECK-DAG: <<Const3:f\d+>> FloatConstant 3
301 /// CHECK-DAG: Return [<<Const3>>]
302
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700303 /// CHECK-START: float Main.FloatAddition() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000304 /// CHECK-NOT: Add
305
306 public static float FloatAddition() {
307 float a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000308 a = $inline$float(1F);
309 b = $inline$float(2F);
Roland Levillain31dd3d62016-02-16 12:21:02 +0000310 c = a + b;
311 return c;
312 }
313
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700314 /// CHECK-START: double Main.DoubleAddition() constant_folding$after_inlining (before)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000315 /// CHECK-DAG: <<Const1:d\d+>> DoubleConstant 1
316 /// CHECK-DAG: <<Const2:d\d+>> DoubleConstant 2
317 /// CHECK-DAG: <<Add:d\d+>> Add [<<Const1>>,<<Const2>>]
318 /// CHECK-DAG: Return [<<Add>>]
319
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700320 /// CHECK-START: double Main.DoubleAddition() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000321 /// CHECK-DAG: <<Const3:d\d+>> DoubleConstant 3
322 /// CHECK-DAG: Return [<<Const3>>]
323
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700324 /// CHECK-START: double Main.DoubleAddition() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000325 /// CHECK-NOT: Add
326
327 public static double DoubleAddition() {
328 double a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000329 a = $inline$double(1D);
330 b = $inline$double(2D);
Roland Levillain31dd3d62016-02-16 12:21:02 +0000331 c = a + b;
332 return c;
333 }
334
Roland Levillainb65eb502015-07-23 12:11:42 +0100335
David Brazdilee690a32014-12-01 17:04:16 +0000336 /**
Roland Levillainb65eb502015-07-23 12:11:42 +0100337 * Exercise constant folding on subtraction.
David Brazdilee690a32014-12-01 17:04:16 +0000338 */
339
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700340 /// CHECK-START: int Main.IntSubtraction() constant_folding$after_inlining (before)
David Brazdila06d66a2015-05-28 11:14:54 +0100341 /// CHECK-DAG: <<Const6:i\d+>> IntConstant 6
342 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
343 /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Const6>>,<<Const2>>]
344 /// CHECK-DAG: Return [<<Sub>>]
David Brazdilee690a32014-12-01 17:04:16 +0000345
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700346 /// CHECK-START: int Main.IntSubtraction() constant_folding$after_inlining (after)
David Brazdila06d66a2015-05-28 11:14:54 +0100347 /// CHECK-DAG: <<Const4:i\d+>> IntConstant 4
348 /// CHECK-DAG: Return [<<Const4>>]
David Brazdilee690a32014-12-01 17:04:16 +0000349
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700350 /// CHECK-START: int Main.IntSubtraction() constant_folding$after_inlining (after)
Roland Levillainb65eb502015-07-23 12:11:42 +0100351 /// CHECK-NOT: Sub
352
David Brazdilee690a32014-12-01 17:04:16 +0000353 public static int IntSubtraction() {
354 int a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000355 a = $inline$int(6);
356 b = $inline$int(2);
David Brazdilee690a32014-12-01 17:04:16 +0000357 c = a - b;
358 return c;
359 }
360
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700361 /// CHECK-START: long Main.LongSubtraction() constant_folding$after_inlining (before)
David Brazdila06d66a2015-05-28 11:14:54 +0100362 /// CHECK-DAG: <<Const6:j\d+>> LongConstant 6
363 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2
364 /// CHECK-DAG: <<Sub:j\d+>> Sub [<<Const6>>,<<Const2>>]
365 /// CHECK-DAG: Return [<<Sub>>]
David Brazdilee690a32014-12-01 17:04:16 +0000366
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700367 /// CHECK-START: long Main.LongSubtraction() constant_folding$after_inlining (after)
David Brazdila06d66a2015-05-28 11:14:54 +0100368 /// CHECK-DAG: <<Const4:j\d+>> LongConstant 4
369 /// CHECK-DAG: Return [<<Const4>>]
David Brazdilee690a32014-12-01 17:04:16 +0000370
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700371 /// CHECK-START: long Main.LongSubtraction() constant_folding$after_inlining (after)
Roland Levillainb65eb502015-07-23 12:11:42 +0100372 /// CHECK-NOT: Sub
373
David Brazdilee690a32014-12-01 17:04:16 +0000374 public static long LongSubtraction() {
375 long a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000376 a = $inline$long(6L);
377 b = $inline$long(2L);
David Brazdilee690a32014-12-01 17:04:16 +0000378 c = a - b;
379 return c;
380 }
381
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700382 /// CHECK-START: float Main.FloatSubtraction() constant_folding$after_inlining (before)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000383 /// CHECK-DAG: <<Const6:f\d+>> FloatConstant 6
384 /// CHECK-DAG: <<Const2:f\d+>> FloatConstant 2
385 /// CHECK-DAG: <<Sub:f\d+>> Sub [<<Const6>>,<<Const2>>]
386 /// CHECK-DAG: Return [<<Sub>>]
387
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700388 /// CHECK-START: float Main.FloatSubtraction() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000389 /// CHECK-DAG: <<Const4:f\d+>> FloatConstant 4
390 /// CHECK-DAG: Return [<<Const4>>]
391
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700392 /// CHECK-START: float Main.FloatSubtraction() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000393 /// CHECK-NOT: Sub
394
395 public static float FloatSubtraction() {
396 float a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000397 a = $inline$float(6F);
398 b = $inline$float(2F);
Roland Levillain31dd3d62016-02-16 12:21:02 +0000399 c = a - b;
400 return c;
401 }
402
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700403 /// CHECK-START: double Main.DoubleSubtraction() constant_folding$after_inlining (before)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000404 /// CHECK-DAG: <<Const6:d\d+>> DoubleConstant 6
405 /// CHECK-DAG: <<Const2:d\d+>> DoubleConstant 2
406 /// CHECK-DAG: <<Sub:d\d+>> Sub [<<Const6>>,<<Const2>>]
407 /// CHECK-DAG: Return [<<Sub>>]
408
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700409 /// CHECK-START: double Main.DoubleSubtraction() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000410 /// CHECK-DAG: <<Const4:d\d+>> DoubleConstant 4
411 /// CHECK-DAG: Return [<<Const4>>]
412
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700413 /// CHECK-START: double Main.DoubleSubtraction() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000414 /// CHECK-NOT: Sub
415
416 public static double DoubleSubtraction() {
417 double a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000418 a = $inline$double(6D);
419 b = $inline$double(2D);
Roland Levillain31dd3d62016-02-16 12:21:02 +0000420 c = a - b;
421 return c;
422 }
423
Roland Levillainb65eb502015-07-23 12:11:42 +0100424
David Brazdilee690a32014-12-01 17:04:16 +0000425 /**
Roland Levillainf7746ad2015-07-22 14:12:01 +0100426 * Exercise constant folding on multiplication.
427 */
428
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700429 /// CHECK-START: int Main.IntMultiplication() constant_folding$after_inlining (before)
Roland Levillainf7746ad2015-07-22 14:12:01 +0100430 /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7
431 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3
432 /// CHECK-DAG: <<Mul:i\d+>> Mul [<<Const7>>,<<Const3>>]
433 /// CHECK-DAG: Return [<<Mul>>]
434
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700435 /// CHECK-START: int Main.IntMultiplication() constant_folding$after_inlining (after)
Roland Levillainf7746ad2015-07-22 14:12:01 +0100436 /// CHECK-DAG: <<Const21:i\d+>> IntConstant 21
437 /// CHECK-DAG: Return [<<Const21>>]
438
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700439 /// CHECK-START: int Main.IntMultiplication() constant_folding$after_inlining (after)
Roland Levillainf7746ad2015-07-22 14:12:01 +0100440 /// CHECK-NOT: Mul
441
442 public static int IntMultiplication() {
443 int a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000444 a = $inline$int(7);
445 b = $inline$int(3);
Roland Levillainf7746ad2015-07-22 14:12:01 +0100446 c = a * b;
447 return c;
448 }
449
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700450 /// CHECK-START: long Main.LongMultiplication() constant_folding$after_inlining (before)
Roland Levillainf7746ad2015-07-22 14:12:01 +0100451 /// CHECK-DAG: <<Const7:j\d+>> LongConstant 7
452 /// CHECK-DAG: <<Const3:j\d+>> LongConstant 3
453 /// CHECK-DAG: <<Mul:j\d+>> Mul [<<Const7>>,<<Const3>>]
454 /// CHECK-DAG: Return [<<Mul>>]
455
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700456 /// CHECK-START: long Main.LongMultiplication() constant_folding$after_inlining (after)
Roland Levillainf7746ad2015-07-22 14:12:01 +0100457 /// CHECK-DAG: <<Const21:j\d+>> LongConstant 21
458 /// CHECK-DAG: Return [<<Const21>>]
459
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700460 /// CHECK-START: long Main.LongMultiplication() constant_folding$after_inlining (after)
Roland Levillainf7746ad2015-07-22 14:12:01 +0100461 /// CHECK-NOT: Mul
462
463 public static long LongMultiplication() {
464 long a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000465 a = $inline$long(7L);
466 b = $inline$long(3L);
Roland Levillainf7746ad2015-07-22 14:12:01 +0100467 c = a * b;
468 return c;
469 }
470
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700471 /// CHECK-START: float Main.FloatMultiplication() constant_folding$after_inlining (before)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000472 /// CHECK-DAG: <<Const7:f\d+>> FloatConstant 7
473 /// CHECK-DAG: <<Const3:f\d+>> FloatConstant 3
474 /// CHECK-DAG: <<Mul:f\d+>> Mul [<<Const7>>,<<Const3>>]
475 /// CHECK-DAG: Return [<<Mul>>]
476
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700477 /// CHECK-START: float Main.FloatMultiplication() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000478 /// CHECK-DAG: <<Const21:f\d+>> FloatConstant 21
479 /// CHECK-DAG: Return [<<Const21>>]
480
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700481 /// CHECK-START: float Main.FloatMultiplication() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000482 /// CHECK-NOT: Mul
483
484 public static float FloatMultiplication() {
485 float a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000486 a = $inline$float(7F);
487 b = $inline$float(3F);
Roland Levillain31dd3d62016-02-16 12:21:02 +0000488 c = a * b;
489 return c;
490 }
491
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700492 /// CHECK-START: double Main.DoubleMultiplication() constant_folding$after_inlining (before)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000493 /// CHECK-DAG: <<Const7:d\d+>> DoubleConstant 7
494 /// CHECK-DAG: <<Const3:d\d+>> DoubleConstant 3
495 /// CHECK-DAG: <<Mul:d\d+>> Mul [<<Const7>>,<<Const3>>]
496 /// CHECK-DAG: Return [<<Mul>>]
497
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700498 /// CHECK-START: double Main.DoubleMultiplication() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000499 /// CHECK-DAG: <<Const21:d\d+>> DoubleConstant 21
500 /// CHECK-DAG: Return [<<Const21>>]
501
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700502 /// CHECK-START: double Main.DoubleMultiplication() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000503 /// CHECK-NOT: Mul
504
505 public static double DoubleMultiplication() {
506 double a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000507 a = $inline$double(7D);
508 b = $inline$double(3D);
Roland Levillain31dd3d62016-02-16 12:21:02 +0000509 c = a * b;
510 return c;
511 }
512
Roland Levillainf7746ad2015-07-22 14:12:01 +0100513
514 /**
515 * Exercise constant folding on division.
516 */
517
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700518 /// CHECK-START: int Main.IntDivision() constant_folding$after_inlining (before)
Roland Levillainf7746ad2015-07-22 14:12:01 +0100519 /// CHECK-DAG: <<Const8:i\d+>> IntConstant 8
520 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3
521 /// CHECK-DAG: <<Div0Chk:i\d+>> DivZeroCheck [<<Const3>>]
522 /// CHECK-DAG: <<Div:i\d+>> Div [<<Const8>>,<<Div0Chk>>]
523 /// CHECK-DAG: Return [<<Div>>]
524
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700525 /// CHECK-START: int Main.IntDivision() constant_folding$after_inlining (after)
Roland Levillainf7746ad2015-07-22 14:12:01 +0100526 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
527 /// CHECK-DAG: Return [<<Const2>>]
528
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700529 /// CHECK-START: int Main.IntDivision() constant_folding$after_inlining (after)
Roland Levillainf7746ad2015-07-22 14:12:01 +0100530 /// CHECK-NOT: DivZeroCheck
531 /// CHECK-NOT: Div
532
533 public static int IntDivision() {
534 int a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000535 a = $inline$int(8);
536 b = $inline$int(3);
Roland Levillainf7746ad2015-07-22 14:12:01 +0100537 c = a / b;
538 return c;
539 }
540
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700541 /// CHECK-START: long Main.LongDivision() constant_folding$after_inlining (before)
Roland Levillainf7746ad2015-07-22 14:12:01 +0100542 /// CHECK-DAG: <<Const8:j\d+>> LongConstant 8
543 /// CHECK-DAG: <<Const3:j\d+>> LongConstant 3
544 /// CHECK-DAG: <<Div0Chk:j\d+>> DivZeroCheck [<<Const3>>]
545 /// CHECK-DAG: <<Div:j\d+>> Div [<<Const8>>,<<Div0Chk>>]
546 /// CHECK-DAG: Return [<<Div>>]
547
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700548 /// CHECK-START: long Main.LongDivision() constant_folding$after_inlining (after)
Roland Levillainf7746ad2015-07-22 14:12:01 +0100549 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2
550 /// CHECK-DAG: Return [<<Const2>>]
551
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700552 /// CHECK-START: long Main.LongDivision() constant_folding$after_inlining (after)
Roland Levillainf7746ad2015-07-22 14:12:01 +0100553 /// CHECK-NOT: DivZeroCheck
554 /// CHECK-NOT: Div
555
556 public static long LongDivision() {
557 long a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000558 a = $inline$long(8L);
559 b = $inline$long(3L);
Roland Levillainf7746ad2015-07-22 14:12:01 +0100560 c = a / b;
561 return c;
562 }
563
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700564 /// CHECK-START: float Main.FloatDivision() constant_folding$after_inlining (before)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000565 /// CHECK-DAG: <<Const8:f\d+>> FloatConstant 8
566 /// CHECK-DAG: <<Const2P5:f\d+>> FloatConstant 2.5
567 /// CHECK-DAG: <<Div:f\d+>> Div [<<Const8>>,<<Const2P5>>]
568 /// CHECK-DAG: Return [<<Div>>]
569
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700570 /// CHECK-START: float Main.FloatDivision() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000571 /// CHECK-DAG: <<Const3P2:f\d+>> FloatConstant 3.2
572 /// CHECK-DAG: Return [<<Const3P2>>]
573
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700574 /// CHECK-START: float Main.FloatDivision() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000575 /// CHECK-NOT: Div
576
577 public static float FloatDivision() {
578 float a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000579 a = $inline$float(8F);
580 b = $inline$float(2.5F);
Roland Levillain31dd3d62016-02-16 12:21:02 +0000581 c = a / b;
582 return c;
583 }
584
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700585 /// CHECK-START: double Main.DoubleDivision() constant_folding$after_inlining (before)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000586 /// CHECK-DAG: <<Const8:d\d+>> DoubleConstant 8
587 /// CHECK-DAG: <<Const2P5:d\d+>> DoubleConstant 2.5
588 /// CHECK-DAG: <<Div:d\d+>> Div [<<Const8>>,<<Const2P5>>]
589 /// CHECK-DAG: Return [<<Div>>]
590
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700591 /// CHECK-START: double Main.DoubleDivision() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000592 /// CHECK-DAG: <<Const3P2:d\d+>> DoubleConstant 3.2
593 /// CHECK-DAG: Return [<<Const3P2>>]
594
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700595 /// CHECK-START: double Main.DoubleDivision() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000596 /// CHECK-NOT: Div
597
598 public static double DoubleDivision() {
599 double a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000600 a = $inline$double(8D);
601 b = $inline$double(2.5D);
Roland Levillain31dd3d62016-02-16 12:21:02 +0000602 c = a / b;
603 return c;
604 }
605
Roland Levillainf7746ad2015-07-22 14:12:01 +0100606
607 /**
608 * Exercise constant folding on remainder.
609 */
610
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700611 /// CHECK-START: int Main.IntRemainder() constant_folding$after_inlining (before)
Roland Levillainf7746ad2015-07-22 14:12:01 +0100612 /// CHECK-DAG: <<Const8:i\d+>> IntConstant 8
613 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3
614 /// CHECK-DAG: <<Div0Chk:i\d+>> DivZeroCheck [<<Const3>>]
615 /// CHECK-DAG: <<Rem:i\d+>> Rem [<<Const8>>,<<Div0Chk>>]
616 /// CHECK-DAG: Return [<<Rem>>]
617
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700618 /// CHECK-START: int Main.IntRemainder() constant_folding$after_inlining (after)
Roland Levillainf7746ad2015-07-22 14:12:01 +0100619 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
620 /// CHECK-DAG: Return [<<Const2>>]
621
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700622 /// CHECK-START: int Main.IntRemainder() constant_folding$after_inlining (after)
Roland Levillainf7746ad2015-07-22 14:12:01 +0100623 /// CHECK-NOT: DivZeroCheck
624 /// CHECK-NOT: Rem
625
626 public static int IntRemainder() {
627 int a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000628 a = $inline$int(8);
629 b = $inline$int(3);
Roland Levillainf7746ad2015-07-22 14:12:01 +0100630 c = a % b;
631 return c;
632 }
633
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700634 /// CHECK-START: long Main.LongRemainder() constant_folding$after_inlining (before)
Roland Levillainf7746ad2015-07-22 14:12:01 +0100635 /// CHECK-DAG: <<Const8:j\d+>> LongConstant 8
636 /// CHECK-DAG: <<Const3:j\d+>> LongConstant 3
637 /// CHECK-DAG: <<Div0Chk:j\d+>> DivZeroCheck [<<Const3>>]
638 /// CHECK-DAG: <<Rem:j\d+>> Rem [<<Const8>>,<<Div0Chk>>]
639 /// CHECK-DAG: Return [<<Rem>>]
640
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700641 /// CHECK-START: long Main.LongRemainder() constant_folding$after_inlining (after)
Roland Levillainf7746ad2015-07-22 14:12:01 +0100642 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2
643 /// CHECK-DAG: Return [<<Const2>>]
644
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700645 /// CHECK-START: long Main.LongRemainder() constant_folding$after_inlining (after)
Roland Levillainf7746ad2015-07-22 14:12:01 +0100646 /// CHECK-NOT: DivZeroCheck
647 /// CHECK-NOT: Rem
648
649 public static long LongRemainder() {
650 long a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000651 a = $inline$long(8L);
652 b = $inline$long(3L);
Roland Levillainf7746ad2015-07-22 14:12:01 +0100653 c = a % b;
654 return c;
655 }
656
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700657 /// CHECK-START: float Main.FloatRemainder() constant_folding$after_inlining (before)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000658 /// CHECK-DAG: <<Const8:f\d+>> FloatConstant 8
659 /// CHECK-DAG: <<Const2P5:f\d+>> FloatConstant 2.5
660 /// CHECK-DAG: <<Rem:f\d+>> Rem [<<Const8>>,<<Const2P5>>]
661 /// CHECK-DAG: Return [<<Rem>>]
662
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700663 /// CHECK-START: float Main.FloatRemainder() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000664 /// CHECK-DAG: <<Const0P5:f\d+>> FloatConstant 0.5
665 /// CHECK-DAG: Return [<<Const0P5>>]
666
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700667 /// CHECK-START: float Main.FloatRemainder() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000668 /// CHECK-NOT: Rem
669
670 public static float FloatRemainder() {
671 float a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000672 a = $inline$float(8F);
673 b = $inline$float(2.5F);
Roland Levillain31dd3d62016-02-16 12:21:02 +0000674 c = a % b;
675 return c;
676 }
677
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700678 /// CHECK-START: double Main.DoubleRemainder() constant_folding$after_inlining (before)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000679 /// CHECK-DAG: <<Const8:d\d+>> DoubleConstant 8
680 /// CHECK-DAG: <<Const2P5:d\d+>> DoubleConstant 2.5
681 /// CHECK-DAG: <<Rem:d\d+>> Rem [<<Const8>>,<<Const2P5>>]
682 /// CHECK-DAG: Return [<<Rem>>]
683
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700684 /// CHECK-START: double Main.DoubleRemainder() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000685 /// CHECK-DAG: <<Const0P5:d\d+>> DoubleConstant 0.5
686 /// CHECK-DAG: Return [<<Const0P5>>]
687
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700688 /// CHECK-START: double Main.DoubleRemainder() constant_folding$after_inlining (after)
Roland Levillain31dd3d62016-02-16 12:21:02 +0000689 /// CHECK-NOT: Rem
690
691 public static double DoubleRemainder() {
692 double a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000693 a = $inline$double(8D);
694 b = $inline$double(2.5D);
Roland Levillain31dd3d62016-02-16 12:21:02 +0000695 c = a % b;
696 return c;
697 }
698
Roland Levillainf7746ad2015-07-22 14:12:01 +0100699
700 /**
Roland Levillain9867bc72015-08-05 10:21:34 +0100701 * Exercise constant folding on left shift.
702 */
703
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700704 /// CHECK-START: int Main.ShlIntLong() constant_folding$after_inlining (before)
Roland Levillain9867bc72015-08-05 10:21:34 +0100705 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
706 /// CHECK-DAG: <<Const2L:j\d+>> LongConstant 2
707 /// CHECK-DAG: <<TypeConv:i\d+>> TypeConversion [<<Const2L>>]
708 /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Const1>>,<<TypeConv>>]
709 /// CHECK-DAG: Return [<<Shl>>]
710
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700711 /// CHECK-START: int Main.ShlIntLong() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100712 /// CHECK-DAG: <<Const4:i\d+>> IntConstant 4
713 /// CHECK-DAG: Return [<<Const4>>]
714
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700715 /// CHECK-START: int Main.ShlIntLong() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100716 /// CHECK-NOT: Shl
717
718 public static int ShlIntLong() {
David Brazdilf02c3cf2016-02-29 09:14:51 +0000719 int lhs = $inline$int(1);
720 long rhs = $inline$long(2L);
Roland Levillain9867bc72015-08-05 10:21:34 +0100721 return lhs << rhs;
722 }
723
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700724 /// CHECK-START: long Main.ShlLongInt() constant_folding$after_inlining (before)
Roland Levillain9867bc72015-08-05 10:21:34 +0100725 /// CHECK-DAG: <<Const3L:j\d+>> LongConstant 3
726 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
727 /// CHECK-DAG: <<Shl:j\d+>> Shl [<<Const3L>>,<<Const2>>]
728 /// CHECK-DAG: Return [<<Shl>>]
729
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700730 /// CHECK-START: long Main.ShlLongInt() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100731 /// CHECK-DAG: <<Const12L:j\d+>> LongConstant 12
732 /// CHECK-DAG: Return [<<Const12L>>]
733
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700734 /// CHECK-START: long Main.ShlLongInt() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100735 /// CHECK-NOT: Shl
736
737 public static long ShlLongInt() {
David Brazdilf02c3cf2016-02-29 09:14:51 +0000738 long lhs = $inline$long(3L);
739 int rhs = $inline$int(2);
Roland Levillain9867bc72015-08-05 10:21:34 +0100740 return lhs << rhs;
741 }
742
743
744 /**
745 * Exercise constant folding on right shift.
746 */
747
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700748 /// CHECK-START: int Main.ShrIntLong() constant_folding$after_inlining (before)
Roland Levillain9867bc72015-08-05 10:21:34 +0100749 /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7
750 /// CHECK-DAG: <<Const2L:j\d+>> LongConstant 2
751 /// CHECK-DAG: <<TypeConv:i\d+>> TypeConversion [<<Const2L>>]
752 /// CHECK-DAG: <<Shr:i\d+>> Shr [<<Const7>>,<<TypeConv>>]
753 /// CHECK-DAG: Return [<<Shr>>]
754
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700755 /// CHECK-START: int Main.ShrIntLong() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100756 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
757 /// CHECK-DAG: Return [<<Const1>>]
758
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700759 /// CHECK-START: int Main.ShrIntLong() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100760 /// CHECK-NOT: Shr
761
762 public static int ShrIntLong() {
David Brazdilf02c3cf2016-02-29 09:14:51 +0000763 int lhs = $inline$int(7);
764 long rhs = $inline$long(2L);
Roland Levillain9867bc72015-08-05 10:21:34 +0100765 return lhs >> rhs;
766 }
767
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700768 /// CHECK-START: long Main.ShrLongInt() constant_folding$after_inlining (before)
Roland Levillain9867bc72015-08-05 10:21:34 +0100769 /// CHECK-DAG: <<Const9L:j\d+>> LongConstant 9
770 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
771 /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Const9L>>,<<Const2>>]
772 /// CHECK-DAG: Return [<<Shr>>]
773
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700774 /// CHECK-START: long Main.ShrLongInt() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100775 /// CHECK-DAG: <<Const2L:j\d+>> LongConstant 2
776 /// CHECK-DAG: Return [<<Const2L>>]
777
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700778 /// CHECK-START: long Main.ShrLongInt() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100779 /// CHECK-NOT: Shr
780
781 public static long ShrLongInt() {
David Brazdilf02c3cf2016-02-29 09:14:51 +0000782 long lhs = $inline$long(9);
783 int rhs = $inline$int(2);
Roland Levillain9867bc72015-08-05 10:21:34 +0100784 return lhs >> rhs;
785 }
786
787
788 /**
789 * Exercise constant folding on unsigned right shift.
790 */
791
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700792 /// CHECK-START: int Main.UShrIntLong() constant_folding$after_inlining (before)
Roland Levillain9867bc72015-08-05 10:21:34 +0100793 /// CHECK-DAG: <<ConstM7:i\d+>> IntConstant -7
794 /// CHECK-DAG: <<Const2L:j\d+>> LongConstant 2
795 /// CHECK-DAG: <<TypeConv:i\d+>> TypeConversion [<<Const2L>>]
796 /// CHECK-DAG: <<UShr:i\d+>> UShr [<<ConstM7>>,<<TypeConv>>]
797 /// CHECK-DAG: Return [<<UShr>>]
798
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700799 /// CHECK-START: int Main.UShrIntLong() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100800 /// CHECK-DAG: <<ConstRes:i\d+>> IntConstant 1073741822
801 /// CHECK-DAG: Return [<<ConstRes>>]
802
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700803 /// CHECK-START: int Main.UShrIntLong() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100804 /// CHECK-NOT: UShr
805
806 public static int UShrIntLong() {
David Brazdilf02c3cf2016-02-29 09:14:51 +0000807 int lhs = $inline$int(-7);
808 long rhs = $inline$long(2L);
Roland Levillain9867bc72015-08-05 10:21:34 +0100809 return lhs >>> rhs;
810 }
811
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700812 /// CHECK-START: long Main.UShrLongInt() constant_folding$after_inlining (before)
Roland Levillain9867bc72015-08-05 10:21:34 +0100813 /// CHECK-DAG: <<ConstM9L:j\d+>> LongConstant -9
814 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
815 /// CHECK-DAG: <<UShr:j\d+>> UShr [<<ConstM9L>>,<<Const2>>]
816 /// CHECK-DAG: Return [<<UShr>>]
817
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700818 /// CHECK-START: long Main.UShrLongInt() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100819 /// CHECK-DAG: <<ConstRes:j\d+>> LongConstant 4611686018427387901
820 /// CHECK-DAG: Return [<<ConstRes>>]
821
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700822 /// CHECK-START: long Main.UShrLongInt() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100823 /// CHECK-NOT: UShr
824
825 public static long UShrLongInt() {
David Brazdilf02c3cf2016-02-29 09:14:51 +0000826 long lhs = $inline$long(-9);
827 int rhs = $inline$int(2);
Roland Levillain9867bc72015-08-05 10:21:34 +0100828 return lhs >>> rhs;
829 }
830
831
832 /**
833 * Exercise constant folding on logical and.
834 */
835
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700836 /// CHECK-START: long Main.AndIntLong() constant_folding$after_inlining (before)
Roland Levillain9867bc72015-08-05 10:21:34 +0100837 /// CHECK-DAG: <<Const10:i\d+>> IntConstant 10
838 /// CHECK-DAG: <<Const3L:j\d+>> LongConstant 3
839 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const10>>]
840 /// CHECK-DAG: <<And:j\d+>> And [<<TypeConv>>,<<Const3L>>]
841 /// CHECK-DAG: Return [<<And>>]
842
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700843 /// CHECK-START: long Main.AndIntLong() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100844 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2
845 /// CHECK-DAG: Return [<<Const2>>]
846
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700847 /// CHECK-START: long Main.AndIntLong() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100848 /// CHECK-NOT: And
849
850 public static long AndIntLong() {
David Brazdilf02c3cf2016-02-29 09:14:51 +0000851 int lhs = $inline$int(10);
852 long rhs = $inline$long(3L);
Roland Levillain9867bc72015-08-05 10:21:34 +0100853 return lhs & rhs;
854 }
855
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700856 /// CHECK-START: long Main.AndLongInt() constant_folding$after_inlining (before)
Roland Levillain9867bc72015-08-05 10:21:34 +0100857 /// CHECK-DAG: <<Const10L:j\d+>> LongConstant 10
858 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3
859 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const3>>]
David Brazdil57e863c2016-01-11 10:27:13 +0000860 /// CHECK-DAG: <<And:j\d+>> And [<<TypeConv>>,<<Const10L>>]
Roland Levillain9867bc72015-08-05 10:21:34 +0100861 /// CHECK-DAG: Return [<<And>>]
862
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700863 /// CHECK-START: long Main.AndLongInt() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100864 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2
865 /// CHECK-DAG: Return [<<Const2>>]
866
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700867 /// CHECK-START: long Main.AndLongInt() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100868 /// CHECK-NOT: And
869
870 public static long AndLongInt() {
David Brazdilf02c3cf2016-02-29 09:14:51 +0000871 long lhs = $inline$long(10L);
872 int rhs = $inline$int(3);
Roland Levillain9867bc72015-08-05 10:21:34 +0100873 return lhs & rhs;
874 }
875
876
877 /**
878 * Exercise constant folding on logical or.
879 */
880
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700881 /// CHECK-START: long Main.OrIntLong() constant_folding$after_inlining (before)
Roland Levillain9867bc72015-08-05 10:21:34 +0100882 /// CHECK-DAG: <<Const10:i\d+>> IntConstant 10
883 /// CHECK-DAG: <<Const3L:j\d+>> LongConstant 3
884 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const10>>]
885 /// CHECK-DAG: <<Or:j\d+>> Or [<<TypeConv>>,<<Const3L>>]
886 /// CHECK-DAG: Return [<<Or>>]
887
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700888 /// CHECK-START: long Main.OrIntLong() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100889 /// CHECK-DAG: <<Const11:j\d+>> LongConstant 11
890 /// CHECK-DAG: Return [<<Const11>>]
891
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700892 /// CHECK-START: long Main.OrIntLong() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100893 /// CHECK-NOT: Or
894
895 public static long OrIntLong() {
David Brazdilf02c3cf2016-02-29 09:14:51 +0000896 int lhs = $inline$int(10);
897 long rhs = $inline$long(3L);
Roland Levillain9867bc72015-08-05 10:21:34 +0100898 return lhs | rhs;
899 }
900
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700901 /// CHECK-START: long Main.OrLongInt() constant_folding$after_inlining (before)
Roland Levillain9867bc72015-08-05 10:21:34 +0100902 /// CHECK-DAG: <<Const10L:j\d+>> LongConstant 10
903 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3
904 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const3>>]
David Brazdil57e863c2016-01-11 10:27:13 +0000905 /// CHECK-DAG: <<Or:j\d+>> Or [<<TypeConv>>,<<Const10L>>]
Roland Levillain9867bc72015-08-05 10:21:34 +0100906 /// CHECK-DAG: Return [<<Or>>]
907
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700908 /// CHECK-START: long Main.OrLongInt() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100909 /// CHECK-DAG: <<Const11:j\d+>> LongConstant 11
910 /// CHECK-DAG: Return [<<Const11>>]
911
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700912 /// CHECK-START: long Main.OrLongInt() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100913 /// CHECK-NOT: Or
914
915 public static long OrLongInt() {
David Brazdilf02c3cf2016-02-29 09:14:51 +0000916 long lhs = $inline$long(10L);
917 int rhs = $inline$int(3);
Roland Levillain9867bc72015-08-05 10:21:34 +0100918 return lhs | rhs;
919 }
920
921
922 /**
923 * Exercise constant folding on logical exclusive or.
924 */
925
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700926 /// CHECK-START: long Main.XorIntLong() constant_folding$after_inlining (before)
Roland Levillain9867bc72015-08-05 10:21:34 +0100927 /// CHECK-DAG: <<Const10:i\d+>> IntConstant 10
928 /// CHECK-DAG: <<Const3L:j\d+>> LongConstant 3
929 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const10>>]
930 /// CHECK-DAG: <<Xor:j\d+>> Xor [<<TypeConv>>,<<Const3L>>]
931 /// CHECK-DAG: Return [<<Xor>>]
932
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700933 /// CHECK-START: long Main.XorIntLong() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100934 /// CHECK-DAG: <<Const9:j\d+>> LongConstant 9
935 /// CHECK-DAG: Return [<<Const9>>]
936
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700937 /// CHECK-START: long Main.XorIntLong() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100938 /// CHECK-NOT: Xor
939
940 public static long XorIntLong() {
David Brazdilf02c3cf2016-02-29 09:14:51 +0000941 int lhs = $inline$int(10);
942 long rhs = $inline$long(3L);
Roland Levillain9867bc72015-08-05 10:21:34 +0100943 return lhs ^ rhs;
944 }
945
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700946 /// CHECK-START: long Main.XorLongInt() constant_folding$after_inlining (before)
Roland Levillain9867bc72015-08-05 10:21:34 +0100947 /// CHECK-DAG: <<Const10L:j\d+>> LongConstant 10
948 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3
949 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const3>>]
David Brazdil57e863c2016-01-11 10:27:13 +0000950 /// CHECK-DAG: <<Xor:j\d+>> Xor [<<TypeConv>>,<<Const10L>>]
Roland Levillain9867bc72015-08-05 10:21:34 +0100951 /// CHECK-DAG: Return [<<Xor>>]
952
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700953 /// CHECK-START: long Main.XorLongInt() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100954 /// CHECK-DAG: <<Const9:j\d+>> LongConstant 9
955 /// CHECK-DAG: Return [<<Const9>>]
956
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700957 /// CHECK-START: long Main.XorLongInt() constant_folding$after_inlining (after)
Roland Levillain9867bc72015-08-05 10:21:34 +0100958 /// CHECK-NOT: Xor
959
960 public static long XorLongInt() {
David Brazdilf02c3cf2016-02-29 09:14:51 +0000961 long lhs = $inline$long(10L);
962 int rhs = $inline$int(3);
Roland Levillain9867bc72015-08-05 10:21:34 +0100963 return lhs ^ rhs;
964 }
965
966
967 /**
Roland Levillainb65eb502015-07-23 12:11:42 +0100968 * Exercise constant folding on constant (static) condition.
David Brazdilee690a32014-12-01 17:04:16 +0000969 */
970
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700971 /// CHECK-START: int Main.StaticCondition() constant_folding$after_inlining (before)
David Brazdila06d66a2015-05-28 11:14:54 +0100972 /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7
973 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
974 /// CHECK-DAG: <<Cond:z\d+>> GreaterThanOrEqual [<<Const7>>,<<Const2>>]
David Brazdilf02c3cf2016-02-29 09:14:51 +0000975 /// CHECK-DAG: Select [{{i\d+}},{{i\d+}},<<Cond>>]
David Brazdilee690a32014-12-01 17:04:16 +0000976
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700977 /// CHECK-START: int Main.StaticCondition() constant_folding$after_inlining (after)
David Brazdila06d66a2015-05-28 11:14:54 +0100978 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
David Brazdilf02c3cf2016-02-29 09:14:51 +0000979 /// CHECK-DAG: Select [{{i\d+}},{{i\d+}},<<Const1>>]
David Brazdilee690a32014-12-01 17:04:16 +0000980
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -0700981 /// CHECK-START: int Main.StaticCondition() constant_folding$after_inlining (after)
Roland Levillainb65eb502015-07-23 12:11:42 +0100982 /// CHECK-NOT: GreaterThanOrEqual
983
David Brazdilee690a32014-12-01 17:04:16 +0000984 public static int StaticCondition() {
985 int a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +0000986 a = $inline$int(7);
987 b = $inline$int(2);
David Brazdilee690a32014-12-01 17:04:16 +0000988 if (a < b)
989 c = a + b;
990 else
991 c = a - b;
992 return c;
993 }
994
Roland Levillainb65eb502015-07-23 12:11:42 +0100995
David Brazdilee690a32014-12-01 17:04:16 +0000996 /**
Vladimir Marko9e23df52015-11-10 17:14:35 +0000997 * Exercise constant folding on constant (static) condition for null references.
998 */
999
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001000 /// CHECK-START: int Main.StaticConditionNulls() constant_folding$after_inlining (before)
Vladimir Marko9e23df52015-11-10 17:14:35 +00001001 /// CHECK-DAG: <<Null:l\d+>> NullConstant
1002 /// CHECK-DAG: <<Cond:z\d+>> NotEqual [<<Null>>,<<Null>>]
David Brazdil74eb1b22015-12-14 11:44:01 +00001003 /// CHECK-DAG: Select [{{i\d+}},{{i\d+}},<<Cond>>]
Vladimir Marko9e23df52015-11-10 17:14:35 +00001004
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001005 /// CHECK-START: int Main.StaticConditionNulls() constant_folding$after_inlining (after)
Vladimir Marko9e23df52015-11-10 17:14:35 +00001006 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
David Brazdil74eb1b22015-12-14 11:44:01 +00001007 /// CHECK-DAG: Select [{{i\d+}},{{i\d+}},<<Const0>>]
Vladimir Marko9e23df52015-11-10 17:14:35 +00001008
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001009 /// CHECK-START: int Main.StaticConditionNulls() constant_folding$after_inlining (after)
Vladimir Marko9e23df52015-11-10 17:14:35 +00001010 /// CHECK-NOT: NotEqual
1011
1012 private static Object getNull() {
1013 return null;
1014 }
1015
1016 public static int StaticConditionNulls() {
1017 Object a = getNull();
1018 Object b = getNull();
1019 return (a == b) ? 5 : 2;
1020 }
1021
1022
1023 /**
Roland Levillainb65eb502015-07-23 12:11:42 +01001024 * Exercise constant folding on a program with condition
1025 * (i.e. jumps) leading to the creation of many blocks.
David Brazdilee690a32014-12-01 17:04:16 +00001026 *
1027 * The intent of this test is to ensure that all constant expressions
1028 * are actually evaluated at compile-time, thanks to the reverse
1029 * (forward) post-order traversal of the the dominator tree.
1030 */
1031
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001032 /// CHECK-START: int Main.JumpsAndConditionals(boolean) constant_folding$after_inlining (before)
David Brazdilf02c3cf2016-02-29 09:14:51 +00001033 /// CHECK-DAG: <<Cond:z\d+>> ParameterValue
David Brazdila06d66a2015-05-28 11:14:54 +01001034 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2
1035 /// CHECK-DAG: <<Const5:i\d+>> IntConstant 5
1036 /// CHECK-DAG: <<Add:i\d+>> Add [<<Const5>>,<<Const2>>]
1037 /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Const5>>,<<Const2>>]
David Brazdilf02c3cf2016-02-29 09:14:51 +00001038 /// CHECK-DAG: <<Phi:i\d+>> Select [<<Sub>>,<<Add>>,<<Cond>>]
David Brazdila06d66a2015-05-28 11:14:54 +01001039 /// CHECK-DAG: Return [<<Phi>>]
David Brazdilee690a32014-12-01 17:04:16 +00001040
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001041 /// CHECK-START: int Main.JumpsAndConditionals(boolean) constant_folding$after_inlining (after)
David Brazdilf02c3cf2016-02-29 09:14:51 +00001042 /// CHECK-DAG: <<Cond:z\d+>> ParameterValue
David Brazdila06d66a2015-05-28 11:14:54 +01001043 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3
1044 /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7
David Brazdilf02c3cf2016-02-29 09:14:51 +00001045 /// CHECK-DAG: <<Phi:i\d+>> Select [<<Const3>>,<<Const7>>,<<Cond>>]
David Brazdila06d66a2015-05-28 11:14:54 +01001046 /// CHECK-DAG: Return [<<Phi>>]
David Brazdilee690a32014-12-01 17:04:16 +00001047
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001048 /// CHECK-START: int Main.JumpsAndConditionals(boolean) constant_folding$after_inlining (after)
Roland Levillainb65eb502015-07-23 12:11:42 +01001049 /// CHECK-NOT: Add
1050 /// CHECK-NOT: Sub
1051
David Brazdilee690a32014-12-01 17:04:16 +00001052 public static int JumpsAndConditionals(boolean cond) {
1053 int a, b, c;
David Brazdilf02c3cf2016-02-29 09:14:51 +00001054 a = $inline$int(5);
1055 b = $inline$int(2);
David Brazdilee690a32014-12-01 17:04:16 +00001056 if (cond)
1057 c = a + b;
1058 else
1059 c = a - b;
1060 return c;
1061 }
David Brazdil4846d132015-01-15 19:07:08 +00001062
Roland Levillainb65eb502015-07-23 12:11:42 +01001063
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001064 /**
1065 * Test optimizations of arithmetic identities yielding a constant result.
1066 */
1067
David Brazdila06d66a2015-05-28 11:14:54 +01001068 /// CHECK-START: int Main.And0(int) constant_folding (before)
1069 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
1070 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
1071 /// CHECK-DAG: <<And:i\d+>> And [<<Arg>>,<<Const0>>]
1072 /// CHECK-DAG: Return [<<And>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001073
David Brazdila06d66a2015-05-28 11:14:54 +01001074 /// CHECK-START: int Main.And0(int) constant_folding (after)
1075 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
1076 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +01001077 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001078
Roland Levillainb65eb502015-07-23 12:11:42 +01001079 /// CHECK-START: int Main.And0(int) constant_folding (after)
1080 /// CHECK-NOT: And
1081
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001082 public static int And0(int arg) {
1083 return arg & 0;
1084 }
1085
David Brazdila06d66a2015-05-28 11:14:54 +01001086 /// CHECK-START: long Main.Mul0(long) constant_folding (before)
1087 /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
1088 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0
David Brazdil57e863c2016-01-11 10:27:13 +00001089 /// CHECK-DAG: <<Mul:j\d+>> Mul [<<Const0>>,<<Arg>>]
David Brazdila06d66a2015-05-28 11:14:54 +01001090 /// CHECK-DAG: Return [<<Mul>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001091
David Brazdila06d66a2015-05-28 11:14:54 +01001092 /// CHECK-START: long Main.Mul0(long) constant_folding (after)
1093 /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
1094 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +01001095 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001096
Roland Levillainb65eb502015-07-23 12:11:42 +01001097 /// CHECK-START: long Main.Mul0(long) constant_folding (after)
1098 /// CHECK-NOT: Mul
1099
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001100 public static long Mul0(long arg) {
1101 return arg * 0;
1102 }
1103
David Brazdila06d66a2015-05-28 11:14:54 +01001104 /// CHECK-START: int Main.OrAllOnes(int) constant_folding (before)
1105 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
1106 /// CHECK-DAG: <<ConstF:i\d+>> IntConstant -1
1107 /// CHECK-DAG: <<Or:i\d+>> Or [<<Arg>>,<<ConstF>>]
1108 /// CHECK-DAG: Return [<<Or>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001109
David Brazdila06d66a2015-05-28 11:14:54 +01001110 /// CHECK-START: int Main.OrAllOnes(int) constant_folding (after)
1111 /// CHECK-DAG: <<ConstF:i\d+>> IntConstant -1
David Brazdila06d66a2015-05-28 11:14:54 +01001112 /// CHECK-DAG: Return [<<ConstF>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001113
Roland Levillainb65eb502015-07-23 12:11:42 +01001114 /// CHECK-START: int Main.OrAllOnes(int) constant_folding (after)
1115 /// CHECK-NOT: Or
1116
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001117 public static int OrAllOnes(int arg) {
1118 return arg | -1;
1119 }
1120
David Brazdila06d66a2015-05-28 11:14:54 +01001121 /// CHECK-START: long Main.Rem0(long) constant_folding (before)
1122 /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
1123 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0
1124 /// CHECK-DAG: <<DivZeroCheck:j\d+>> DivZeroCheck [<<Arg>>]
1125 /// CHECK-DAG: <<Rem:j\d+>> Rem [<<Const0>>,<<DivZeroCheck>>]
1126 /// CHECK-DAG: Return [<<Rem>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001127
David Brazdila06d66a2015-05-28 11:14:54 +01001128 /// CHECK-START: long Main.Rem0(long) constant_folding (after)
1129 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +01001130 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001131
Roland Levillainb65eb502015-07-23 12:11:42 +01001132 /// CHECK-START: long Main.Rem0(long) constant_folding (after)
1133 /// CHECK-NOT: Rem
1134
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001135 public static long Rem0(long arg) {
1136 return 0 % arg;
1137 }
1138
David Brazdila06d66a2015-05-28 11:14:54 +01001139 /// CHECK-START: int Main.Rem1(int) constant_folding (before)
1140 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
1141 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
1142 /// CHECK-DAG: <<Rem:i\d+>> Rem [<<Arg>>,<<Const1>>]
1143 /// CHECK-DAG: Return [<<Rem>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001144
David Brazdila06d66a2015-05-28 11:14:54 +01001145 /// CHECK-START: int Main.Rem1(int) constant_folding (after)
1146 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +01001147 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001148
Roland Levillainb65eb502015-07-23 12:11:42 +01001149 /// CHECK-START: int Main.Rem1(int) constant_folding (after)
1150 /// CHECK-NOT: Rem
1151
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001152 public static int Rem1(int arg) {
1153 return arg % 1;
1154 }
1155
David Brazdila06d66a2015-05-28 11:14:54 +01001156 /// CHECK-START: long Main.RemN1(long) constant_folding (before)
1157 /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
1158 /// CHECK-DAG: <<ConstN1:j\d+>> LongConstant -1
1159 /// CHECK-DAG: <<DivZeroCheck:j\d+>> DivZeroCheck [<<ConstN1>>]
1160 /// CHECK-DAG: <<Rem:j\d+>> Rem [<<Arg>>,<<DivZeroCheck>>]
1161 /// CHECK-DAG: Return [<<Rem>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001162
David Brazdila06d66a2015-05-28 11:14:54 +01001163 /// CHECK-START: long Main.RemN1(long) constant_folding (after)
1164 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +01001165 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001166
Roland Levillainb65eb502015-07-23 12:11:42 +01001167 /// CHECK-START: long Main.RemN1(long) constant_folding (after)
1168 /// CHECK-NOT: Rem
1169
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001170 public static long RemN1(long arg) {
1171 return arg % -1;
1172 }
1173
David Brazdila06d66a2015-05-28 11:14:54 +01001174 /// CHECK-START: int Main.Shl0(int) constant_folding (before)
1175 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
1176 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
1177 /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Const0>>,<<Arg>>]
1178 /// CHECK-DAG: Return [<<Shl>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001179
David Brazdila06d66a2015-05-28 11:14:54 +01001180 /// CHECK-START: int Main.Shl0(int) constant_folding (after)
1181 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
1182 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +01001183 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001184
Roland Levillainb65eb502015-07-23 12:11:42 +01001185 /// CHECK-START: int Main.Shl0(int) constant_folding (after)
1186 /// CHECK-NOT: Shl
1187
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001188 public static int Shl0(int arg) {
1189 return 0 << arg;
1190 }
1191
Roland Levillain9867bc72015-08-05 10:21:34 +01001192 /// CHECK-START: long Main.ShlLong0WithInt(int) constant_folding (before)
1193 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
1194 /// CHECK-DAG: <<Const0L:j\d+>> LongConstant 0
1195 /// CHECK-DAG: <<Shl:j\d+>> Shl [<<Const0L>>,<<Arg>>]
1196 /// CHECK-DAG: Return [<<Shl>>]
1197
1198 /// CHECK-START: long Main.ShlLong0WithInt(int) constant_folding (after)
1199 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
1200 /// CHECK-DAG: <<Const0L:j\d+>> LongConstant 0
1201 /// CHECK-DAG: Return [<<Const0L>>]
1202
1203 /// CHECK-START: long Main.ShlLong0WithInt(int) constant_folding (after)
1204 /// CHECK-NOT: Shl
1205
1206 public static long ShlLong0WithInt(int arg) {
1207 long long_zero = 0;
1208 return long_zero << arg;
1209 }
1210
David Brazdila06d66a2015-05-28 11:14:54 +01001211 /// CHECK-START: long Main.Shr0(int) constant_folding (before)
1212 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
1213 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0
1214 /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Const0>>,<<Arg>>]
1215 /// CHECK-DAG: Return [<<Shr>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001216
David Brazdila06d66a2015-05-28 11:14:54 +01001217 /// CHECK-START: long Main.Shr0(int) constant_folding (after)
1218 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
1219 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +01001220 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001221
Roland Levillainb65eb502015-07-23 12:11:42 +01001222 /// CHECK-START: long Main.Shr0(int) constant_folding (after)
1223 /// CHECK-NOT: Shr
1224
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001225 public static long Shr0(int arg) {
1226 return (long)0 >> arg;
1227 }
1228
David Brazdila06d66a2015-05-28 11:14:54 +01001229 /// CHECK-START: long Main.SubSameLong(long) constant_folding (before)
1230 /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
1231 /// CHECK-DAG: <<Sub:j\d+>> Sub [<<Arg>>,<<Arg>>]
1232 /// CHECK-DAG: Return [<<Sub>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001233
David Brazdila06d66a2015-05-28 11:14:54 +01001234 /// CHECK-START: long Main.SubSameLong(long) constant_folding (after)
1235 /// CHECK-DAG: <<Arg:j\d+>> ParameterValue
1236 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +01001237 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001238
Roland Levillainb65eb502015-07-23 12:11:42 +01001239 /// CHECK-START: long Main.SubSameLong(long) constant_folding (after)
1240 /// CHECK-NOT: Sub
1241
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001242 public static long SubSameLong(long arg) {
1243 return arg - arg;
1244 }
1245
David Brazdila06d66a2015-05-28 11:14:54 +01001246 /// CHECK-START: int Main.UShr0(int) constant_folding (before)
1247 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
1248 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
1249 /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Const0>>,<<Arg>>]
1250 /// CHECK-DAG: Return [<<UShr>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001251
David Brazdila06d66a2015-05-28 11:14:54 +01001252 /// CHECK-START: int Main.UShr0(int) constant_folding (after)
1253 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
1254 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +01001255 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001256
Roland Levillainb65eb502015-07-23 12:11:42 +01001257 /// CHECK-START: int Main.UShr0(int) constant_folding (after)
1258 /// CHECK-NOT: UShr
1259
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001260 public static int UShr0(int arg) {
1261 return 0 >>> arg;
1262 }
1263
David Brazdila06d66a2015-05-28 11:14:54 +01001264 /// CHECK-START: int Main.XorSameInt(int) constant_folding (before)
1265 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
1266 /// CHECK-DAG: <<Xor:i\d+>> Xor [<<Arg>>,<<Arg>>]
1267 /// CHECK-DAG: Return [<<Xor>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001268
David Brazdila06d66a2015-05-28 11:14:54 +01001269 /// CHECK-START: int Main.XorSameInt(int) constant_folding (after)
1270 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue
1271 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
David Brazdila06d66a2015-05-28 11:14:54 +01001272 /// CHECK-DAG: Return [<<Const0>>]
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001273
Roland Levillainb65eb502015-07-23 12:11:42 +01001274 /// CHECK-START: int Main.XorSameInt(int) constant_folding (after)
1275 /// CHECK-NOT: Xor
1276
Alexandre Ramesb2fd7bc2015-03-11 16:48:16 +00001277 public static int XorSameInt(int arg) {
1278 return arg ^ arg;
1279 }
1280
David Brazdila06d66a2015-05-28 11:14:54 +01001281 /// CHECK-START: boolean Main.CmpFloatGreaterThanNaN(float) constant_folding (before)
1282 /// CHECK-DAG: <<Arg:f\d+>> ParameterValue
1283 /// CHECK-DAG: <<ConstNan:f\d+>> FloatConstant nan
1284 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
1285 /// CHECK-DAG: IntConstant 1
1286 /// CHECK-DAG: <<Cmp:i\d+>> Compare [<<Arg>>,<<ConstNan>>]
1287 /// CHECK-DAG: <<Le:z\d+>> LessThanOrEqual [<<Cmp>>,<<Const0>>]
1288 /// CHECK-DAG: If [<<Le>>]
Roland Levillain3b55ebb2015-05-08 13:13:19 +01001289
David Brazdila06d66a2015-05-28 11:14:54 +01001290 /// CHECK-START: boolean Main.CmpFloatGreaterThanNaN(float) constant_folding (after)
1291 /// CHECK-DAG: ParameterValue
1292 /// CHECK-DAG: FloatConstant nan
1293 /// CHECK-DAG: IntConstant 0
1294 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
1295 /// CHECK-DAG: If [<<Const1>>]
Roland Levillain3b55ebb2015-05-08 13:13:19 +01001296
David Brazdila06d66a2015-05-28 11:14:54 +01001297 /// CHECK-START: boolean Main.CmpFloatGreaterThanNaN(float) constant_folding (after)
1298 /// CHECK-NOT: Compare
1299 /// CHECK-NOT: LessThanOrEqual
Roland Levillain3b55ebb2015-05-08 13:13:19 +01001300
1301 public static boolean CmpFloatGreaterThanNaN(float arg) {
1302 return arg > Float.NaN;
1303 }
1304
David Brazdila06d66a2015-05-28 11:14:54 +01001305 /// CHECK-START: boolean Main.CmpDoubleLessThanNaN(double) constant_folding (before)
1306 /// CHECK-DAG: <<Arg:d\d+>> ParameterValue
1307 /// CHECK-DAG: <<ConstNan:d\d+>> DoubleConstant nan
1308 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
1309 /// CHECK-DAG: IntConstant 1
1310 /// CHECK-DAG: <<Cmp:i\d+>> Compare [<<Arg>>,<<ConstNan>>]
1311 /// CHECK-DAG: <<Ge:z\d+>> GreaterThanOrEqual [<<Cmp>>,<<Const0>>]
1312 /// CHECK-DAG: If [<<Ge>>]
Roland Levillain3b55ebb2015-05-08 13:13:19 +01001313
David Brazdila06d66a2015-05-28 11:14:54 +01001314 /// CHECK-START: boolean Main.CmpDoubleLessThanNaN(double) constant_folding (after)
1315 /// CHECK-DAG: ParameterValue
1316 /// CHECK-DAG: DoubleConstant nan
1317 /// CHECK-DAG: IntConstant 0
1318 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1
1319 /// CHECK-DAG: If [<<Const1>>]
Roland Levillain3b55ebb2015-05-08 13:13:19 +01001320
David Brazdila06d66a2015-05-28 11:14:54 +01001321 /// CHECK-START: boolean Main.CmpDoubleLessThanNaN(double) constant_folding (after)
1322 /// CHECK-NOT: Compare
1323 /// CHECK-NOT: GreaterThanOrEqual
Roland Levillain3b55ebb2015-05-08 13:13:19 +01001324
1325 public static boolean CmpDoubleLessThanNaN(double arg) {
1326 return arg < Double.NaN;
1327 }
1328
Roland Levillainb65eb502015-07-23 12:11:42 +01001329
1330 /**
Vladimir Markoa341f352016-08-31 12:18:20 +01001331 * Test optimizations of comparisons with null yielding a constant result.
1332 */
1333
1334 /// CHECK-START: boolean Main.ConstStringEqualsNull() constant_folding$after_inlining (before)
1335 /// CHECK-DAG: <<ConstStr:l\d+>> LoadString
1336 /// CHECK-DAG: <<Null:l\d+>> NullConstant
1337 /// CHECK-DAG: <<Eq:z\d+>> Equal [<<ConstStr>>,<<Null>>]
1338 /// CHECK-DAG: If [<<Eq>>]
1339
1340 /// CHECK-START: boolean Main.ConstStringEqualsNull() constant_folding$after_inlining (after)
1341 /// CHECK-DAG: <<False:i\d+>> IntConstant 0
1342 /// CHECK-DAG: If [<<False>>]
1343
1344 /// CHECK-START: boolean Main.ConstStringEqualsNull() constant_folding$after_inlining (after)
1345 /// CHECK-NOT: Equal
1346
1347 public static boolean ConstStringEqualsNull() {
1348 // Due to Jack emitting code using the opposite condition, use != to generate Equal.
1349 if ($inline$ConstString() != null) {
1350 return false;
1351 } else {
1352 return true;
1353 }
1354 }
1355
1356 /// CHECK-START: boolean Main.ConstStringNotEqualsNull() constant_folding$after_inlining (before)
1357 /// CHECK-DAG: <<ConstStr:l\d+>> LoadString
1358 /// CHECK-DAG: <<Null:l\d+>> NullConstant
1359 /// CHECK-DAG: <<Ne:z\d+>> NotEqual [<<ConstStr>>,<<Null>>]
1360 /// CHECK-DAG: If [<<Ne>>]
1361
1362 /// CHECK-START: boolean Main.ConstStringNotEqualsNull() constant_folding$after_inlining (after)
1363 /// CHECK-DAG: <<True:i\d+>> IntConstant 1
1364 /// CHECK-DAG: If [<<True>>]
1365
1366 /// CHECK-START: boolean Main.ConstStringNotEqualsNull() constant_folding$after_inlining (after)
1367 /// CHECK-NOT: NotEqual
1368
1369 public static boolean ConstStringNotEqualsNull() {
1370 // Due to Jack emitting code using the opposite condition, use == to generate NotEqual.
1371 if ($inline$ConstString() == null) {
1372 return false;
1373 } else {
1374 return true;
1375 }
1376 }
1377
1378 public static String $inline$ConstString() {
1379 return "";
1380 }
1381
1382 /**
Roland Levillainb65eb502015-07-23 12:11:42 +01001383 * Exercise constant folding on type conversions.
1384 */
1385
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001386 /// CHECK-START: int Main.ReturnInt33() constant_folding$after_inlining (before)
David Brazdila06d66a2015-05-28 11:14:54 +01001387 /// CHECK-DAG: <<Const33:j\d+>> LongConstant 33
1388 /// CHECK-DAG: <<Convert:i\d+>> TypeConversion [<<Const33>>]
1389 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001390
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001391 /// CHECK-START: int Main.ReturnInt33() constant_folding$after_inlining (after)
David Brazdila06d66a2015-05-28 11:14:54 +01001392 /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33
1393 /// CHECK-DAG: Return [<<Const33>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001394
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001395 /// CHECK-START: int Main.ReturnInt33() constant_folding$after_inlining (after)
Roland Levillainb65eb502015-07-23 12:11:42 +01001396 /// CHECK-NOT: TypeConversion
1397
Mark Mendelle82549b2015-05-06 10:55:34 -04001398 public static int ReturnInt33() {
David Brazdilf02c3cf2016-02-29 09:14:51 +00001399 long imm = $inline$long(33L);
Mark Mendelle82549b2015-05-06 10:55:34 -04001400 return (int) imm;
1401 }
1402
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001403 /// CHECK-START: int Main.ReturnIntMax() constant_folding$after_inlining (before)
David Brazdila06d66a2015-05-28 11:14:54 +01001404 /// CHECK-DAG: <<ConstMax:f\d+>> FloatConstant 1e+34
1405 /// CHECK-DAG: <<Convert:i\d+>> TypeConversion [<<ConstMax>>]
1406 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001407
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001408 /// CHECK-START: int Main.ReturnIntMax() constant_folding$after_inlining (after)
David Brazdila06d66a2015-05-28 11:14:54 +01001409 /// CHECK-DAG: <<ConstMax:i\d+>> IntConstant 2147483647
1410 /// CHECK-DAG: Return [<<ConstMax>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001411
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001412 /// CHECK-START: int Main.ReturnIntMax() constant_folding$after_inlining (after)
Roland Levillainb65eb502015-07-23 12:11:42 +01001413 /// CHECK-NOT: TypeConversion
1414
Mark Mendelle82549b2015-05-06 10:55:34 -04001415 public static int ReturnIntMax() {
David Brazdilf02c3cf2016-02-29 09:14:51 +00001416 float imm = $inline$float(1.0e34f);
Mark Mendelle82549b2015-05-06 10:55:34 -04001417 return (int) imm;
1418 }
1419
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001420 /// CHECK-START: int Main.ReturnInt0() constant_folding$after_inlining (before)
David Brazdila06d66a2015-05-28 11:14:54 +01001421 /// CHECK-DAG: <<ConstNaN:d\d+>> DoubleConstant nan
1422 /// CHECK-DAG: <<Convert:i\d+>> TypeConversion [<<ConstNaN>>]
1423 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001424
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001425 /// CHECK-START: int Main.ReturnInt0() constant_folding$after_inlining (after)
David Brazdila06d66a2015-05-28 11:14:54 +01001426 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0
1427 /// CHECK-DAG: Return [<<Const0>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001428
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001429 /// CHECK-START: int Main.ReturnInt0() constant_folding$after_inlining (after)
Roland Levillainb65eb502015-07-23 12:11:42 +01001430 /// CHECK-NOT: TypeConversion
1431
Mark Mendelle82549b2015-05-06 10:55:34 -04001432 public static int ReturnInt0() {
David Brazdilf02c3cf2016-02-29 09:14:51 +00001433 double imm = $inline$double(Double.NaN);
Mark Mendelle82549b2015-05-06 10:55:34 -04001434 return (int) imm;
1435 }
1436
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001437 /// CHECK-START: long Main.ReturnLong33() constant_folding$after_inlining (before)
David Brazdila06d66a2015-05-28 11:14:54 +01001438 /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33
1439 /// CHECK-DAG: <<Convert:j\d+>> TypeConversion [<<Const33>>]
1440 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001441
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001442 /// CHECK-START: long Main.ReturnLong33() constant_folding$after_inlining (after)
David Brazdila06d66a2015-05-28 11:14:54 +01001443 /// CHECK-DAG: <<Const33:j\d+>> LongConstant 33
1444 /// CHECK-DAG: Return [<<Const33>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001445
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001446 /// CHECK-START: long Main.ReturnLong33() constant_folding$after_inlining (after)
Roland Levillainb65eb502015-07-23 12:11:42 +01001447 /// CHECK-NOT: TypeConversion
1448
Mark Mendelle82549b2015-05-06 10:55:34 -04001449 public static long ReturnLong33() {
David Brazdilf02c3cf2016-02-29 09:14:51 +00001450 int imm = $inline$int(33);
Mark Mendelle82549b2015-05-06 10:55:34 -04001451 return (long) imm;
1452 }
1453
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001454 /// CHECK-START: long Main.ReturnLong34() constant_folding$after_inlining (before)
David Brazdila06d66a2015-05-28 11:14:54 +01001455 /// CHECK-DAG: <<Const34:f\d+>> FloatConstant 34
1456 /// CHECK-DAG: <<Convert:j\d+>> TypeConversion [<<Const34>>]
1457 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001458
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001459 /// CHECK-START: long Main.ReturnLong34() constant_folding$after_inlining (after)
David Brazdila06d66a2015-05-28 11:14:54 +01001460 /// CHECK-DAG: <<Const34:j\d+>> LongConstant 34
1461 /// CHECK-DAG: Return [<<Const34>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001462
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001463 /// CHECK-START: long Main.ReturnLong34() constant_folding$after_inlining (after)
Roland Levillainb65eb502015-07-23 12:11:42 +01001464 /// CHECK-NOT: TypeConversion
1465
Mark Mendelle82549b2015-05-06 10:55:34 -04001466 public static long ReturnLong34() {
David Brazdilf02c3cf2016-02-29 09:14:51 +00001467 float imm = $inline$float(34.0f);
Mark Mendelle82549b2015-05-06 10:55:34 -04001468 return (long) imm;
1469 }
1470
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001471 /// CHECK-START: long Main.ReturnLong0() constant_folding$after_inlining (before)
David Brazdila06d66a2015-05-28 11:14:54 +01001472 /// CHECK-DAG: <<ConstNaN:d\d+>> DoubleConstant nan
1473 /// CHECK-DAG: <<Convert:j\d+>> TypeConversion [<<ConstNaN>>]
1474 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001475
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001476 /// CHECK-START: long Main.ReturnLong0() constant_folding$after_inlining (after)
David Brazdila06d66a2015-05-28 11:14:54 +01001477 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0
1478 /// CHECK-DAG: Return [<<Const0>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001479
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001480 /// CHECK-START: long Main.ReturnLong0() constant_folding$after_inlining (after)
Roland Levillainb65eb502015-07-23 12:11:42 +01001481 /// CHECK-NOT: TypeConversion
1482
Mark Mendelle82549b2015-05-06 10:55:34 -04001483 public static long ReturnLong0() {
David Brazdilf02c3cf2016-02-29 09:14:51 +00001484 double imm = $inline$double(-Double.NaN);
Mark Mendelle82549b2015-05-06 10:55:34 -04001485 return (long) imm;
1486 }
1487
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001488 /// CHECK-START: float Main.ReturnFloat33() constant_folding$after_inlining (before)
David Brazdila06d66a2015-05-28 11:14:54 +01001489 /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33
1490 /// CHECK-DAG: <<Convert:f\d+>> TypeConversion [<<Const33>>]
1491 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001492
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001493 /// CHECK-START: float Main.ReturnFloat33() constant_folding$after_inlining (after)
David Brazdila06d66a2015-05-28 11:14:54 +01001494 /// CHECK-DAG: <<Const33:f\d+>> FloatConstant 33
1495 /// CHECK-DAG: Return [<<Const33>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001496
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001497 /// CHECK-START: float Main.ReturnFloat33() constant_folding$after_inlining (after)
Roland Levillainb65eb502015-07-23 12:11:42 +01001498 /// CHECK-NOT: TypeConversion
1499
Mark Mendelle82549b2015-05-06 10:55:34 -04001500 public static float ReturnFloat33() {
David Brazdilf02c3cf2016-02-29 09:14:51 +00001501 int imm = $inline$int(33);
Mark Mendelle82549b2015-05-06 10:55:34 -04001502 return (float) imm;
1503 }
1504
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001505 /// CHECK-START: float Main.ReturnFloat34() constant_folding$after_inlining (before)
David Brazdila06d66a2015-05-28 11:14:54 +01001506 /// CHECK-DAG: <<Const34:j\d+>> LongConstant 34
1507 /// CHECK-DAG: <<Convert:f\d+>> TypeConversion [<<Const34>>]
1508 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001509
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001510 /// CHECK-START: float Main.ReturnFloat34() constant_folding$after_inlining (after)
David Brazdila06d66a2015-05-28 11:14:54 +01001511 /// CHECK-DAG: <<Const34:f\d+>> FloatConstant 34
1512 /// CHECK-DAG: Return [<<Const34>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001513
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001514 /// CHECK-START: float Main.ReturnFloat34() constant_folding$after_inlining (after)
Roland Levillainb65eb502015-07-23 12:11:42 +01001515 /// CHECK-NOT: TypeConversion
1516
Mark Mendelle82549b2015-05-06 10:55:34 -04001517 public static float ReturnFloat34() {
David Brazdilf02c3cf2016-02-29 09:14:51 +00001518 long imm = $inline$long(34L);
Mark Mendelle82549b2015-05-06 10:55:34 -04001519 return (float) imm;
1520 }
1521
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001522 /// CHECK-START: float Main.ReturnFloat99P25() constant_folding$after_inlining (before)
David Brazdila06d66a2015-05-28 11:14:54 +01001523 /// CHECK-DAG: <<Const:d\d+>> DoubleConstant 99.25
1524 /// CHECK-DAG: <<Convert:f\d+>> TypeConversion [<<Const>>]
1525 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001526
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001527 /// CHECK-START: float Main.ReturnFloat99P25() constant_folding$after_inlining (after)
David Brazdila06d66a2015-05-28 11:14:54 +01001528 /// CHECK-DAG: <<Const:f\d+>> FloatConstant 99.25
1529 /// CHECK-DAG: Return [<<Const>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001530
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001531 /// CHECK-START: float Main.ReturnFloat99P25() constant_folding$after_inlining (after)
Roland Levillainb65eb502015-07-23 12:11:42 +01001532 /// CHECK-NOT: TypeConversion
1533
Mark Mendelle82549b2015-05-06 10:55:34 -04001534 public static float ReturnFloat99P25() {
David Brazdilf02c3cf2016-02-29 09:14:51 +00001535 double imm = $inline$double(99.25);
Mark Mendelle82549b2015-05-06 10:55:34 -04001536 return (float) imm;
1537 }
1538
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001539 /// CHECK-START: double Main.ReturnDouble33() constant_folding$after_inlining (before)
David Brazdila06d66a2015-05-28 11:14:54 +01001540 /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33
1541 /// CHECK-DAG: <<Convert:d\d+>> TypeConversion [<<Const33>>]
1542 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001543
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001544 /// CHECK-START: double Main.ReturnDouble33() constant_folding$after_inlining (after)
David Brazdila06d66a2015-05-28 11:14:54 +01001545 /// CHECK-DAG: <<Const33:d\d+>> DoubleConstant 33
1546 /// CHECK-DAG: Return [<<Const33>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001547
1548 public static double ReturnDouble33() {
David Brazdilf02c3cf2016-02-29 09:14:51 +00001549 int imm = $inline$int(33);
Mark Mendelle82549b2015-05-06 10:55:34 -04001550 return (double) imm;
1551 }
1552
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001553 /// CHECK-START: double Main.ReturnDouble34() constant_folding$after_inlining (before)
David Brazdila06d66a2015-05-28 11:14:54 +01001554 /// CHECK-DAG: <<Const34:j\d+>> LongConstant 34
1555 /// CHECK-DAG: <<Convert:d\d+>> TypeConversion [<<Const34>>]
1556 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001557
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001558 /// CHECK-START: double Main.ReturnDouble34() constant_folding$after_inlining (after)
David Brazdila06d66a2015-05-28 11:14:54 +01001559 /// CHECK-DAG: <<Const34:d\d+>> DoubleConstant 34
1560 /// CHECK-DAG: Return [<<Const34>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001561
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001562 /// CHECK-START: double Main.ReturnDouble34() constant_folding$after_inlining (after)
Roland Levillainb65eb502015-07-23 12:11:42 +01001563 /// CHECK-NOT: TypeConversion
1564
Mark Mendelle82549b2015-05-06 10:55:34 -04001565 public static double ReturnDouble34() {
David Brazdilf02c3cf2016-02-29 09:14:51 +00001566 long imm = $inline$long(34L);
Mark Mendelle82549b2015-05-06 10:55:34 -04001567 return (double) imm;
1568 }
1569
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001570 /// CHECK-START: double Main.ReturnDouble99P25() constant_folding$after_inlining (before)
David Brazdila06d66a2015-05-28 11:14:54 +01001571 /// CHECK-DAG: <<Const:f\d+>> FloatConstant 99.25
1572 /// CHECK-DAG: <<Convert:d\d+>> TypeConversion [<<Const>>]
1573 /// CHECK-DAG: Return [<<Convert>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001574
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001575 /// CHECK-START: double Main.ReturnDouble99P25() constant_folding$after_inlining (after)
David Brazdila06d66a2015-05-28 11:14:54 +01001576 /// CHECK-DAG: <<Const:d\d+>> DoubleConstant 99.25
1577 /// CHECK-DAG: Return [<<Const>>]
Mark Mendelle82549b2015-05-06 10:55:34 -04001578
Wojciech Staszkiewicz5319d3c2016-08-01 17:48:59 -07001579 /// CHECK-START: double Main.ReturnDouble99P25() constant_folding$after_inlining (after)
Roland Levillainb65eb502015-07-23 12:11:42 +01001580 /// CHECK-NOT: TypeConversion
1581
Mark Mendelle82549b2015-05-06 10:55:34 -04001582 public static double ReturnDouble99P25() {
David Brazdilf02c3cf2016-02-29 09:14:51 +00001583 float imm = $inline$float(99.25f);
Mark Mendelle82549b2015-05-06 10:55:34 -04001584 return (double) imm;
1585 }
1586
Roland Levillainb65eb502015-07-23 12:11:42 +01001587
Roland Levillain31dd3d62016-02-16 12:21:02 +00001588 public static void main(String[] args) throws Exception {
Roland Levillainb65eb502015-07-23 12:11:42 +01001589 assertIntEquals(-42, IntNegation());
Roland Levillainc90bc7c2014-12-11 12:14:33 +00001590 assertLongEquals(-42L, LongNegation());
Roland Levillain31dd3d62016-02-16 12:21:02 +00001591 assertFloatEquals(-42F, FloatNegation());
1592 assertDoubleEquals(-42D, DoubleNegation());
Roland Levillainb65eb502015-07-23 12:11:42 +01001593
1594 assertIntEquals(3, IntAddition1());
1595 assertIntEquals(14, IntAddition2());
1596 assertLongEquals(3L, LongAddition());
Roland Levillain31dd3d62016-02-16 12:21:02 +00001597 assertFloatEquals(3F, FloatAddition());
1598 assertDoubleEquals(3D, DoubleAddition());
Roland Levillainb65eb502015-07-23 12:11:42 +01001599
1600 assertIntEquals(4, IntSubtraction());
1601 assertLongEquals(4L, LongSubtraction());
Roland Levillain31dd3d62016-02-16 12:21:02 +00001602 assertFloatEquals(4F, FloatSubtraction());
1603 assertDoubleEquals(4D, DoubleSubtraction());
Roland Levillainb65eb502015-07-23 12:11:42 +01001604
Roland Levillainf7746ad2015-07-22 14:12:01 +01001605 assertIntEquals(21, IntMultiplication());
1606 assertLongEquals(21L, LongMultiplication());
Roland Levillain31dd3d62016-02-16 12:21:02 +00001607 assertFloatEquals(21F, FloatMultiplication());
1608 assertDoubleEquals(21D, DoubleMultiplication());
Roland Levillainf7746ad2015-07-22 14:12:01 +01001609
1610 assertIntEquals(2, IntDivision());
1611 assertLongEquals(2L, LongDivision());
Roland Levillain31dd3d62016-02-16 12:21:02 +00001612 assertFloatEquals(3.2F, FloatDivision());
1613 assertDoubleEquals(3.2D, DoubleDivision());
Roland Levillainf7746ad2015-07-22 14:12:01 +01001614
1615 assertIntEquals(2, IntRemainder());
1616 assertLongEquals(2L, LongRemainder());
Roland Levillain31dd3d62016-02-16 12:21:02 +00001617 assertFloatEquals(0.5F, FloatRemainder());
1618 assertDoubleEquals(0.5D, DoubleRemainder());
Roland Levillainf7746ad2015-07-22 14:12:01 +01001619
Roland Levillain9867bc72015-08-05 10:21:34 +01001620 assertIntEquals(4, ShlIntLong());
1621 assertLongEquals(12L, ShlLongInt());
1622
1623 assertIntEquals(1, ShrIntLong());
1624 assertLongEquals(2L, ShrLongInt());
1625
1626 assertIntEquals(1073741822, UShrIntLong());
1627 assertLongEquals(4611686018427387901L, UShrLongInt());
1628
1629 assertLongEquals(2, AndIntLong());
1630 assertLongEquals(2, AndLongInt());
1631
1632 assertLongEquals(11, OrIntLong());
1633 assertLongEquals(11, OrLongInt());
1634
1635 assertLongEquals(9, XorIntLong());
1636 assertLongEquals(9, XorLongInt());
1637
Roland Levillainb65eb502015-07-23 12:11:42 +01001638 assertIntEquals(5, StaticCondition());
Vladimir Marko9e23df52015-11-10 17:14:35 +00001639 assertIntEquals(5, StaticConditionNulls());
Roland Levillainb65eb502015-07-23 12:11:42 +01001640
1641 assertIntEquals(7, JumpsAndConditionals(true));
1642 assertIntEquals(3, JumpsAndConditionals(false));
1643
Roland Levillain3b55ebb2015-05-08 13:13:19 +01001644 int arbitrary = 123456; // Value chosen arbitrarily.
Roland Levillainb65eb502015-07-23 12:11:42 +01001645
1646 assertIntEquals(0, And0(arbitrary));
1647 assertLongEquals(0, Mul0(arbitrary));
1648 assertIntEquals(-1, OrAllOnes(arbitrary));
1649 assertLongEquals(0, Rem0(arbitrary));
1650 assertIntEquals(0, Rem1(arbitrary));
1651 assertLongEquals(0, RemN1(arbitrary));
1652 assertIntEquals(0, Shl0(arbitrary));
Roland Levillain9867bc72015-08-05 10:21:34 +01001653 assertLongEquals(0, ShlLong0WithInt(arbitrary));
Roland Levillainb65eb502015-07-23 12:11:42 +01001654 assertLongEquals(0, Shr0(arbitrary));
1655 assertLongEquals(0, SubSameLong(arbitrary));
1656 assertIntEquals(0, UShr0(arbitrary));
1657 assertIntEquals(0, XorSameInt(arbitrary));
1658
Roland Levillain3b55ebb2015-05-08 13:13:19 +01001659 assertFalse(CmpFloatGreaterThanNaN(arbitrary));
1660 assertFalse(CmpDoubleLessThanNaN(arbitrary));
Roland Levillainb65eb502015-07-23 12:11:42 +01001661
Vladimir Markoa341f352016-08-31 12:18:20 +01001662 assertFalse(ConstStringEqualsNull());
1663 assertTrue(ConstStringNotEqualsNull());
1664
Roland Levillain31dd3d62016-02-16 12:21:02 +00001665 Main main = new Main();
1666 assertIntEquals(1, main.smaliCmpLongConstants());
1667 assertIntEquals(-1, main.smaliCmpGtFloatConstants());
1668 assertIntEquals(-1, main.smaliCmpLtFloatConstants());
1669 assertIntEquals(-1, main.smaliCmpGtDoubleConstants());
1670 assertIntEquals(-1, main.smaliCmpLtDoubleConstants());
1671
1672 assertIntEquals(0, main.smaliCmpLongSameConstant());
1673 assertIntEquals(0, main.smaliCmpGtFloatSameConstant());
1674 assertIntEquals(0, main.smaliCmpLtFloatSameConstant());
1675 assertIntEquals(0, main.smaliCmpGtDoubleSameConstant());
1676 assertIntEquals(0, main.smaliCmpLtDoubleSameConstant());
1677
1678 assertIntEquals(1, main.smaliCmpGtFloatConstantWithNaN());
1679 assertIntEquals(-1, main.smaliCmpLtFloatConstantWithNaN());
1680 assertIntEquals(1, main.smaliCmpGtDoubleConstantWithNaN());
1681 assertIntEquals(-1, main.smaliCmpLtDoubleConstantWithNaN());
1682
Roland Levillainb65eb502015-07-23 12:11:42 +01001683 assertIntEquals(33, ReturnInt33());
1684 assertIntEquals(2147483647, ReturnIntMax());
1685 assertIntEquals(0, ReturnInt0());
1686
1687 assertLongEquals(33, ReturnLong33());
1688 assertLongEquals(34, ReturnLong34());
1689 assertLongEquals(0, ReturnLong0());
1690
1691 assertFloatEquals(33, ReturnFloat33());
1692 assertFloatEquals(34, ReturnFloat34());
1693 assertFloatEquals(99.25f, ReturnFloat99P25());
1694
1695 assertDoubleEquals(33, ReturnDouble33());
1696 assertDoubleEquals(34, ReturnDouble34());
1697 assertDoubleEquals(99.25, ReturnDouble99P25());
David Brazdil4846d132015-01-15 19:07:08 +00001698 }
Roland Levillain31dd3d62016-02-16 12:21:02 +00001699
1700 Main() throws ClassNotFoundException {
1701 testCmp = Class.forName("TestCmp");
1702 }
1703
1704 private Class<?> testCmp;
David Brazdilee690a32014-12-01 17:04:16 +00001705}