Roland Levillain | ca0bf03 | 2016-02-09 12:49:18 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | public class Main { |
| 18 | |
| 19 | public static void main(String[] args) { |
| 20 | System.out.println(test().intValue()); |
| 21 | } |
| 22 | |
David Brazdil | 8e73ac3 | 2016-02-15 18:20:01 +0000 | [diff] [blame] | 23 | /// CHECK-START: java.lang.Integer Main.test() builder (after) |
Roland Levillain | 3e6232e | 2016-02-11 12:50:41 +0000 | [diff] [blame] | 24 | /// CHECK-DAG: <<Const2P19:i\d+>> IntConstant 524288 |
Roland Levillain | ca0bf03 | 2016-02-09 12:49:18 +0000 | [diff] [blame] | 25 | /// CHECK-DAG: <<ConstM1:i\d+>> IntConstant -1 |
Nicolas Geoffray | e761bcc | 2017-01-19 08:59:37 +0000 | [diff] [blame] | 26 | /// CHECK-DAG: <<LoadClass:l\d+>> LoadClass |
| 27 | /// CHECK-DAG: <<Array:l\d+>> NewArray [<<LoadClass>>,<<Const2P19>>] |
David Brazdil | c120bbe | 2016-04-22 16:57:00 +0100 | [diff] [blame] | 28 | /// CHECK-DAG: <<Length1:i\d+>> ArrayLength [<<Array>>] |
Roland Levillain | ca0bf03 | 2016-02-09 12:49:18 +0000 | [diff] [blame] | 29 | /// CHECK-DAG: <<Index:i\d+>> Add [<<Length1>>,<<ConstM1>>] |
David Brazdil | c120bbe | 2016-04-22 16:57:00 +0100 | [diff] [blame] | 30 | /// CHECK-DAG: <<Length2:i\d+>> ArrayLength [<<Array>>] |
Roland Levillain | ca0bf03 | 2016-02-09 12:49:18 +0000 | [diff] [blame] | 31 | /// CHECK-DAG: <<BoundsCheck:i\d+>> BoundsCheck [<<Index>>,<<Length2>>] |
David Brazdil | c120bbe | 2016-04-22 16:57:00 +0100 | [diff] [blame] | 32 | /// CHECK-DAG: <<LastElement:l\d+>> ArrayGet [<<Array>>,<<BoundsCheck>>] |
Roland Levillain | ca0bf03 | 2016-02-09 12:49:18 +0000 | [diff] [blame] | 33 | /// CHECK-DAG: Return [<<LastElement>>] |
| 34 | |
Roland Levillain | 3e6232e | 2016-02-11 12:50:41 +0000 | [diff] [blame] | 35 | |
Roland Levillain | ca0bf03 | 2016-02-09 12:49:18 +0000 | [diff] [blame] | 36 | /// CHECK-START: java.lang.Integer Main.test() register (before) |
Roland Levillain | 3e6232e | 2016-02-11 12:50:41 +0000 | [diff] [blame] | 37 | /// CHECK-DAG: <<Const2P19:i\d+>> IntConstant 524288 |
| 38 | /// CHECK-DAG: <<Const2P19M1:i\d+>> IntConstant 524287 |
Nicolas Geoffray | e761bcc | 2017-01-19 08:59:37 +0000 | [diff] [blame] | 39 | /// CHECK-DAG: <<LoadClass:l\d+>> LoadClass |
| 40 | /// CHECK-DAG: <<Array:l\d+>> NewArray [<<LoadClass>>,<<Const2P19>>] |
Roland Levillain | 3e6232e | 2016-02-11 12:50:41 +0000 | [diff] [blame] | 41 | /// CHECK-DAG: <<LastElement:l\d+>> ArrayGet [<<Array>>,<<Const2P19M1>>] |
Roland Levillain | ca0bf03 | 2016-02-09 12:49:18 +0000 | [diff] [blame] | 42 | /// CHECK-DAG: Return [<<LastElement>>] |
| 43 | |
| 44 | public static Integer test() { |
Roland Levillain | 3e6232e | 2016-02-11 12:50:41 +0000 | [diff] [blame] | 45 | Integer[] integers = new Integer[1 << 19]; |
Roland Levillain | ca0bf03 | 2016-02-09 12:49:18 +0000 | [diff] [blame] | 46 | initIntegerArray(integers); |
| 47 | // Array load with a large constant index (after constant folding |
| 48 | // and bounds check elimination). |
| 49 | Integer last_integer = integers[integers.length - 1]; |
| 50 | return last_integer; |
| 51 | } |
| 52 | |
| 53 | public static void initIntegerArray(Integer[] integers) { |
| 54 | for (int i = 0; i < integers.length; ++i) { |
| 55 | integers[i] = new Integer(i); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | } |