diff options
| author | 2016-02-03 07:21:05 +0000 | |
|---|---|---|
| committer | 2016-02-03 07:21:05 +0000 | |
| commit | b72923dd4d6e1636163047c960395ed9879e31fc (patch) | |
| tree | 3c5cbbd6743ad8a4760d7f1a64da17ed35eac6ec | |
| parent | 81e01d72abfe3136554cdaa354be683e2cb636af (diff) | |
| parent | e5c71f98cb74943157d22f7cf408847156eae402 (diff) | |
Merge "Handle HSelect in LSE."
| -rw-r--r-- | compiler/optimizing/load_store_elimination.cc | 4 | ||||
| -rw-r--r-- | test/530-checker-lse/src/Main.java | 38 |
2 files changed, 37 insertions, 5 deletions
diff --git a/compiler/optimizing/load_store_elimination.cc b/compiler/optimizing/load_store_elimination.cc index c4492c8f92..9a97f54d54 100644 --- a/compiler/optimizing/load_store_elimination.cc +++ b/compiler/optimizing/load_store_elimination.cc @@ -55,13 +55,13 @@ class ReferenceInfo : public ArenaObject<kArenaAllocMisc> { is_singleton_and_not_returned_ = false; return; } - if (use->IsPhi() || use->IsInvoke() || + if (use->IsPhi() || use->IsSelect() || use->IsInvoke() || (use->IsInstanceFieldSet() && (reference_ == use->InputAt(1))) || (use->IsUnresolvedInstanceFieldSet() && (reference_ == use->InputAt(1))) || (use->IsStaticFieldSet() && (reference_ == use->InputAt(1))) || (use->IsUnresolvedStaticFieldSet() && (reference_ == use->InputAt(0))) || (use->IsArraySet() && (reference_ == use->InputAt(2)))) { - // reference_ is merged to a phi, passed to a callee, or stored to heap. + // reference_ is merged to a phi/HSelect, passed to a callee, or stored to heap. // reference_ isn't the only name that can refer to its value anymore. is_singleton_ = false; is_singleton_and_not_returned_ = false; diff --git a/test/530-checker-lse/src/Main.java b/test/530-checker-lse/src/Main.java index f87326cc26..d647683869 100644 --- a/test/530-checker-lse/src/Main.java +++ b/test/530-checker-lse/src/Main.java @@ -664,19 +664,50 @@ public class Main { System.out.println("testFinalizableByForcingGc() failed to force gc."); } - public static void assertIntEquals(int expected, int result) { + /// CHECK-START: int Main.testHSelect(boolean) load_store_elimination (before) + /// CHECK: InstanceFieldSet + /// CHECK: Select + + /// CHECK-START: int Main.testHSelect(boolean) load_store_elimination (after) + /// CHECK: InstanceFieldSet + /// CHECK: Select + + // Test that HSelect creates alias. + public static int testHSelect(boolean b) { + // Disable inlining. + System.out.print(""); + System.out.print(""); + System.out.print(""); + System.out.print(""); + System.out.print(""); + System.out.print(""); + System.out.print(""); + System.out.print(""); + System.out.print(""); + System.out.print(""); + + TestClass obj = new TestClass(); + TestClass obj2 = null; + obj.i = 0xdead; + if (b) { + obj2 = obj; + } + return obj2.i; + } + + public static void assertIntEquals(int result, int expected) { if (expected != result) { throw new Error("Expected: " + expected + ", found: " + result); } } - public static void assertFloatEquals(float expected, float result) { + public static void assertFloatEquals(float result, float expected) { if (expected != result) { throw new Error("Expected: " + expected + ", found: " + result); } } - public static void assertDoubleEquals(double expected, double result) { + public static void assertDoubleEquals(double result, double expected) { if (expected != result) { throw new Error("Expected: " + expected + ", found: " + result); } @@ -723,5 +754,6 @@ public class Main { assertIntEquals(test23(false), 5); assertFloatEquals(test24(), 8.0f); testFinalizableByForcingGc(); + assertIntEquals(testHSelect(true), 0xdead); } } |