blob: 16ff3b2eff67cf05668225cd8dc160515933d3bc [file] [log] [blame]
jeffhao5d1ac922011-09-29 17:41:15 -07001/*
2 * Copyright (C) 2011 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 * Create two versions of loops where the unresolved field is on either the
19 * taken or the non-taken path to make sure that the loop detection code bails
20 * on unresolved fields.
21 */
22public class Main {
23 static int counter1;
24 static int counter2;
25 static int counter3;
26 static int counter4;
27 static int counter5;
28
29 public static void main(String[] args) {
30 /* counter1 is not resolved */
31 for (int i = 0; i < 32767; i++) {
32 if (i < 0) {
33 counter1++;
34 } else {
35 counter2++;
36 }
37 counter5++;
38 }
39
40 /* counter4 is not resolved */
41 for (int i = 0; i < 32767; i++) {
42 if (i >= 0) {
43 counter3++;
44 } else {
45 counter4++;
46 }
47 counter5++;
48 }
49
50 System.out.println("counter1 is " + counter1);
51 System.out.println("counter2 is " + counter2);
52 System.out.println("counter3 is " + counter3);
53 System.out.println("counter4 is " + counter4);
54 System.out.println("counter5 is " + counter5);
Andreas Gampeb15be572015-04-25 15:27:38 -070055
56 deeplyNested();
57 }
58
59 // GVN is limited to a maximum loop depth of 6. To track whether dependent passes are
60 // correctly turned off, test some very simple, but deeply nested loops.
61 private static void deeplyNested() {
62 int sum = 0;
63 for (int i = 0; i < 2; i++) {
64 for (int j = 0; j < 2; j++) {
65 for (int k = 0; k < 2; k++) {
66 for (int l = 0; l < 2; l++) {
67 for (int m = 0; m < 2; m++) {
68 for (int n = 0; n < 2; n++) {
69 for (int o = 0; o < 2; o++) {
70 for (int p = 0; p < 2; p++) {
71 sum++;
72 }
73 }
74 }
75 }
76 }
77 }
78 }
79 }
80 System.out.println(sum);
jeffhao5d1ac922011-09-29 17:41:15 -070081 }
82}