diff options
| author | 2020-06-09 15:03:42 +0100 | |
|---|---|---|
| committer | 2020-06-09 16:06:24 +0000 | |
| commit | 344e24ec28d2117e91a39ca5a45e47f4a6bfcfd0 (patch) | |
| tree | 6d38d5bec13b511f5eb7187db71dc794c08066fb | |
| parent | f0ccfa9d913af0914654bd4cb1cfa62e1851367b (diff) | |
Make test 455-checker-gvn pass on RI.
Move the smali code back to Java. Use inlining to expose the
GVN opportunity to Optimizing while hiding it from D8.
Test: testrunner.py --host --optimizing --jvm
Bug: 65168732
Bug: 73888836
Change-Id: I3704b4f993fe81be634af5d8fb9b8babdbef9378
| -rw-r--r-- | test/455-checker-gvn/smali/Smali.smali | 42 | ||||
| -rw-r--r-- | test/455-checker-gvn/src/Main.java | 44 | ||||
| -rw-r--r-- | test/knownfailures.json | 1 |
3 files changed, 26 insertions, 61 deletions
diff --git a/test/455-checker-gvn/smali/Smali.smali b/test/455-checker-gvn/smali/Smali.smali deleted file mode 100644 index fbeb4dbc8e..0000000000 --- a/test/455-checker-gvn/smali/Smali.smali +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright (C) 2017 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -.class public LSmali; -.super Ljava/lang/Object; - -## CHECK-START: int Smali.foo(int, int) GVN (before) -## CHECK: Add -## CHECK: Add -## CHECK: Add - -## CHECK-START: int Smali.foo(int, int) GVN (after) -## CHECK: Add -## CHECK: Add -## CHECK-NOT: Add -.method public static foo(II)I - - # int sum1 = x + y; - # int sum2 = y + x; - # return sum1 + sum2; - - .registers 5 - .param p0, "x" # I - .param p1, "y" # I - - add-int v0, p0, p1 - add-int v1, p1, p0 - add-int v2, v0, v1 - - return v2 -.end method - diff --git a/test/455-checker-gvn/src/Main.java b/test/455-checker-gvn/src/Main.java index 74b1839808..76b3d42df5 100644 --- a/test/455-checker-gvn/src/Main.java +++ b/test/455-checker-gvn/src/Main.java @@ -21,22 +21,31 @@ public class Main { private static int mY = -3; public static void main(String[] args) { - System.out.println(foo(3, 4)); - System.out.println(mulAndIntrinsic()); - System.out.println(directIntrinsic(-5)); + System.out.println($noinline$foo(3, 4)); + System.out.println($noinline$mulAndIntrinsic()); + System.out.println($noinline$directIntrinsic(-5)); } - public static int foo(int x, int y) { - try { - Class<?> c = Class.forName("Smali"); - Method m = c.getMethod("foo", int.class, int.class); - return (Integer) m.invoke(null, x, y); - } catch (Throwable t) { - throw new RuntimeException(t); - } + private static int $inline$add(int a, int b) { + return a + b; } - /// CHECK-START: int Main.mulAndIntrinsic() GVN (before) + /// CHECK-START: int Main.$noinline$foo(int, int) GVN (before) + /// CHECK: Add + /// CHECK: Add + /// CHECK: Add + + /// CHECK-START: int Main.$noinline$foo(int, int) GVN (after) + /// CHECK: Add + /// CHECK: Add + /// CHECK-NOT: Add + public static int $noinline$foo(int x, int y) { + int sum1 = $inline$add(x, y); + int sum2 = $inline$add(y, x); + return sum1 + sum2; + } + + /// CHECK-START: int Main.$noinline$mulAndIntrinsic() GVN (before) /// CHECK: StaticFieldGet /// CHECK: StaticFieldGet /// CHECK: Mul @@ -46,7 +55,7 @@ public class Main { /// CHECK: Mul /// CHECK: Add - /// CHECK-START: int Main.mulAndIntrinsic() GVN (after) + /// CHECK-START: int Main.$noinline$mulAndIntrinsic() GVN (after) /// CHECK: StaticFieldGet /// CHECK: StaticFieldGet /// CHECK: Mul @@ -56,7 +65,7 @@ public class Main { /// CHECK-NOT: Mul /// CHECK: Add - public static int mulAndIntrinsic() { + public static int $noinline$mulAndIntrinsic() { // The intermediate call to abs() does not kill // the common subexpression on the multiplication. int mul1 = mX * mY; @@ -65,21 +74,20 @@ public class Main { return abs + mul2; } - /// CHECK-START: int Main.directIntrinsic(int) GVN (before) + /// CHECK-START: int Main.$noinline$directIntrinsic(int) GVN (before) /// CHECK: Abs /// CHECK: Abs /// CHECK: Add - /// CHECK-START: int Main.directIntrinsic(int) GVN (after) + /// CHECK-START: int Main.$noinline$directIntrinsic(int) GVN (after) /// CHECK: Abs /// CHECK-NOT: Abs /// CHECK: Add - public static int directIntrinsic(int x) { + public static int $noinline$directIntrinsic(int x) { // Here, the two calls to abs() themselves can be replaced with just one. int abs1 = Math.abs(x); int abs2 = Math.abs(x); return abs1 + abs2; } - } diff --git a/test/knownfailures.json b/test/knownfailures.json index aaa3f3fe28..7a2ea5d716 100644 --- a/test/knownfailures.json +++ b/test/knownfailures.json @@ -891,7 +891,6 @@ "452-multiple-returns2", "453-not-byte", "454-get-vreg", - "455-checker-gvn", "457-regs", "458-checker-instruct-simplification", "459-dead-phi", |