diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2014-11-27 12:01:59 +0000 |
---|---|---|
committer | Nicolas Geoffray <ngeoffray@google.com> | 2014-11-28 11:05:22 +0000 |
commit | dbca6fae9d09160f45bf8d3512f15cdd9558975b (patch) | |
tree | 4e06651a63b661610f2f12654600c9146b0d3607 /test/433-gvn | |
parent | 35ecc8ca8fba713728b8fc60e9e2a275da2028aa (diff) | |
download | art-dbca6fae9d09160f45bf8d3512f15cdd9558975b.zip art-dbca6fae9d09160f45bf8d3512f15cdd9558975b.tar.gz art-dbca6fae9d09160f45bf8d3512f15cdd9558975b.tar.bz2 |
Fix a bug in GVN.
When a predecessor block was killing instructions in a set, we were
not taking into account side effects of blocks between the dominator to
this predecessor.
Implementation now intersects the copied set of the dominator with
the predecessors to take these side effects into account.
Change-Id: If297439cc4e50cee91e9fffd028216a3e49e19ef
Diffstat (limited to 'test/433-gvn')
-rw-r--r-- | test/433-gvn/expected.txt | 1 | ||||
-rw-r--r-- | test/433-gvn/info.txt | 3 | ||||
-rw-r--r-- | test/433-gvn/src/Main.java | 38 |
3 files changed, 42 insertions, 0 deletions
diff --git a/test/433-gvn/expected.txt b/test/433-gvn/expected.txt new file mode 100644 index 0000000..d81cc07 --- /dev/null +++ b/test/433-gvn/expected.txt @@ -0,0 +1 @@ +42 diff --git a/test/433-gvn/info.txt b/test/433-gvn/info.txt new file mode 100644 index 0000000..bcdab15 --- /dev/null +++ b/test/433-gvn/info.txt @@ -0,0 +1,3 @@ +Regression test for the optimizing compiler's GVN, that +used to not take into account all side effects between +a dominator and its dominated blocks. diff --git a/test/433-gvn/src/Main.java b/test/433-gvn/src/Main.java new file mode 100644 index 0000000..f9cb594 --- /dev/null +++ b/test/433-gvn/src/Main.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2014 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. + */ + +public class Main { + public static void main(String[] args) { + System.out.println(foo()); + } + + public static int foo() { + Main m = new Main(); + int a = m.field; + if (a == 0) { + m.field = 42; + if (m.test) { + a = 3; + } + } + // The compiler used to GVN this field get with the one line 24, + // even though the field is updated in the if. + return m.field; + } + + public int field; + public boolean test = true; +} |