# HG changeset patch # User Gilles Duboscq # Date 1371222564 -7200 # Node ID 10fbede11db00651a836952350cc31a1496ac5c4 # Parent 0531aa5ae1cd2d2c0643cecf21d4e323ed0fc1bd Canonicalize useless PiNodes away diff -r 0531aa5ae1cd -r 10fbede11db0 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiNode.java --- 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; + } }