blob: 7aab6598a10036dc8bbe08efb76b437d4d0423d2 [file] [log] [blame]
Nicolas Geoffrayfbda5f32015-04-29 14:16:00 +01001/*
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
17public class Main {
18
Mingyao Yang718493c2015-07-22 15:56:34 -070019 static class Foo {
20 int field0;
21 int field1;
22 int field2;
23 int field3;
24 int field4;
25 };
26
David Brazdila06d66a2015-05-28 11:14:54 +010027 /// CHECK-START: void Main.test1(boolean, int, int, int, int, int) register (after)
28 /// CHECK: name "B0"
29 /// CHECK-NOT: ParallelMove
30 /// CHECK: name "B1"
31 /// CHECK-NOT: end_block
32 /// CHECK: If
33 /// CHECK-NOT: ParallelMove
34 /// CHECK: name "B3"
35 /// CHECK-NOT: end_block
Mingyao Yang718493c2015-07-22 15:56:34 -070036 /// CHECK: InstanceFieldSet
Nicolas Geoffrayfbda5f32015-04-29 14:16:00 +010037 // We could check here that there is a parallel move, but it's only valid
38 // for some architectures (for example x86), as other architectures may
39 // not do move at all.
David Brazdila06d66a2015-05-28 11:14:54 +010040 /// CHECK: end_block
41 /// CHECK-NOT: ParallelMove
Nicolas Geoffrayfbda5f32015-04-29 14:16:00 +010042
43 public static void test1(boolean z, int a, int b, int c, int d, int m) {
44 int e = live1;
45 int f = live2;
46 int g = live3;
Mingyao Yang718493c2015-07-22 15:56:34 -070047 int j = live0;
Nicolas Geoffrayfbda5f32015-04-29 14:16:00 +010048 if (z) {
49 } else {
50 // Create enough live instructions to force spilling on x86.
51 int h = live4;
52 int i = live5;
Mingyao Yang718493c2015-07-22 15:56:34 -070053 foo.field2 = e + i + h;
54 foo.field3 = f + i + h;
55 foo.field4 = g + i + h;
56 foo.field0 = h;
57 foo.field1 = i + h;
Nicolas Geoffrayfbda5f32015-04-29 14:16:00 +010058 }
Mingyao Yang718493c2015-07-22 15:56:34 -070059 live1 = e + f + g + j;
Nicolas Geoffrayfbda5f32015-04-29 14:16:00 +010060 }
61
David Brazdila06d66a2015-05-28 11:14:54 +010062 /// CHECK-START: void Main.test2(boolean, int, int, int, int, int) register (after)
63 /// CHECK: name "B0"
64 /// CHECK-NOT: ParallelMove
65 /// CHECK: name "B1"
66 /// CHECK-NOT: end_block
67 /// CHECK: If
68 /// CHECK-NOT: ParallelMove
69 /// CHECK: name "B3"
70 /// CHECK-NOT: end_block
Mingyao Yang718493c2015-07-22 15:56:34 -070071 /// CHECK: InstanceFieldSet
Nicolas Geoffrayfbda5f32015-04-29 14:16:00 +010072 // We could check here that there is a parallel move, but it's only valid
73 // for some architectures (for example x86), as other architectures may
74 // not do move at all.
David Brazdila06d66a2015-05-28 11:14:54 +010075 /// CHECK: end_block
76 /// CHECK-NOT: ParallelMove
Nicolas Geoffrayfbda5f32015-04-29 14:16:00 +010077
78 public static void test2(boolean z, int a, int b, int c, int d, int m) {
79 int e = live1;
80 int f = live2;
81 int g = live3;
Mingyao Yang718493c2015-07-22 15:56:34 -070082 int j = live0;
Nicolas Geoffrayfbda5f32015-04-29 14:16:00 +010083 if (z) {
84 if (y) {
85 int h = live4;
86 int i = live5;
Mingyao Yang718493c2015-07-22 15:56:34 -070087 foo.field2 = e + i + h;
88 foo.field3 = f + i + h;
89 foo.field4 = g + i + h;
90 foo.field0 = h;
91 foo.field1 = i + h;
Nicolas Geoffrayfbda5f32015-04-29 14:16:00 +010092 }
93 }
Mingyao Yang718493c2015-07-22 15:56:34 -070094 live1 = e + f + g + j;
Nicolas Geoffrayfbda5f32015-04-29 14:16:00 +010095 }
96
David Brazdila06d66a2015-05-28 11:14:54 +010097 /// CHECK-START: void Main.test3(boolean, int, int, int, int, int) register (after)
98 /// CHECK: name "B0"
99 /// CHECK-NOT: ParallelMove
100 /// CHECK: name "B1"
Nicolas Geoffrayfbda5f32015-04-29 14:16:00 +0100101 public static void test3(boolean z, int a, int b, int c, int d, int m) {
102 // Same version as test2, but with branches reversed, to ensure
103 // whatever linear order is computed, we will get the same results.
104 int e = live1;
105 int f = live2;
106 int g = live3;
Mingyao Yang718493c2015-07-22 15:56:34 -0700107 int j = live0;
Nicolas Geoffrayfbda5f32015-04-29 14:16:00 +0100108 if (z) {
109 live1 = e;
110 } else {
111 if (y) {
112 live1 = e;
113 } else {
114 int h = live4;
115 int i = live5;
Mingyao Yang718493c2015-07-22 15:56:34 -0700116 foo.field2 = e + i + h;
117 foo.field3 = f + i + h;
118 foo.field4 = g + i + h;
119 foo.field0 = h;
120 foo.field1 = i + h;
Nicolas Geoffrayfbda5f32015-04-29 14:16:00 +0100121 }
122 }
Mingyao Yang718493c2015-07-22 15:56:34 -0700123 live1 = e + f + g + j;
Nicolas Geoffrayfbda5f32015-04-29 14:16:00 +0100124 }
125
126 public static void main(String[] args) {
127 }
128
129 static boolean y;
Mingyao Yang718493c2015-07-22 15:56:34 -0700130 static int live0;
Nicolas Geoffrayfbda5f32015-04-29 14:16:00 +0100131 static int live1;
132 static int live2;
133 static int live3;
134 static int live4;
135 static int live5;
Mingyao Yang718493c2015-07-22 15:56:34 -0700136 static Foo foo;
Nicolas Geoffrayfbda5f32015-04-29 14:16:00 +0100137}