blob: 1e15654950a2b4576c7da8c26419c4df77ece0eb [file] [log] [blame]
David Brazdil744a1c62015-12-28 10:53:34 +00001/*
2 * Copyright (C) 2015 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
18public class Main {
19
David Brazdilbadd8262016-02-02 16:28:56 +000020 /// CHECK-START: void Main.boundTypeForIfNotNull() builder (after)
David Brazdil744a1c62015-12-28 10:53:34 +000021 /// CHECK-DAG: <<Null:l\d+>> NullConstant
22 /// CHECK-DAG: <<Cst5:i\d+>> IntConstant 5
23 /// CHECK-DAG: <<Cst10:i\d+>> IntConstant 10
24
25 /// CHECK-DAG: InvokeVirtual [<<NullCheck:l\d+>>]
26 /// CHECK-DAG: <<NullCheck>> NullCheck [<<LoopPhi:l\d+>>] klass:int[]
27 /// CHECK-DAG: <<LoopPhi>> Phi [<<Null>>,<<MergePhi:l\d+>>] klass:int[]
28
29 /// CHECK-DAG: <<BoundType:l\d+>> BoundType [<<LoopPhi>>] klass:int[] can_be_null:false
Nicolas Geoffraye761bcc2017-01-19 08:59:37 +000030 /// CHECK-DAG: <<LoadClass1:l\d+>> LoadClass
31 /// CHECK-DAG: <<LoadClass2:l\d+>> LoadClass
32 /// CHECK-DAG: <<NewArray10:l\d+>> NewArray [<<LoadClass2>>,<<Cst10>>] klass:int[]
David Brazdil744a1c62015-12-28 10:53:34 +000033 /// CHECK-DAG: <<NotNullPhi:l\d+>> Phi [<<BoundType>>,<<NewArray10>>] klass:int[]
34
Nicolas Geoffraye761bcc2017-01-19 08:59:37 +000035 /// CHECK-DAG: <<NewArray5:l\d+>> NewArray [<<LoadClass1>>,<<Cst5>>] klass:int[]
David Brazdil744a1c62015-12-28 10:53:34 +000036 /// CHECK-DAG: <<MergePhi>> Phi [<<NewArray5>>,<<NotNullPhi>>] klass:int[]
37
38 public static void boundTypeForIfNotNull() {
39 int[] array = null;
40 for (int i = -1; i < 10; ++i) {
41 if (array == null) {
42 array = new int[5];
43 } else {
44 if (i == 5) {
45 array = new int[10];
46 }
47 array[i] = i;
48 }
49 }
50 array.hashCode();
51 }
52
53 public static void main(String[] args) { }
54}