changeset 14933:0a7fce0ac01b

eliminate duplicate guards with the same anchor
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Tue, 01 Apr 2014 15:42:42 -0700
parents 8ce9a950fbe2
children f83404938588
files graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java	Tue Apr 01 15:42:19 2014 -0700
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java	Tue Apr 01 15:42:42 2014 -0700
@@ -469,9 +469,7 @@
         private boolean eliminateTrivialGuard(GuardNode guard) {
             LogicNode condition = guard.condition();
 
-            ValueNode existingGuards = guard.negated() ? state.falseConditions.get(condition) : state.trueConditions.get(condition);
-            if (existingGuards != null) {
-                eliminateGuard(guard, existingGuards);
+            if (testExistingGuard(guard)) {
                 return true;
             } else {
                 ValueNode anchor = state.trueConditions.get(condition);
@@ -560,6 +558,15 @@
             return false;
         }
 
+        private boolean testExistingGuard(GuardNode guard) {
+            ValueNode existingGuard = guard.negated() ? state.falseConditions.get(guard.condition()) : state.trueConditions.get(guard.condition());
+            if (existingGuard != null && existingGuard != guard) {
+                eliminateGuard(guard, existingGuard);
+                return true;
+            }
+            return false;
+        }
+
         private void registerConditionalStamp(GuardNode guard) {
             GuardedStamp conditional = computeGuardedStamp(guard);
             if (conditional != null) {
@@ -663,7 +670,7 @@
                 // just be registered since they aren't trivially deleteable. Test the other guards
                 // to see if they can be deleted using type constraints.
                 for (GuardNode guard : begin.guards().snapshot()) {
-                    if (provers.contains(guard) || !testImpliedGuard(guard)) {
+                    if (provers.contains(guard) || !testExistingGuard(guard) || !testImpliedGuard(guard)) {
                         registerCondition(!guard.negated(), guard.condition(), guard);
                     }
                 }