changeset 10054:10fbede11db0

Canonicalize useless PiNodes away
author Gilles Duboscq <duboscq@ssw.jku.at>
date Fri, 14 Jun 2013 17:09:24 +0200
parents 0531aa5ae1cd
children e90e48dae0ab
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiNode.java
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiNode.java	Fri Jun 14 17:07:37 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiNode.java	Fri Jun 14 17:09:24 2013 +0200
@@ -32,7 +32,7 @@
  * A node that changes the type of its input, usually narrowing it. For example, a PI node refines
  * the type of a receiver during type-guarded inlining to be the type tested by the guard.
  */
-public class PiNode extends FloatingGuardedNode implements LIRLowerable, Virtualizable, Node.IterableNodeType, GuardingNode {
+public class PiNode extends FloatingGuardedNode implements LIRLowerable, Virtualizable, Node.IterableNodeType, GuardingNode, Canonicalizable {
 
     @Input private ValueNode object;
 
@@ -69,4 +69,15 @@
             tool.replaceWithVirtual(state.getVirtualObject());
         }
     }
+
+    @Override
+    public ValueNode canonical(CanonicalizerTool tool) {
+        if (getGuard() == graph().start()) {
+            inferStamp();
+            if (stamp().equals(object().stamp())) {
+                return object();
+            }
+        }
+        return this;
+    }
 }