1 /* 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 17 import java.lang.reflect.Method; 18 19 public class Main { 20 21 // Workaround for b/18051191. 22 class InnerClass {} 23 24 public static void assertFalse(boolean condition) { 25 if (condition) { 26 throw new Error(); 27 } 28 } 29 30 public static void assertIntEquals(int expected, int result) { 31 if (expected != result) { 32 throw new Error("Expected: " + expected + ", found: " + result); 33 } 34 } 35 36 public static void assertLongEquals(long expected, long result) { 37 if (expected != result) { 38 throw new Error("Expected: " + expected + ", found: " + result); 39 } 40 } 41 42 public static void assertFloatEquals(float expected, float result) { 43 if (expected != result) { 44 throw new Error("Expected: " + expected + ", found: " + result); 45 } 46 } 47 48 public static void assertDoubleEquals(double expected, double result) { 49 if (expected != result) { 50 throw new Error("Expected: " + expected + ", found: " + result); 51 } 52 } 53 54 55 // Wrappers around methods located in file TestCmp.smali. 56 57 public int smaliCmpLongConstants() throws Exception { 58 Method m = testCmp.getMethod("$opt$CmpLongConstants"); 59 return (Integer)m.invoke(null); 60 } 61 public int smaliCmpGtFloatConstants() throws Exception { 62 Method m = testCmp.getMethod("$opt$CmpGtFloatConstants"); 63 return (Integer)m.invoke(null); 64 } 65 public int smaliCmpLtFloatConstants() throws Exception { 66 Method m = testCmp.getMethod("$opt$CmpLtFloatConstants"); 67 return (Integer)m.invoke(null); 68 } 69 public int smaliCmpGtDoubleConstants() throws Exception { 70 Method m = testCmp.getMethod("$opt$CmpGtDoubleConstants"); 71 return (Integer)m.invoke(null); 72 } 73 public int smaliCmpLtDoubleConstants() throws Exception { 74 Method m = testCmp.getMethod("$opt$CmpLtDoubleConstants"); 75 return (Integer)m.invoke(null); 76 } 77 78 public int smaliCmpLongSameConstant() throws Exception { 79 Method m = testCmp.getMethod("$opt$CmpLongSameConstant"); 80 return (Integer)m.invoke(null); 81 } 82 public int smaliCmpGtFloatSameConstant() throws Exception { 83 Method m = testCmp.getMethod("$opt$CmpGtFloatSameConstant"); 84 return (Integer)m.invoke(null); 85 } 86 public int smaliCmpLtFloatSameConstant() throws Exception { 87 Method m = testCmp.getMethod("$opt$CmpLtFloatSameConstant"); 88 return (Integer)m.invoke(null); 89 } 90 public int smaliCmpGtDoubleSameConstant() throws Exception { 91 Method m = testCmp.getMethod("$opt$CmpGtDoubleSameConstant"); 92 return (Integer)m.invoke(null); 93 } 94 public int smaliCmpLtDoubleSameConstant() throws Exception { 95 Method m = testCmp.getMethod("$opt$CmpLtDoubleSameConstant"); 96 return (Integer)m.invoke(null); 97 } 98 99 public int smaliCmpGtFloatConstantWithNaN() throws Exception { 100 Method m = testCmp.getMethod("$opt$CmpGtFloatConstantWithNaN"); 101 return (Integer)m.invoke(null); 102 } 103 public int smaliCmpLtFloatConstantWithNaN() throws Exception { 104 Method m = testCmp.getMethod("$opt$CmpLtFloatConstantWithNaN"); 105 return (Integer)m.invoke(null); 106 } 107 public int smaliCmpGtDoubleConstantWithNaN() throws Exception { 108 Method m = testCmp.getMethod("$opt$CmpGtDoubleConstantWithNaN"); 109 return (Integer)m.invoke(null); 110 } 111 public int smaliCmpLtDoubleConstantWithNaN() throws Exception { 112 Method m = testCmp.getMethod("$opt$CmpLtDoubleConstantWithNaN"); 113 return (Integer)m.invoke(null); 114 } 115 116 117 /** 118 * Exercise constant folding on negation. 119 */ 120 121 /// CHECK-START: int Main.IntNegation() constant_folding (before) 122 /// CHECK-DAG: <<Const42:i\d+>> IntConstant 42 123 /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Const42>>] 124 /// CHECK-DAG: Return [<<Neg>>] 125 126 /// CHECK-START: int Main.IntNegation() constant_folding (after) 127 /// CHECK-DAG: <<ConstN42:i\d+>> IntConstant -42 128 /// CHECK-DAG: Return [<<ConstN42>>] 129 130 /// CHECK-START: int Main.IntNegation() constant_folding (after) 131 /// CHECK-NOT: Neg 132 133 public static int IntNegation() { 134 int x, y; 135 x = 42; 136 y = -x; 137 return y; 138 } 139 140 /// CHECK-START: long Main.LongNegation() constant_folding (before) 141 /// CHECK-DAG: <<Const42:j\d+>> LongConstant 42 142 /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Const42>>] 143 /// CHECK-DAG: Return [<<Neg>>] 144 145 /// CHECK-START: long Main.LongNegation() constant_folding (after) 146 /// CHECK-DAG: <<ConstN42:j\d+>> LongConstant -42 147 /// CHECK-DAG: Return [<<ConstN42>>] 148 149 /// CHECK-START: long Main.LongNegation() constant_folding (after) 150 /// CHECK-NOT: Neg 151 152 public static long LongNegation() { 153 long x, y; 154 x = 42L; 155 y = -x; 156 return y; 157 } 158 159 /// CHECK-START: float Main.FloatNegation() constant_folding (before) 160 /// CHECK-DAG: <<Const42:f\d+>> FloatConstant 42 161 /// CHECK-DAG: <<Neg:f\d+>> Neg [<<Const42>>] 162 /// CHECK-DAG: Return [<<Neg>>] 163 164 /// CHECK-START: float Main.FloatNegation() constant_folding (after) 165 /// CHECK-DAG: <<ConstN42:f\d+>> FloatConstant -42 166 /// CHECK-DAG: Return [<<ConstN42>>] 167 168 /// CHECK-START: float Main.FloatNegation() constant_folding (after) 169 /// CHECK-NOT: Neg 170 171 public static float FloatNegation() { 172 float x, y; 173 x = 42F; 174 y = -x; 175 return y; 176 } 177 178 /// CHECK-START: double Main.DoubleNegation() constant_folding (before) 179 /// CHECK-DAG: <<Const42:d\d+>> DoubleConstant 42 180 /// CHECK-DAG: <<Neg:d\d+>> Neg [<<Const42>>] 181 /// CHECK-DAG: Return [<<Neg>>] 182 183 /// CHECK-START: double Main.DoubleNegation() constant_folding (after) 184 /// CHECK-DAG: <<ConstN42:d\d+>> DoubleConstant -42 185 /// CHECK-DAG: Return [<<ConstN42>>] 186 187 /// CHECK-START: double Main.DoubleNegation() constant_folding (after) 188 /// CHECK-NOT: Neg 189 190 public static double DoubleNegation() { 191 double x, y; 192 x = 42D; 193 y = -x; 194 return y; 195 } 196 197 198 /** 199 * Exercise constant folding on addition. 200 */ 201 202 /// CHECK-START: int Main.IntAddition1() constant_folding (before) 203 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 204 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 205 /// CHECK-DAG: <<Add:i\d+>> Add [<<Const1>>,<<Const2>>] 206 /// CHECK-DAG: Return [<<Add>>] 207 208 /// CHECK-START: int Main.IntAddition1() constant_folding (after) 209 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 210 /// CHECK-DAG: Return [<<Const3>>] 211 212 /// CHECK-START: int Main.IntAddition1() constant_folding (after) 213 /// CHECK-NOT: Add 214 215 public static int IntAddition1() { 216 int a, b, c; 217 a = 1; 218 b = 2; 219 c = a + b; 220 return c; 221 } 222 223 /// CHECK-START: int Main.IntAddition2() constant_folding (before) 224 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 225 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 226 /// CHECK-DAG: <<Const5:i\d+>> IntConstant 5 227 /// CHECK-DAG: <<Const6:i\d+>> IntConstant 6 228 /// CHECK-DAG: <<Const11:i\d+>> IntConstant 11 229 /// CHECK-DAG: <<Add1:i\d+>> Add [<<Const1>>,<<Const2>>] 230 /// CHECK-DAG: Add [<<Const5>>,<<Const6>>] 231 /// CHECK-DAG: <<Add3:i\d+>> Add [<<Add1>>,<<Const11>>] 232 /// CHECK-DAG: Return [<<Add3>>] 233 234 /// CHECK-START: int Main.IntAddition2() constant_folding (after) 235 /// CHECK-DAG: <<Const14:i\d+>> IntConstant 14 236 /// CHECK-DAG: Return [<<Const14>>] 237 238 /// CHECK-START: int Main.IntAddition2() constant_folding (after) 239 /// CHECK-NOT: Add 240 241 public static int IntAddition2() { 242 int a, b, c; 243 a = 1; 244 b = 2; 245 a += b; 246 b = 5; 247 c = 6; 248 b += c; 249 c = a + b; 250 return c; 251 } 252 253 /// CHECK-START: long Main.LongAddition() constant_folding (before) 254 /// CHECK-DAG: <<Const1:j\d+>> LongConstant 1 255 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2 256 /// CHECK-DAG: <<Add:j\d+>> Add [<<Const1>>,<<Const2>>] 257 /// CHECK-DAG: Return [<<Add>>] 258 259 /// CHECK-START: long Main.LongAddition() constant_folding (after) 260 /// CHECK-DAG: <<Const3:j\d+>> LongConstant 3 261 /// CHECK-DAG: Return [<<Const3>>] 262 263 /// CHECK-START: long Main.LongAddition() constant_folding (after) 264 /// CHECK-NOT: Add 265 266 public static long LongAddition() { 267 long a, b, c; 268 a = 1L; 269 b = 2L; 270 c = a + b; 271 return c; 272 } 273 274 /// CHECK-START: float Main.FloatAddition() constant_folding (before) 275 /// CHECK-DAG: <<Const1:f\d+>> FloatConstant 1 276 /// CHECK-DAG: <<Const2:f\d+>> FloatConstant 2 277 /// CHECK-DAG: <<Add:f\d+>> Add [<<Const1>>,<<Const2>>] 278 /// CHECK-DAG: Return [<<Add>>] 279 280 /// CHECK-START: float Main.FloatAddition() constant_folding (after) 281 /// CHECK-DAG: <<Const3:f\d+>> FloatConstant 3 282 /// CHECK-DAG: Return [<<Const3>>] 283 284 /// CHECK-START: float Main.FloatAddition() constant_folding (after) 285 /// CHECK-NOT: Add 286 287 public static float FloatAddition() { 288 float a, b, c; 289 a = 1F; 290 b = 2F; 291 c = a + b; 292 return c; 293 } 294 295 /// CHECK-START: double Main.DoubleAddition() constant_folding (before) 296 /// CHECK-DAG: <<Const1:d\d+>> DoubleConstant 1 297 /// CHECK-DAG: <<Const2:d\d+>> DoubleConstant 2 298 /// CHECK-DAG: <<Add:d\d+>> Add [<<Const1>>,<<Const2>>] 299 /// CHECK-DAG: Return [<<Add>>] 300 301 /// CHECK-START: double Main.DoubleAddition() constant_folding (after) 302 /// CHECK-DAG: <<Const3:d\d+>> DoubleConstant 3 303 /// CHECK-DAG: Return [<<Const3>>] 304 305 /// CHECK-START: double Main.DoubleAddition() constant_folding (after) 306 /// CHECK-NOT: Add 307 308 public static double DoubleAddition() { 309 double a, b, c; 310 a = 1D; 311 b = 2D; 312 c = a + b; 313 return c; 314 } 315 316 317 /** 318 * Exercise constant folding on subtraction. 319 */ 320 321 /// CHECK-START: int Main.IntSubtraction() constant_folding (before) 322 /// CHECK-DAG: <<Const6:i\d+>> IntConstant 6 323 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 324 /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Const6>>,<<Const2>>] 325 /// CHECK-DAG: Return [<<Sub>>] 326 327 /// CHECK-START: int Main.IntSubtraction() constant_folding (after) 328 /// CHECK-DAG: <<Const4:i\d+>> IntConstant 4 329 /// CHECK-DAG: Return [<<Const4>>] 330 331 /// CHECK-START: int Main.IntSubtraction() constant_folding (after) 332 /// CHECK-NOT: Sub 333 334 public static int IntSubtraction() { 335 int a, b, c; 336 a = 6; 337 b = 2; 338 c = a - b; 339 return c; 340 } 341 342 /// CHECK-START: long Main.LongSubtraction() constant_folding (before) 343 /// CHECK-DAG: <<Const6:j\d+>> LongConstant 6 344 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2 345 /// CHECK-DAG: <<Sub:j\d+>> Sub [<<Const6>>,<<Const2>>] 346 /// CHECK-DAG: Return [<<Sub>>] 347 348 /// CHECK-START: long Main.LongSubtraction() constant_folding (after) 349 /// CHECK-DAG: <<Const4:j\d+>> LongConstant 4 350 /// CHECK-DAG: Return [<<Const4>>] 351 352 /// CHECK-START: long Main.LongSubtraction() constant_folding (after) 353 /// CHECK-NOT: Sub 354 355 public static long LongSubtraction() { 356 long a, b, c; 357 a = 6L; 358 b = 2L; 359 c = a - b; 360 return c; 361 } 362 363 /// CHECK-START: float Main.FloatSubtraction() constant_folding (before) 364 /// CHECK-DAG: <<Const6:f\d+>> FloatConstant 6 365 /// CHECK-DAG: <<Const2:f\d+>> FloatConstant 2 366 /// CHECK-DAG: <<Sub:f\d+>> Sub [<<Const6>>,<<Const2>>] 367 /// CHECK-DAG: Return [<<Sub>>] 368 369 /// CHECK-START: float Main.FloatSubtraction() constant_folding (after) 370 /// CHECK-DAG: <<Const4:f\d+>> FloatConstant 4 371 /// CHECK-DAG: Return [<<Const4>>] 372 373 /// CHECK-START: float Main.FloatSubtraction() constant_folding (after) 374 /// CHECK-NOT: Sub 375 376 public static float FloatSubtraction() { 377 float a, b, c; 378 a = 6F; 379 b = 2F; 380 c = a - b; 381 return c; 382 } 383 384 /// CHECK-START: double Main.DoubleSubtraction() constant_folding (before) 385 /// CHECK-DAG: <<Const6:d\d+>> DoubleConstant 6 386 /// CHECK-DAG: <<Const2:d\d+>> DoubleConstant 2 387 /// CHECK-DAG: <<Sub:d\d+>> Sub [<<Const6>>,<<Const2>>] 388 /// CHECK-DAG: Return [<<Sub>>] 389 390 /// CHECK-START: double Main.DoubleSubtraction() constant_folding (after) 391 /// CHECK-DAG: <<Const4:d\d+>> DoubleConstant 4 392 /// CHECK-DAG: Return [<<Const4>>] 393 394 /// CHECK-START: double Main.DoubleSubtraction() constant_folding (after) 395 /// CHECK-NOT: Sub 396 397 public static double DoubleSubtraction() { 398 double a, b, c; 399 a = 6D; 400 b = 2D; 401 c = a - b; 402 return c; 403 } 404 405 406 /** 407 * Exercise constant folding on multiplication. 408 */ 409 410 /// CHECK-START: int Main.IntMultiplication() constant_folding (before) 411 /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7 412 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 413 /// CHECK-DAG: <<Mul:i\d+>> Mul [<<Const7>>,<<Const3>>] 414 /// CHECK-DAG: Return [<<Mul>>] 415 416 /// CHECK-START: int Main.IntMultiplication() constant_folding (after) 417 /// CHECK-DAG: <<Const21:i\d+>> IntConstant 21 418 /// CHECK-DAG: Return [<<Const21>>] 419 420 /// CHECK-START: int Main.IntMultiplication() constant_folding (after) 421 /// CHECK-NOT: Mul 422 423 public static int IntMultiplication() { 424 int a, b, c; 425 a = 7; 426 b = 3; 427 c = a * b; 428 return c; 429 } 430 431 /// CHECK-START: long Main.LongMultiplication() constant_folding (before) 432 /// CHECK-DAG: <<Const7:j\d+>> LongConstant 7 433 /// CHECK-DAG: <<Const3:j\d+>> LongConstant 3 434 /// CHECK-DAG: <<Mul:j\d+>> Mul [<<Const7>>,<<Const3>>] 435 /// CHECK-DAG: Return [<<Mul>>] 436 437 /// CHECK-START: long Main.LongMultiplication() constant_folding (after) 438 /// CHECK-DAG: <<Const21:j\d+>> LongConstant 21 439 /// CHECK-DAG: Return [<<Const21>>] 440 441 /// CHECK-START: long Main.LongMultiplication() constant_folding (after) 442 /// CHECK-NOT: Mul 443 444 public static long LongMultiplication() { 445 long a, b, c; 446 a = 7L; 447 b = 3L; 448 c = a * b; 449 return c; 450 } 451 452 /// CHECK-START: float Main.FloatMultiplication() constant_folding (before) 453 /// CHECK-DAG: <<Const7:f\d+>> FloatConstant 7 454 /// CHECK-DAG: <<Const3:f\d+>> FloatConstant 3 455 /// CHECK-DAG: <<Mul:f\d+>> Mul [<<Const7>>,<<Const3>>] 456 /// CHECK-DAG: Return [<<Mul>>] 457 458 /// CHECK-START: float Main.FloatMultiplication() constant_folding (after) 459 /// CHECK-DAG: <<Const21:f\d+>> FloatConstant 21 460 /// CHECK-DAG: Return [<<Const21>>] 461 462 /// CHECK-START: float Main.FloatMultiplication() constant_folding (after) 463 /// CHECK-NOT: Mul 464 465 public static float FloatMultiplication() { 466 float a, b, c; 467 a = 7F; 468 b = 3F; 469 c = a * b; 470 return c; 471 } 472 473 /// CHECK-START: double Main.DoubleMultiplication() constant_folding (before) 474 /// CHECK-DAG: <<Const7:d\d+>> DoubleConstant 7 475 /// CHECK-DAG: <<Const3:d\d+>> DoubleConstant 3 476 /// CHECK-DAG: <<Mul:d\d+>> Mul [<<Const7>>,<<Const3>>] 477 /// CHECK-DAG: Return [<<Mul>>] 478 479 /// CHECK-START: double Main.DoubleMultiplication() constant_folding (after) 480 /// CHECK-DAG: <<Const21:d\d+>> DoubleConstant 21 481 /// CHECK-DAG: Return [<<Const21>>] 482 483 /// CHECK-START: double Main.DoubleMultiplication() constant_folding (after) 484 /// CHECK-NOT: Mul 485 486 public static double DoubleMultiplication() { 487 double a, b, c; 488 a = 7D; 489 b = 3D; 490 c = a * b; 491 return c; 492 } 493 494 495 /** 496 * Exercise constant folding on division. 497 */ 498 499 /// CHECK-START: int Main.IntDivision() constant_folding (before) 500 /// CHECK-DAG: <<Const8:i\d+>> IntConstant 8 501 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 502 /// CHECK-DAG: <<Div0Chk:i\d+>> DivZeroCheck [<<Const3>>] 503 /// CHECK-DAG: <<Div:i\d+>> Div [<<Const8>>,<<Div0Chk>>] 504 /// CHECK-DAG: Return [<<Div>>] 505 506 /// CHECK-START: int Main.IntDivision() constant_folding (after) 507 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 508 /// CHECK-DAG: Return [<<Const2>>] 509 510 /// CHECK-START: int Main.IntDivision() constant_folding (after) 511 /// CHECK-NOT: DivZeroCheck 512 /// CHECK-NOT: Div 513 514 public static int IntDivision() { 515 int a, b, c; 516 a = 8; 517 b = 3; 518 c = a / b; 519 return c; 520 } 521 522 /// CHECK-START: long Main.LongDivision() constant_folding (before) 523 /// CHECK-DAG: <<Const8:j\d+>> LongConstant 8 524 /// CHECK-DAG: <<Const3:j\d+>> LongConstant 3 525 /// CHECK-DAG: <<Div0Chk:j\d+>> DivZeroCheck [<<Const3>>] 526 /// CHECK-DAG: <<Div:j\d+>> Div [<<Const8>>,<<Div0Chk>>] 527 /// CHECK-DAG: Return [<<Div>>] 528 529 /// CHECK-START: long Main.LongDivision() constant_folding (after) 530 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2 531 /// CHECK-DAG: Return [<<Const2>>] 532 533 /// CHECK-START: long Main.LongDivision() constant_folding (after) 534 /// CHECK-NOT: DivZeroCheck 535 /// CHECK-NOT: Div 536 537 public static long LongDivision() { 538 long a, b, c; 539 a = 8L; 540 b = 3L; 541 c = a / b; 542 return c; 543 } 544 545 /// CHECK-START: float Main.FloatDivision() constant_folding (before) 546 /// CHECK-DAG: <<Const8:f\d+>> FloatConstant 8 547 /// CHECK-DAG: <<Const2P5:f\d+>> FloatConstant 2.5 548 /// CHECK-DAG: <<Div:f\d+>> Div [<<Const8>>,<<Const2P5>>] 549 /// CHECK-DAG: Return [<<Div>>] 550 551 /// CHECK-START: float Main.FloatDivision() constant_folding (after) 552 /// CHECK-DAG: <<Const3P2:f\d+>> FloatConstant 3.2 553 /// CHECK-DAG: Return [<<Const3P2>>] 554 555 /// CHECK-START: float Main.FloatDivision() constant_folding (after) 556 /// CHECK-NOT: Div 557 558 public static float FloatDivision() { 559 float a, b, c; 560 a = 8F; 561 b = 2.5F; 562 c = a / b; 563 return c; 564 } 565 566 /// CHECK-START: double Main.DoubleDivision() constant_folding (before) 567 /// CHECK-DAG: <<Const8:d\d+>> DoubleConstant 8 568 /// CHECK-DAG: <<Const2P5:d\d+>> DoubleConstant 2.5 569 /// CHECK-DAG: <<Div:d\d+>> Div [<<Const8>>,<<Const2P5>>] 570 /// CHECK-DAG: Return [<<Div>>] 571 572 /// CHECK-START: double Main.DoubleDivision() constant_folding (after) 573 /// CHECK-DAG: <<Const3P2:d\d+>> DoubleConstant 3.2 574 /// CHECK-DAG: Return [<<Const3P2>>] 575 576 /// CHECK-START: double Main.DoubleDivision() constant_folding (after) 577 /// CHECK-NOT: Div 578 579 public static double DoubleDivision() { 580 double a, b, c; 581 a = 8D; 582 b = 2.5D; 583 c = a / b; 584 return c; 585 } 586 587 588 /** 589 * Exercise constant folding on remainder. 590 */ 591 592 /// CHECK-START: int Main.IntRemainder() constant_folding (before) 593 /// CHECK-DAG: <<Const8:i\d+>> IntConstant 8 594 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 595 /// CHECK-DAG: <<Div0Chk:i\d+>> DivZeroCheck [<<Const3>>] 596 /// CHECK-DAG: <<Rem:i\d+>> Rem [<<Const8>>,<<Div0Chk>>] 597 /// CHECK-DAG: Return [<<Rem>>] 598 599 /// CHECK-START: int Main.IntRemainder() constant_folding (after) 600 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 601 /// CHECK-DAG: Return [<<Const2>>] 602 603 /// CHECK-START: int Main.IntRemainder() constant_folding (after) 604 /// CHECK-NOT: DivZeroCheck 605 /// CHECK-NOT: Rem 606 607 public static int IntRemainder() { 608 int a, b, c; 609 a = 8; 610 b = 3; 611 c = a % b; 612 return c; 613 } 614 615 /// CHECK-START: long Main.LongRemainder() constant_folding (before) 616 /// CHECK-DAG: <<Const8:j\d+>> LongConstant 8 617 /// CHECK-DAG: <<Const3:j\d+>> LongConstant 3 618 /// CHECK-DAG: <<Div0Chk:j\d+>> DivZeroCheck [<<Const3>>] 619 /// CHECK-DAG: <<Rem:j\d+>> Rem [<<Const8>>,<<Div0Chk>>] 620 /// CHECK-DAG: Return [<<Rem>>] 621 622 /// CHECK-START: long Main.LongRemainder() constant_folding (after) 623 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2 624 /// CHECK-DAG: Return [<<Const2>>] 625 626 /// CHECK-START: long Main.LongRemainder() constant_folding (after) 627 /// CHECK-NOT: DivZeroCheck 628 /// CHECK-NOT: Rem 629 630 public static long LongRemainder() { 631 long a, b, c; 632 a = 8L; 633 b = 3L; 634 c = a % b; 635 return c; 636 } 637 638 /// CHECK-START: float Main.FloatRemainder() constant_folding (before) 639 /// CHECK-DAG: <<Const8:f\d+>> FloatConstant 8 640 /// CHECK-DAG: <<Const2P5:f\d+>> FloatConstant 2.5 641 /// CHECK-DAG: <<Rem:f\d+>> Rem [<<Const8>>,<<Const2P5>>] 642 /// CHECK-DAG: Return [<<Rem>>] 643 644 /// CHECK-START: float Main.FloatRemainder() constant_folding (after) 645 /// CHECK-DAG: <<Const0P5:f\d+>> FloatConstant 0.5 646 /// CHECK-DAG: Return [<<Const0P5>>] 647 648 /// CHECK-START: float Main.FloatRemainder() constant_folding (after) 649 /// CHECK-NOT: Rem 650 651 public static float FloatRemainder() { 652 float a, b, c; 653 a = 8F; 654 b = 2.5F; 655 c = a % b; 656 return c; 657 } 658 659 /// CHECK-START: double Main.DoubleRemainder() constant_folding (before) 660 /// CHECK-DAG: <<Const8:d\d+>> DoubleConstant 8 661 /// CHECK-DAG: <<Const2P5:d\d+>> DoubleConstant 2.5 662 /// CHECK-DAG: <<Rem:d\d+>> Rem [<<Const8>>,<<Const2P5>>] 663 /// CHECK-DAG: Return [<<Rem>>] 664 665 /// CHECK-START: double Main.DoubleRemainder() constant_folding (after) 666 /// CHECK-DAG: <<Const0P5:d\d+>> DoubleConstant 0.5 667 /// CHECK-DAG: Return [<<Const0P5>>] 668 669 /// CHECK-START: double Main.DoubleRemainder() constant_folding (after) 670 /// CHECK-NOT: Rem 671 672 public static double DoubleRemainder() { 673 double a, b, c; 674 a = 8D; 675 b = 2.5D; 676 c = a % b; 677 return c; 678 } 679 680 681 /** 682 * Exercise constant folding on left shift. 683 */ 684 685 /// CHECK-START: int Main.ShlIntLong() constant_folding (before) 686 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 687 /// CHECK-DAG: <<Const2L:j\d+>> LongConstant 2 688 /// CHECK-DAG: <<TypeConv:i\d+>> TypeConversion [<<Const2L>>] 689 /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Const1>>,<<TypeConv>>] 690 /// CHECK-DAG: Return [<<Shl>>] 691 692 /// CHECK-START: int Main.ShlIntLong() constant_folding (after) 693 /// CHECK-DAG: <<Const4:i\d+>> IntConstant 4 694 /// CHECK-DAG: Return [<<Const4>>] 695 696 /// CHECK-START: int Main.ShlIntLong() constant_folding (after) 697 /// CHECK-NOT: Shl 698 699 public static int ShlIntLong() { 700 int lhs = 1; 701 long rhs = 2; 702 return lhs << rhs; 703 } 704 705 /// CHECK-START: long Main.ShlLongInt() constant_folding (before) 706 /// CHECK-DAG: <<Const3L:j\d+>> LongConstant 3 707 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 708 /// CHECK-DAG: <<Shl:j\d+>> Shl [<<Const3L>>,<<Const2>>] 709 /// CHECK-DAG: Return [<<Shl>>] 710 711 /// CHECK-START: long Main.ShlLongInt() constant_folding (after) 712 /// CHECK-DAG: <<Const12L:j\d+>> LongConstant 12 713 /// CHECK-DAG: Return [<<Const12L>>] 714 715 /// CHECK-START: long Main.ShlLongInt() constant_folding (after) 716 /// CHECK-NOT: Shl 717 718 public static long ShlLongInt() { 719 long lhs = 3; 720 int rhs = 2; 721 return lhs << rhs; 722 } 723 724 725 /** 726 * Exercise constant folding on right shift. 727 */ 728 729 /// CHECK-START: int Main.ShrIntLong() constant_folding (before) 730 /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7 731 /// CHECK-DAG: <<Const2L:j\d+>> LongConstant 2 732 /// CHECK-DAG: <<TypeConv:i\d+>> TypeConversion [<<Const2L>>] 733 /// CHECK-DAG: <<Shr:i\d+>> Shr [<<Const7>>,<<TypeConv>>] 734 /// CHECK-DAG: Return [<<Shr>>] 735 736 /// CHECK-START: int Main.ShrIntLong() constant_folding (after) 737 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 738 /// CHECK-DAG: Return [<<Const1>>] 739 740 /// CHECK-START: int Main.ShrIntLong() constant_folding (after) 741 /// CHECK-NOT: Shr 742 743 public static int ShrIntLong() { 744 int lhs = 7; 745 long rhs = 2; 746 return lhs >> rhs; 747 } 748 749 /// CHECK-START: long Main.ShrLongInt() constant_folding (before) 750 /// CHECK-DAG: <<Const9L:j\d+>> LongConstant 9 751 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 752 /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Const9L>>,<<Const2>>] 753 /// CHECK-DAG: Return [<<Shr>>] 754 755 /// CHECK-START: long Main.ShrLongInt() constant_folding (after) 756 /// CHECK-DAG: <<Const2L:j\d+>> LongConstant 2 757 /// CHECK-DAG: Return [<<Const2L>>] 758 759 /// CHECK-START: long Main.ShrLongInt() constant_folding (after) 760 /// CHECK-NOT: Shr 761 762 public static long ShrLongInt() { 763 long lhs = 9; 764 int rhs = 2; 765 return lhs >> rhs; 766 } 767 768 769 /** 770 * Exercise constant folding on unsigned right shift. 771 */ 772 773 /// CHECK-START: int Main.UShrIntLong() constant_folding (before) 774 /// CHECK-DAG: <<ConstM7:i\d+>> IntConstant -7 775 /// CHECK-DAG: <<Const2L:j\d+>> LongConstant 2 776 /// CHECK-DAG: <<TypeConv:i\d+>> TypeConversion [<<Const2L>>] 777 /// CHECK-DAG: <<UShr:i\d+>> UShr [<<ConstM7>>,<<TypeConv>>] 778 /// CHECK-DAG: Return [<<UShr>>] 779 780 /// CHECK-START: int Main.UShrIntLong() constant_folding (after) 781 /// CHECK-DAG: <<ConstRes:i\d+>> IntConstant 1073741822 782 /// CHECK-DAG: Return [<<ConstRes>>] 783 784 /// CHECK-START: int Main.UShrIntLong() constant_folding (after) 785 /// CHECK-NOT: UShr 786 787 public static int UShrIntLong() { 788 int lhs = -7; 789 long rhs = 2; 790 return lhs >>> rhs; 791 } 792 793 /// CHECK-START: long Main.UShrLongInt() constant_folding (before) 794 /// CHECK-DAG: <<ConstM9L:j\d+>> LongConstant -9 795 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 796 /// CHECK-DAG: <<UShr:j\d+>> UShr [<<ConstM9L>>,<<Const2>>] 797 /// CHECK-DAG: Return [<<UShr>>] 798 799 /// CHECK-START: long Main.UShrLongInt() constant_folding (after) 800 /// CHECK-DAG: <<ConstRes:j\d+>> LongConstant 4611686018427387901 801 /// CHECK-DAG: Return [<<ConstRes>>] 802 803 /// CHECK-START: long Main.UShrLongInt() constant_folding (after) 804 /// CHECK-NOT: UShr 805 806 public static long UShrLongInt() { 807 long lhs = -9; 808 int rhs = 2; 809 return lhs >>> rhs; 810 } 811 812 813 /** 814 * Exercise constant folding on logical and. 815 */ 816 817 /// CHECK-START: long Main.AndIntLong() constant_folding (before) 818 /// CHECK-DAG: <<Const10:i\d+>> IntConstant 10 819 /// CHECK-DAG: <<Const3L:j\d+>> LongConstant 3 820 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const10>>] 821 /// CHECK-DAG: <<And:j\d+>> And [<<TypeConv>>,<<Const3L>>] 822 /// CHECK-DAG: Return [<<And>>] 823 824 /// CHECK-START: long Main.AndIntLong() constant_folding (after) 825 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2 826 /// CHECK-DAG: Return [<<Const2>>] 827 828 /// CHECK-START: long Main.AndIntLong() constant_folding (after) 829 /// CHECK-NOT: And 830 831 public static long AndIntLong() { 832 int lhs = 10; 833 long rhs = 3; 834 return lhs & rhs; 835 } 836 837 /// CHECK-START: long Main.AndLongInt() constant_folding (before) 838 /// CHECK-DAG: <<Const10L:j\d+>> LongConstant 10 839 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 840 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const3>>] 841 /// CHECK-DAG: <<And:j\d+>> And [<<TypeConv>>,<<Const10L>>] 842 /// CHECK-DAG: Return [<<And>>] 843 844 /// CHECK-START: long Main.AndLongInt() constant_folding (after) 845 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2 846 /// CHECK-DAG: Return [<<Const2>>] 847 848 /// CHECK-START: long Main.AndLongInt() constant_folding (after) 849 /// CHECK-NOT: And 850 851 public static long AndLongInt() { 852 long lhs = 10; 853 int rhs = 3; 854 return lhs & rhs; 855 } 856 857 858 /** 859 * Exercise constant folding on logical or. 860 */ 861 862 /// CHECK-START: long Main.OrIntLong() constant_folding (before) 863 /// CHECK-DAG: <<Const10:i\d+>> IntConstant 10 864 /// CHECK-DAG: <<Const3L:j\d+>> LongConstant 3 865 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const10>>] 866 /// CHECK-DAG: <<Or:j\d+>> Or [<<TypeConv>>,<<Const3L>>] 867 /// CHECK-DAG: Return [<<Or>>] 868 869 /// CHECK-START: long Main.OrIntLong() constant_folding (after) 870 /// CHECK-DAG: <<Const11:j\d+>> LongConstant 11 871 /// CHECK-DAG: Return [<<Const11>>] 872 873 /// CHECK-START: long Main.OrIntLong() constant_folding (after) 874 /// CHECK-NOT: Or 875 876 public static long OrIntLong() { 877 int lhs = 10; 878 long rhs = 3; 879 return lhs | rhs; 880 } 881 882 /// CHECK-START: long Main.OrLongInt() constant_folding (before) 883 /// CHECK-DAG: <<Const10L:j\d+>> LongConstant 10 884 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 885 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const3>>] 886 /// CHECK-DAG: <<Or:j\d+>> Or [<<TypeConv>>,<<Const10L>>] 887 /// CHECK-DAG: Return [<<Or>>] 888 889 /// CHECK-START: long Main.OrLongInt() constant_folding (after) 890 /// CHECK-DAG: <<Const11:j\d+>> LongConstant 11 891 /// CHECK-DAG: Return [<<Const11>>] 892 893 /// CHECK-START: long Main.OrLongInt() constant_folding (after) 894 /// CHECK-NOT: Or 895 896 public static long OrLongInt() { 897 long lhs = 10; 898 int rhs = 3; 899 return lhs | rhs; 900 } 901 902 903 /** 904 * Exercise constant folding on logical exclusive or. 905 */ 906 907 /// CHECK-START: long Main.XorIntLong() constant_folding (before) 908 /// CHECK-DAG: <<Const10:i\d+>> IntConstant 10 909 /// CHECK-DAG: <<Const3L:j\d+>> LongConstant 3 910 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const10>>] 911 /// CHECK-DAG: <<Xor:j\d+>> Xor [<<TypeConv>>,<<Const3L>>] 912 /// CHECK-DAG: Return [<<Xor>>] 913 914 /// CHECK-START: long Main.XorIntLong() constant_folding (after) 915 /// CHECK-DAG: <<Const9:j\d+>> LongConstant 9 916 /// CHECK-DAG: Return [<<Const9>>] 917 918 /// CHECK-START: long Main.XorIntLong() constant_folding (after) 919 /// CHECK-NOT: Xor 920 921 public static long XorIntLong() { 922 int lhs = 10; 923 long rhs = 3; 924 return lhs ^ rhs; 925 } 926 927 /// CHECK-START: long Main.XorLongInt() constant_folding (before) 928 /// CHECK-DAG: <<Const10L:j\d+>> LongConstant 10 929 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 930 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const3>>] 931 /// CHECK-DAG: <<Xor:j\d+>> Xor [<<TypeConv>>,<<Const10L>>] 932 /// CHECK-DAG: Return [<<Xor>>] 933 934 /// CHECK-START: long Main.XorLongInt() constant_folding (after) 935 /// CHECK-DAG: <<Const9:j\d+>> LongConstant 9 936 /// CHECK-DAG: Return [<<Const9>>] 937 938 /// CHECK-START: long Main.XorLongInt() constant_folding (after) 939 /// CHECK-NOT: Xor 940 941 public static long XorLongInt() { 942 long lhs = 10; 943 int rhs = 3; 944 return lhs ^ rhs; 945 } 946 947 948 /** 949 * Exercise constant folding on constant (static) condition. 950 */ 951 952 /// CHECK-START: int Main.StaticCondition() constant_folding (before) 953 /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7 954 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 955 /// CHECK-DAG: <<Cond:z\d+>> GreaterThanOrEqual [<<Const7>>,<<Const2>>] 956 /// CHECK-DAG: If [<<Cond>>] 957 958 /// CHECK-START: int Main.StaticCondition() constant_folding (after) 959 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 960 /// CHECK-DAG: If [<<Const1>>] 961 962 /// CHECK-START: int Main.StaticCondition() constant_folding (after) 963 /// CHECK-NOT: GreaterThanOrEqual 964 965 public static int StaticCondition() { 966 int a, b, c; 967 a = 7; 968 b = 2; 969 if (a < b) 970 c = a + b; 971 else 972 c = a - b; 973 return c; 974 } 975 976 977 /** 978 * Exercise constant folding on constant (static) condition for null references. 979 */ 980 981 /// CHECK-START: int Main.StaticConditionNulls() constant_folding$after_inlining (before) 982 /// CHECK-DAG: <<Null:l\d+>> NullConstant 983 /// CHECK-DAG: <<Cond:z\d+>> NotEqual [<<Null>>,<<Null>>] 984 /// CHECK-DAG: Select [{{i\d+}},{{i\d+}},<<Cond>>] 985 986 /// CHECK-START: int Main.StaticConditionNulls() constant_folding$after_inlining (after) 987 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 988 /// CHECK-DAG: Select [{{i\d+}},{{i\d+}},<<Const0>>] 989 990 /// CHECK-START: int Main.StaticConditionNulls() constant_folding$after_inlining (after) 991 /// CHECK-NOT: NotEqual 992 993 private static Object getNull() { 994 return null; 995 } 996 997 public static int StaticConditionNulls() { 998 Object a = getNull(); 999 Object b = getNull(); 1000 return (a == b) ? 5 : 2; 1001 } 1002 1003 1004 /** 1005 * Exercise constant folding on a program with condition 1006 * (i.e. jumps) leading to the creation of many blocks. 1007 * 1008 * The intent of this test is to ensure that all constant expressions 1009 * are actually evaluated at compile-time, thanks to the reverse 1010 * (forward) post-order traversal of the the dominator tree. 1011 */ 1012 1013 /// CHECK-START: int Main.JumpsAndConditionals(boolean) constant_folding (before) 1014 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 1015 /// CHECK-DAG: <<Const5:i\d+>> IntConstant 5 1016 /// CHECK-DAG: <<Add:i\d+>> Add [<<Const5>>,<<Const2>>] 1017 /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Const5>>,<<Const2>>] 1018 /// CHECK-DAG: <<Phi:i\d+>> Phi [<<Add>>,<<Sub>>] 1019 /// CHECK-DAG: Return [<<Phi>>] 1020 1021 /// CHECK-START: int Main.JumpsAndConditionals(boolean) constant_folding (after) 1022 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 1023 /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7 1024 /// CHECK-DAG: <<Phi:i\d+>> Phi [<<Const7>>,<<Const3>>] 1025 /// CHECK-DAG: Return [<<Phi>>] 1026 1027 /// CHECK-START: int Main.JumpsAndConditionals(boolean) constant_folding (after) 1028 /// CHECK-NOT: Add 1029 /// CHECK-NOT: Sub 1030 1031 public static int JumpsAndConditionals(boolean cond) { 1032 int a, b, c; 1033 a = 5; 1034 b = 2; 1035 if (cond) 1036 c = a + b; 1037 else 1038 c = a - b; 1039 return c; 1040 } 1041 1042 1043 /** 1044 * Test optimizations of arithmetic identities yielding a constant result. 1045 */ 1046 1047 /// CHECK-START: int Main.And0(int) constant_folding (before) 1048 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1049 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 1050 /// CHECK-DAG: <<And:i\d+>> And [<<Arg>>,<<Const0>>] 1051 /// CHECK-DAG: Return [<<And>>] 1052 1053 /// CHECK-START: int Main.And0(int) constant_folding (after) 1054 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1055 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 1056 /// CHECK-DAG: Return [<<Const0>>] 1057 1058 /// CHECK-START: int Main.And0(int) constant_folding (after) 1059 /// CHECK-NOT: And 1060 1061 public static int And0(int arg) { 1062 return arg & 0; 1063 } 1064 1065 /// CHECK-START: long Main.Mul0(long) constant_folding (before) 1066 /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 1067 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0 1068 /// CHECK-DAG: <<Mul:j\d+>> Mul [<<Const0>>,<<Arg>>] 1069 /// CHECK-DAG: Return [<<Mul>>] 1070 1071 /// CHECK-START: long Main.Mul0(long) constant_folding (after) 1072 /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 1073 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0 1074 /// CHECK-DAG: Return [<<Const0>>] 1075 1076 /// CHECK-START: long Main.Mul0(long) constant_folding (after) 1077 /// CHECK-NOT: Mul 1078 1079 public static long Mul0(long arg) { 1080 return arg * 0; 1081 } 1082 1083 /// CHECK-START: int Main.OrAllOnes(int) constant_folding (before) 1084 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1085 /// CHECK-DAG: <<ConstF:i\d+>> IntConstant -1 1086 /// CHECK-DAG: <<Or:i\d+>> Or [<<Arg>>,<<ConstF>>] 1087 /// CHECK-DAG: Return [<<Or>>] 1088 1089 /// CHECK-START: int Main.OrAllOnes(int) constant_folding (after) 1090 /// CHECK-DAG: <<ConstF:i\d+>> IntConstant -1 1091 /// CHECK-DAG: Return [<<ConstF>>] 1092 1093 /// CHECK-START: int Main.OrAllOnes(int) constant_folding (after) 1094 /// CHECK-NOT: Or 1095 1096 public static int OrAllOnes(int arg) { 1097 return arg | -1; 1098 } 1099 1100 /// CHECK-START: long Main.Rem0(long) constant_folding (before) 1101 /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 1102 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0 1103 /// CHECK-DAG: <<DivZeroCheck:j\d+>> DivZeroCheck [<<Arg>>] 1104 /// CHECK-DAG: <<Rem:j\d+>> Rem [<<Const0>>,<<DivZeroCheck>>] 1105 /// CHECK-DAG: Return [<<Rem>>] 1106 1107 /// CHECK-START: long Main.Rem0(long) constant_folding (after) 1108 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0 1109 /// CHECK-DAG: Return [<<Const0>>] 1110 1111 /// CHECK-START: long Main.Rem0(long) constant_folding (after) 1112 /// CHECK-NOT: Rem 1113 1114 public static long Rem0(long arg) { 1115 return 0 % arg; 1116 } 1117 1118 /// CHECK-START: int Main.Rem1(int) constant_folding (before) 1119 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1120 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 1121 /// CHECK-DAG: <<Rem:i\d+>> Rem [<<Arg>>,<<Const1>>] 1122 /// CHECK-DAG: Return [<<Rem>>] 1123 1124 /// CHECK-START: int Main.Rem1(int) constant_folding (after) 1125 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 1126 /// CHECK-DAG: Return [<<Const0>>] 1127 1128 /// CHECK-START: int Main.Rem1(int) constant_folding (after) 1129 /// CHECK-NOT: Rem 1130 1131 public static int Rem1(int arg) { 1132 return arg % 1; 1133 } 1134 1135 /// CHECK-START: long Main.RemN1(long) constant_folding (before) 1136 /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 1137 /// CHECK-DAG: <<ConstN1:j\d+>> LongConstant -1 1138 /// CHECK-DAG: <<DivZeroCheck:j\d+>> DivZeroCheck [<<ConstN1>>] 1139 /// CHECK-DAG: <<Rem:j\d+>> Rem [<<Arg>>,<<DivZeroCheck>>] 1140 /// CHECK-DAG: Return [<<Rem>>] 1141 1142 /// CHECK-START: long Main.RemN1(long) constant_folding (after) 1143 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0 1144 /// CHECK-DAG: Return [<<Const0>>] 1145 1146 /// CHECK-START: long Main.RemN1(long) constant_folding (after) 1147 /// CHECK-NOT: Rem 1148 1149 public static long RemN1(long arg) { 1150 return arg % -1; 1151 } 1152 1153 /// CHECK-START: int Main.Shl0(int) constant_folding (before) 1154 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1155 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 1156 /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Const0>>,<<Arg>>] 1157 /// CHECK-DAG: Return [<<Shl>>] 1158 1159 /// CHECK-START: int Main.Shl0(int) constant_folding (after) 1160 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1161 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 1162 /// CHECK-DAG: Return [<<Const0>>] 1163 1164 /// CHECK-START: int Main.Shl0(int) constant_folding (after) 1165 /// CHECK-NOT: Shl 1166 1167 public static int Shl0(int arg) { 1168 return 0 << arg; 1169 } 1170 1171 /// CHECK-START: long Main.ShlLong0WithInt(int) constant_folding (before) 1172 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1173 /// CHECK-DAG: <<Const0L:j\d+>> LongConstant 0 1174 /// CHECK-DAG: <<Shl:j\d+>> Shl [<<Const0L>>,<<Arg>>] 1175 /// CHECK-DAG: Return [<<Shl>>] 1176 1177 /// CHECK-START: long Main.ShlLong0WithInt(int) constant_folding (after) 1178 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1179 /// CHECK-DAG: <<Const0L:j\d+>> LongConstant 0 1180 /// CHECK-DAG: Return [<<Const0L>>] 1181 1182 /// CHECK-START: long Main.ShlLong0WithInt(int) constant_folding (after) 1183 /// CHECK-NOT: Shl 1184 1185 public static long ShlLong0WithInt(int arg) { 1186 long long_zero = 0; 1187 return long_zero << arg; 1188 } 1189 1190 /// CHECK-START: long Main.Shr0(int) constant_folding (before) 1191 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1192 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0 1193 /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Const0>>,<<Arg>>] 1194 /// CHECK-DAG: Return [<<Shr>>] 1195 1196 /// CHECK-START: long Main.Shr0(int) constant_folding (after) 1197 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1198 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0 1199 /// CHECK-DAG: Return [<<Const0>>] 1200 1201 /// CHECK-START: long Main.Shr0(int) constant_folding (after) 1202 /// CHECK-NOT: Shr 1203 1204 public static long Shr0(int arg) { 1205 return (long)0 >> arg; 1206 } 1207 1208 /// CHECK-START: long Main.SubSameLong(long) constant_folding (before) 1209 /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 1210 /// CHECK-DAG: <<Sub:j\d+>> Sub [<<Arg>>,<<Arg>>] 1211 /// CHECK-DAG: Return [<<Sub>>] 1212 1213 /// CHECK-START: long Main.SubSameLong(long) constant_folding (after) 1214 /// CHECK-DAG: <<Arg:j\d+>> ParameterValue 1215 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0 1216 /// CHECK-DAG: Return [<<Const0>>] 1217 1218 /// CHECK-START: long Main.SubSameLong(long) constant_folding (after) 1219 /// CHECK-NOT: Sub 1220 1221 public static long SubSameLong(long arg) { 1222 return arg - arg; 1223 } 1224 1225 /// CHECK-START: int Main.UShr0(int) constant_folding (before) 1226 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1227 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 1228 /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Const0>>,<<Arg>>] 1229 /// CHECK-DAG: Return [<<UShr>>] 1230 1231 /// CHECK-START: int Main.UShr0(int) constant_folding (after) 1232 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1233 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 1234 /// CHECK-DAG: Return [<<Const0>>] 1235 1236 /// CHECK-START: int Main.UShr0(int) constant_folding (after) 1237 /// CHECK-NOT: UShr 1238 1239 public static int UShr0(int arg) { 1240 return 0 >>> arg; 1241 } 1242 1243 /// CHECK-START: int Main.XorSameInt(int) constant_folding (before) 1244 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1245 /// CHECK-DAG: <<Xor:i\d+>> Xor [<<Arg>>,<<Arg>>] 1246 /// CHECK-DAG: Return [<<Xor>>] 1247 1248 /// CHECK-START: int Main.XorSameInt(int) constant_folding (after) 1249 /// CHECK-DAG: <<Arg:i\d+>> ParameterValue 1250 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 1251 /// CHECK-DAG: Return [<<Const0>>] 1252 1253 /// CHECK-START: int Main.XorSameInt(int) constant_folding (after) 1254 /// CHECK-NOT: Xor 1255 1256 public static int XorSameInt(int arg) { 1257 return arg ^ arg; 1258 } 1259 1260 /// CHECK-START: boolean Main.CmpFloatGreaterThanNaN(float) constant_folding (before) 1261 /// CHECK-DAG: <<Arg:f\d+>> ParameterValue 1262 /// CHECK-DAG: <<ConstNan:f\d+>> FloatConstant nan 1263 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 1264 /// CHECK-DAG: IntConstant 1 1265 /// CHECK-DAG: <<Cmp:i\d+>> Compare [<<Arg>>,<<ConstNan>>] 1266 /// CHECK-DAG: <<Le:z\d+>> LessThanOrEqual [<<Cmp>>,<<Const0>>] 1267 /// CHECK-DAG: If [<<Le>>] 1268 1269 /// CHECK-START: boolean Main.CmpFloatGreaterThanNaN(float) constant_folding (after) 1270 /// CHECK-DAG: ParameterValue 1271 /// CHECK-DAG: FloatConstant nan 1272 /// CHECK-DAG: IntConstant 0 1273 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 1274 /// CHECK-DAG: If [<<Const1>>] 1275 1276 /// CHECK-START: boolean Main.CmpFloatGreaterThanNaN(float) constant_folding (after) 1277 /// CHECK-NOT: Compare 1278 /// CHECK-NOT: LessThanOrEqual 1279 1280 public static boolean CmpFloatGreaterThanNaN(float arg) { 1281 return arg > Float.NaN; 1282 } 1283 1284 /// CHECK-START: boolean Main.CmpDoubleLessThanNaN(double) constant_folding (before) 1285 /// CHECK-DAG: <<Arg:d\d+>> ParameterValue 1286 /// CHECK-DAG: <<ConstNan:d\d+>> DoubleConstant nan 1287 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 1288 /// CHECK-DAG: IntConstant 1 1289 /// CHECK-DAG: <<Cmp:i\d+>> Compare [<<Arg>>,<<ConstNan>>] 1290 /// CHECK-DAG: <<Ge:z\d+>> GreaterThanOrEqual [<<Cmp>>,<<Const0>>] 1291 /// CHECK-DAG: If [<<Ge>>] 1292 1293 /// CHECK-START: boolean Main.CmpDoubleLessThanNaN(double) constant_folding (after) 1294 /// CHECK-DAG: ParameterValue 1295 /// CHECK-DAG: DoubleConstant nan 1296 /// CHECK-DAG: IntConstant 0 1297 /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 1298 /// CHECK-DAG: If [<<Const1>>] 1299 1300 /// CHECK-START: boolean Main.CmpDoubleLessThanNaN(double) constant_folding (after) 1301 /// CHECK-NOT: Compare 1302 /// CHECK-NOT: GreaterThanOrEqual 1303 1304 public static boolean CmpDoubleLessThanNaN(double arg) { 1305 return arg < Double.NaN; 1306 } 1307 1308 1309 /** 1310 * Exercise constant folding on type conversions. 1311 */ 1312 1313 /// CHECK-START: int Main.ReturnInt33() constant_folding (before) 1314 /// CHECK-DAG: <<Const33:j\d+>> LongConstant 33 1315 /// CHECK-DAG: <<Convert:i\d+>> TypeConversion [<<Const33>>] 1316 /// CHECK-DAG: Return [<<Convert>>] 1317 1318 /// CHECK-START: int Main.ReturnInt33() constant_folding (after) 1319 /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33 1320 /// CHECK-DAG: Return [<<Const33>>] 1321 1322 /// CHECK-START: int Main.ReturnInt33() constant_folding (after) 1323 /// CHECK-NOT: TypeConversion 1324 1325 public static int ReturnInt33() { 1326 long imm = 33L; 1327 return (int) imm; 1328 } 1329 1330 /// CHECK-START: int Main.ReturnIntMax() constant_folding (before) 1331 /// CHECK-DAG: <<ConstMax:f\d+>> FloatConstant 1e+34 1332 /// CHECK-DAG: <<Convert:i\d+>> TypeConversion [<<ConstMax>>] 1333 /// CHECK-DAG: Return [<<Convert>>] 1334 1335 /// CHECK-START: int Main.ReturnIntMax() constant_folding (after) 1336 /// CHECK-DAG: <<ConstMax:i\d+>> IntConstant 2147483647 1337 /// CHECK-DAG: Return [<<ConstMax>>] 1338 1339 /// CHECK-START: int Main.ReturnIntMax() constant_folding (after) 1340 /// CHECK-NOT: TypeConversion 1341 1342 public static int ReturnIntMax() { 1343 float imm = 1.0e34f; 1344 return (int) imm; 1345 } 1346 1347 /// CHECK-START: int Main.ReturnInt0() constant_folding (before) 1348 /// CHECK-DAG: <<ConstNaN:d\d+>> DoubleConstant nan 1349 /// CHECK-DAG: <<Convert:i\d+>> TypeConversion [<<ConstNaN>>] 1350 /// CHECK-DAG: Return [<<Convert>>] 1351 1352 /// CHECK-START: int Main.ReturnInt0() constant_folding (after) 1353 /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 1354 /// CHECK-DAG: Return [<<Const0>>] 1355 1356 /// CHECK-START: int Main.ReturnInt0() constant_folding (after) 1357 /// CHECK-NOT: TypeConversion 1358 1359 public static int ReturnInt0() { 1360 double imm = Double.NaN; 1361 return (int) imm; 1362 } 1363 1364 /// CHECK-START: long Main.ReturnLong33() constant_folding (before) 1365 /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33 1366 /// CHECK-DAG: <<Convert:j\d+>> TypeConversion [<<Const33>>] 1367 /// CHECK-DAG: Return [<<Convert>>] 1368 1369 /// CHECK-START: long Main.ReturnLong33() constant_folding (after) 1370 /// CHECK-DAG: <<Const33:j\d+>> LongConstant 33 1371 /// CHECK-DAG: Return [<<Const33>>] 1372 1373 /// CHECK-START: long Main.ReturnLong33() constant_folding (after) 1374 /// CHECK-NOT: TypeConversion 1375 1376 public static long ReturnLong33() { 1377 int imm = 33; 1378 return (long) imm; 1379 } 1380 1381 /// CHECK-START: long Main.ReturnLong34() constant_folding (before) 1382 /// CHECK-DAG: <<Const34:f\d+>> FloatConstant 34 1383 /// CHECK-DAG: <<Convert:j\d+>> TypeConversion [<<Const34>>] 1384 /// CHECK-DAG: Return [<<Convert>>] 1385 1386 /// CHECK-START: long Main.ReturnLong34() constant_folding (after) 1387 /// CHECK-DAG: <<Const34:j\d+>> LongConstant 34 1388 /// CHECK-DAG: Return [<<Const34>>] 1389 1390 /// CHECK-START: long Main.ReturnLong34() constant_folding (after) 1391 /// CHECK-NOT: TypeConversion 1392 1393 public static long ReturnLong34() { 1394 float imm = 34.0f; 1395 return (long) imm; 1396 } 1397 1398 /// CHECK-START: long Main.ReturnLong0() constant_folding (before) 1399 /// CHECK-DAG: <<ConstNaN:d\d+>> DoubleConstant nan 1400 /// CHECK-DAG: <<Convert:j\d+>> TypeConversion [<<ConstNaN>>] 1401 /// CHECK-DAG: Return [<<Convert>>] 1402 1403 /// CHECK-START: long Main.ReturnLong0() constant_folding (after) 1404 /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0 1405 /// CHECK-DAG: Return [<<Const0>>] 1406 1407 /// CHECK-START: long Main.ReturnLong0() constant_folding (after) 1408 /// CHECK-NOT: TypeConversion 1409 1410 public static long ReturnLong0() { 1411 double imm = -Double.NaN; 1412 return (long) imm; 1413 } 1414 1415 /// CHECK-START: float Main.ReturnFloat33() constant_folding (before) 1416 /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33 1417 /// CHECK-DAG: <<Convert:f\d+>> TypeConversion [<<Const33>>] 1418 /// CHECK-DAG: Return [<<Convert>>] 1419 1420 /// CHECK-START: float Main.ReturnFloat33() constant_folding (after) 1421 /// CHECK-DAG: <<Const33:f\d+>> FloatConstant 33 1422 /// CHECK-DAG: Return [<<Const33>>] 1423 1424 /// CHECK-START: float Main.ReturnFloat33() constant_folding (after) 1425 /// CHECK-NOT: TypeConversion 1426 1427 public static float ReturnFloat33() { 1428 int imm = 33; 1429 return (float) imm; 1430 } 1431 1432 /// CHECK-START: float Main.ReturnFloat34() constant_folding (before) 1433 /// CHECK-DAG: <<Const34:j\d+>> LongConstant 34 1434 /// CHECK-DAG: <<Convert:f\d+>> TypeConversion [<<Const34>>] 1435 /// CHECK-DAG: Return [<<Convert>>] 1436 1437 /// CHECK-START: float Main.ReturnFloat34() constant_folding (after) 1438 /// CHECK-DAG: <<Const34:f\d+>> FloatConstant 34 1439 /// CHECK-DAG: Return [<<Const34>>] 1440 1441 /// CHECK-START: float Main.ReturnFloat34() constant_folding (after) 1442 /// CHECK-NOT: TypeConversion 1443 1444 public static float ReturnFloat34() { 1445 long imm = 34L; 1446 return (float) imm; 1447 } 1448 1449 /// CHECK-START: float Main.ReturnFloat99P25() constant_folding (before) 1450 /// CHECK-DAG: <<Const:d\d+>> DoubleConstant 99.25 1451 /// CHECK-DAG: <<Convert:f\d+>> TypeConversion [<<Const>>] 1452 /// CHECK-DAG: Return [<<Convert>>] 1453 1454 /// CHECK-START: float Main.ReturnFloat99P25() constant_folding (after) 1455 /// CHECK-DAG: <<Const:f\d+>> FloatConstant 99.25 1456 /// CHECK-DAG: Return [<<Const>>] 1457 1458 /// CHECK-START: float Main.ReturnFloat99P25() constant_folding (after) 1459 /// CHECK-NOT: TypeConversion 1460 1461 public static float ReturnFloat99P25() { 1462 double imm = 99.25; 1463 return (float) imm; 1464 } 1465 1466 /// CHECK-START: double Main.ReturnDouble33() constant_folding (before) 1467 /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33 1468 /// CHECK-DAG: <<Convert:d\d+>> TypeConversion [<<Const33>>] 1469 /// CHECK-DAG: Return [<<Convert>>] 1470 1471 /// CHECK-START: double Main.ReturnDouble33() constant_folding (after) 1472 /// CHECK-DAG: <<Const33:d\d+>> DoubleConstant 33 1473 /// CHECK-DAG: Return [<<Const33>>] 1474 1475 public static double ReturnDouble33() { 1476 int imm = 33; 1477 return (double) imm; 1478 } 1479 1480 /// CHECK-START: double Main.ReturnDouble34() constant_folding (before) 1481 /// CHECK-DAG: <<Const34:j\d+>> LongConstant 34 1482 /// CHECK-DAG: <<Convert:d\d+>> TypeConversion [<<Const34>>] 1483 /// CHECK-DAG: Return [<<Convert>>] 1484 1485 /// CHECK-START: double Main.ReturnDouble34() constant_folding (after) 1486 /// CHECK-DAG: <<Const34:d\d+>> DoubleConstant 34 1487 /// CHECK-DAG: Return [<<Const34>>] 1488 1489 /// CHECK-START: double Main.ReturnDouble34() constant_folding (after) 1490 /// CHECK-NOT: TypeConversion 1491 1492 public static double ReturnDouble34() { 1493 long imm = 34L; 1494 return (double) imm; 1495 } 1496 1497 /// CHECK-START: double Main.ReturnDouble99P25() constant_folding (before) 1498 /// CHECK-DAG: <<Const:f\d+>> FloatConstant 99.25 1499 /// CHECK-DAG: <<Convert:d\d+>> TypeConversion [<<Const>>] 1500 /// CHECK-DAG: Return [<<Convert>>] 1501 1502 /// CHECK-START: double Main.ReturnDouble99P25() constant_folding (after) 1503 /// CHECK-DAG: <<Const:d\d+>> DoubleConstant 99.25 1504 /// CHECK-DAG: Return [<<Const>>] 1505 1506 /// CHECK-START: double Main.ReturnDouble99P25() constant_folding (after) 1507 /// CHECK-NOT: TypeConversion 1508 1509 public static double ReturnDouble99P25() { 1510 float imm = 99.25f; 1511 return (double) imm; 1512 } 1513 1514 1515 public static void main(String[] args) throws Exception { 1516 assertIntEquals(-42, IntNegation()); 1517 assertLongEquals(-42L, LongNegation()); 1518 assertFloatEquals(-42F, FloatNegation()); 1519 assertDoubleEquals(-42D, DoubleNegation()); 1520 1521 assertIntEquals(3, IntAddition1()); 1522 assertIntEquals(14, IntAddition2()); 1523 assertLongEquals(3L, LongAddition()); 1524 assertFloatEquals(3F, FloatAddition()); 1525 assertDoubleEquals(3D, DoubleAddition()); 1526 1527 assertIntEquals(4, IntSubtraction()); 1528 assertLongEquals(4L, LongSubtraction()); 1529 assertFloatEquals(4F, FloatSubtraction()); 1530 assertDoubleEquals(4D, DoubleSubtraction()); 1531 1532 assertIntEquals(21, IntMultiplication()); 1533 assertLongEquals(21L, LongMultiplication()); 1534 assertFloatEquals(21F, FloatMultiplication()); 1535 assertDoubleEquals(21D, DoubleMultiplication()); 1536 1537 assertIntEquals(2, IntDivision()); 1538 assertLongEquals(2L, LongDivision()); 1539 assertFloatEquals(3.2F, FloatDivision()); 1540 assertDoubleEquals(3.2D, DoubleDivision()); 1541 1542 assertIntEquals(2, IntRemainder()); 1543 assertLongEquals(2L, LongRemainder()); 1544 assertFloatEquals(0.5F, FloatRemainder()); 1545 assertDoubleEquals(0.5D, DoubleRemainder()); 1546 1547 assertIntEquals(4, ShlIntLong()); 1548 assertLongEquals(12L, ShlLongInt()); 1549 1550 assertIntEquals(1, ShrIntLong()); 1551 assertLongEquals(2L, ShrLongInt()); 1552 1553 assertIntEquals(1073741822, UShrIntLong()); 1554 assertLongEquals(4611686018427387901L, UShrLongInt()); 1555 1556 assertLongEquals(2, AndIntLong()); 1557 assertLongEquals(2, AndLongInt()); 1558 1559 assertLongEquals(11, OrIntLong()); 1560 assertLongEquals(11, OrLongInt()); 1561 1562 assertLongEquals(9, XorIntLong()); 1563 assertLongEquals(9, XorLongInt()); 1564 1565 assertIntEquals(5, StaticCondition()); 1566 assertIntEquals(5, StaticConditionNulls()); 1567 1568 assertIntEquals(7, JumpsAndConditionals(true)); 1569 assertIntEquals(3, JumpsAndConditionals(false)); 1570 1571 int arbitrary = 123456; // Value chosen arbitrarily. 1572 1573 assertIntEquals(0, And0(arbitrary)); 1574 assertLongEquals(0, Mul0(arbitrary)); 1575 assertIntEquals(-1, OrAllOnes(arbitrary)); 1576 assertLongEquals(0, Rem0(arbitrary)); 1577 assertIntEquals(0, Rem1(arbitrary)); 1578 assertLongEquals(0, RemN1(arbitrary)); 1579 assertIntEquals(0, Shl0(arbitrary)); 1580 assertLongEquals(0, ShlLong0WithInt(arbitrary)); 1581 assertLongEquals(0, Shr0(arbitrary)); 1582 assertLongEquals(0, SubSameLong(arbitrary)); 1583 assertIntEquals(0, UShr0(arbitrary)); 1584 assertIntEquals(0, XorSameInt(arbitrary)); 1585 1586 assertFalse(CmpFloatGreaterThanNaN(arbitrary)); 1587 assertFalse(CmpDoubleLessThanNaN(arbitrary)); 1588 1589 Main main = new Main(); 1590 assertIntEquals(1, main.smaliCmpLongConstants()); 1591 assertIntEquals(-1, main.smaliCmpGtFloatConstants()); 1592 assertIntEquals(-1, main.smaliCmpLtFloatConstants()); 1593 assertIntEquals(-1, main.smaliCmpGtDoubleConstants()); 1594 assertIntEquals(-1, main.smaliCmpLtDoubleConstants()); 1595 1596 assertIntEquals(0, main.smaliCmpLongSameConstant()); 1597 assertIntEquals(0, main.smaliCmpGtFloatSameConstant()); 1598 assertIntEquals(0, main.smaliCmpLtFloatSameConstant()); 1599 assertIntEquals(0, main.smaliCmpGtDoubleSameConstant()); 1600 assertIntEquals(0, main.smaliCmpLtDoubleSameConstant()); 1601 1602 assertIntEquals(1, main.smaliCmpGtFloatConstantWithNaN()); 1603 assertIntEquals(-1, main.smaliCmpLtFloatConstantWithNaN()); 1604 assertIntEquals(1, main.smaliCmpGtDoubleConstantWithNaN()); 1605 assertIntEquals(-1, main.smaliCmpLtDoubleConstantWithNaN()); 1606 1607 assertIntEquals(33, ReturnInt33()); 1608 assertIntEquals(2147483647, ReturnIntMax()); 1609 assertIntEquals(0, ReturnInt0()); 1610 1611 assertLongEquals(33, ReturnLong33()); 1612 assertLongEquals(34, ReturnLong34()); 1613 assertLongEquals(0, ReturnLong0()); 1614 1615 assertFloatEquals(33, ReturnFloat33()); 1616 assertFloatEquals(34, ReturnFloat34()); 1617 assertFloatEquals(99.25f, ReturnFloat99P25()); 1618 1619 assertDoubleEquals(33, ReturnDouble33()); 1620 assertDoubleEquals(34, ReturnDouble34()); 1621 assertDoubleEquals(99.25, ReturnDouble99P25()); 1622 } 1623 1624 Main() throws ClassNotFoundException { 1625 testCmp = Class.forName("TestCmp"); 1626 } 1627 1628 private Class<?> testCmp; 1629 } 1630