1 /* 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 18 public class Main { 19 public static int FIBCOUNT = 64; 20 public static int[] fibs; 21 22 /// CHECK-START-X86_64: int Main.test() licm (before) 23 /// CHECK-DAG: StaticFieldGet field_name:Main.fibs loop:none 24 /// CHECK-DAG: StaticFieldGet field_name:Main.fibs loop:B{{\d+}} 25 26 /// CHECK-START-X86_64: int Main.test() licm (after) 27 /// CHECK: StaticFieldGet field_name:Main.fibs loop:none 28 /// CHECK: StaticFieldGet field_name:Main.fibs loop:none 29 30 /// CHECK-START-X86_64: int Main.test() licm (after) 31 /// CHECK-NOT: StaticFieldGet field_name:Main.fibs loop:B{{\d+}} 32 33 /// CHECK-START-X86_64: int Main.test() load_store_elimination (after) 34 /// CHECK: StaticFieldGet field_name:Main.fibs 35 /// CHECK-NOT: StaticFieldGet field_name:Main.fibs 36 37 /// CHECK-START-X86_64: int Main.test() disassembly (after) 38 /// CHECK-DAG: <<Zero:i\d+>> IntConstant 0 39 /// CHECK-DAG: <<Fibs:l\d+>> StaticFieldGet field_name:Main.fibs 40 // 41 /// CHECK: If 42 /// CHECK-NEXT: cmp 43 /// CHECK-NEXT: jle/ng 44 // 45 /// CHECK-DAG: NullCheck [<<Fibs>>] 46 /// CHECK-NOT: jmp 47 /// CHECK-DAG: <<FibsAtZero:i\d+>> ArrayGet [<<Fibs>>,<<Zero>>] 48 /// CHECK-DAG: Return [<<FibsAtZero>>] 49 // 50 // Checks that there is no conditional jump over a `jmp` 51 // instruction. The `ArrayGet` instruction is in the next block. 52 // 53 // Note that the `StaticFieldGet` HIR instruction above (captured as 54 // `Fibs`) can produce a `jmp` x86-64 instruction when read barriers 55 // are enabled (to jump into the read barrier slow path), which is 56 // different from the `jmp` in the `CHECK-NOT` assertion. test()57 public static int test() { 58 for (int i = 1; ; i++) { 59 if (i >= FIBCOUNT) { 60 return fibs[0]; 61 } 62 fibs[i] = (i + fibs[(i - 1)]); 63 } 64 } 65 main(String[] args)66 public static void main(String[] args) { 67 fibs = new int[FIBCOUNT]; 68 fibs[0] = 1; 69 test(); 70 } 71 } 72