Mercurial > hg > graal-compiler
changeset 23237:46db8e4d2ee0
Move loop phi recursive usage optimization from loop begin simplification to loop phi canonicalization.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 01 Jan 2016 18:32:58 +0100 |
parents | 4b117cc6ae9c |
children | bc992c49ca71 |
files | graal/com.oracle.graal.loop.phases/src/com/oracle/graal/loop/phases/LoopTransformations.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopBeginNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java |
diffstat | 3 files changed, 19 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.loop.phases/src/com/oracle/graal/loop/phases/LoopTransformations.java Fri Jan 01 18:14:07 2016 +0100 +++ b/graal/com.oracle.graal.loop.phases/src/com/oracle/graal/loop/phases/LoopTransformations.java Fri Jan 01 18:32:58 2016 +0100 @@ -65,7 +65,6 @@ Mark mark = graph.getMark(); peel(loop); canonicalizer.applyIncremental(graph, context, mark); - loopBegin.removeDeadPhis(); loop.invalidateFragments(); if (graph.getNodeCount() > MaximumDesiredSize.getValue() * 3) { throw new BailoutException("FullUnroll : Graph seems to grow out of proportion");
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopBeginNode.java Fri Jan 01 18:14:07 2016 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/LoopBeginNode.java Fri Jan 01 18:32:58 2016 +0100 @@ -24,14 +24,11 @@ import static com.oracle.graal.graph.iterators.NodePredicates.isNotA; -import java.util.Set; - import com.oracle.graal.compiler.common.type.IntegerStamp; import com.oracle.graal.graph.IterableNodeType; import com.oracle.graal.graph.Node; import com.oracle.graal.graph.NodeClass; import com.oracle.graal.graph.iterators.NodeIterable; -import com.oracle.graal.graph.iterators.NodePredicate; import com.oracle.graal.graph.spi.SimplifierTool; import com.oracle.graal.nodeinfo.InputType; import com.oracle.graal.nodeinfo.NodeInfo; @@ -220,7 +217,6 @@ @Override public void simplify(SimplifierTool tool) { - removeDeadPhis(); canonicalizePhis(tool); } @@ -248,30 +244,6 @@ this.overflowGuard = overflowGuard; } - /** - * Removes dead {@linkplain PhiNode phi nodes} hanging from this node. - * - * This method uses the heuristic that any node which not a phi node of this LoopBeginNode is - * alive. This allows the removal of dead phi loops. - */ - public void removeDeadPhis() { - if (phis().isNotEmpty()) { - Set<PhiNode> alive = Node.newSet(); - for (PhiNode phi : phis()) { - NodePredicate isAlive = u -> !isPhiAtMerge(u) || alive.contains(u); - if (phi.usages().filter(isAlive).isNotEmpty()) { - alive.add(phi); - for (PhiNode keptAlive : phi.values().filter(PhiNode.class).filter(isAlive.negate())) { - alive.add(keptAlive); - } - } - } - for (PhiNode phi : phis().filter(((NodePredicate) alive::contains).negate()).snapshot()) { - phi.replaceAtUsagesAndDelete(null); - } - } - } - private static final int NO_INCREMENT = Integer.MIN_VALUE; /**
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java Fri Jan 01 18:14:07 2016 +0100 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PhiNode.java Fri Jan 01 18:32:58 2016 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ import jdk.vm.ci.meta.JavaKind; import com.oracle.graal.compiler.common.type.Stamp; +import com.oracle.graal.graph.Node; import com.oracle.graal.graph.NodeClass; import com.oracle.graal.graph.NodeInputList; import com.oracle.graal.graph.spi.Canonicalizable; @@ -199,14 +200,26 @@ @Override public ValueNode canonical(CanonicalizerTool tool) { - ValueNode singleValue; + + if (isLoopPhi()) { + if (singleBackValue() == this) { + return firstValue(); + } - if (isLoopPhi() && singleBackValue() == this) { - singleValue = firstValue(); - } else { - singleValue = singleValue(); + boolean onlySelfUsage = true; + for (Node n : this.usages()) { + if (n != this) { + onlySelfUsage = false; + break; + } + } + + if (onlySelfUsage) { + return null; + } } + ValueNode singleValue = singleValue(); if (singleValue != MULTIPLE_VALUES) { return singleValue; }