Mercurial > hg > truffle
diff graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java @ 15145:df2ef5204f2b
Remove AbstractBeginNode, move the framestate from AbstractBeginNode to BeginStateSplitNode.
This required some changes to loop transformations: when peeling don't create duplicates for the exit proxies.
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Mon, 14 Apr 2014 15:21:27 +0200 |
parents | 76695509b2fd |
children | 96bb07a5d667 |
line wrap: on
line diff
--- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java Mon Apr 14 15:16:59 2014 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragmentInside.java Mon Apr 14 15:21:27 2014 +0200 @@ -29,7 +29,6 @@ import com.oracle.graal.graph.iterators.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.VirtualState.NodeClosure; -import com.oracle.graal.nodes.util.*; public class LoopFragmentInside extends LoopFragment { @@ -88,18 +87,13 @@ patchNodes(dataFixBefore); - AbstractBeginNode end = mergeEnds(); - - original().patchPeeling(this); + BeginNode end = mergeEnds(); mergeEarlyExits(); - AbstractBeginNode entry = getDuplicatedNode(loop.loopBegin()); - FrameState state = entry.stateAfter(); - if (state != null) { - entry.setStateAfter(null); - GraphUtil.killWithUnusedFloatingInputs(state); - } + original().patchPeeling(this); + + BeginNode entry = getDuplicatedNode(loop.loopBegin()); loop.entryPoint().replaceAtPredecessor(entry); end.setNext(loop.entryPoint()); } @@ -111,13 +105,27 @@ whole.nodes(); // init nodes bitmap in whole nodes = whole.nodes.copy(); // remove the phis - for (PhiNode phi : loop().loopBegin().phis()) { + LoopBeginNode loopBegin = loop().loopBegin(); + for (PhiNode phi : loopBegin.phis()) { nodes.clear(phi); } + for (LoopExitNode exit : exits()) { + FrameState exitState = exit.stateAfter(); + if (exitState != null) { + exitState.applyToVirtual(v -> nodes.clear(v)); + } + for (ProxyNode proxy : exit.proxies()) { + nodes.clear(proxy); + } + } } return nodes; } + public NodeIterable<LoopExitNode> exits() { + return loop().loopBegin().loopExits(); + } + @Override protected DuplicationReplacement getDuplicationReplacement() { final LoopBeginNode loopBegin = loop().loopBegin(); @@ -183,6 +191,18 @@ LoopBeginNode loopBegin = loop().loopBegin(); StructuredGraph graph = loopBegin.graph(); List<PhiNode> newPhis = new LinkedList<>(); + + NodeBitMap usagesToPatch = nodes.copy(); + for (LoopExitNode exit : exits()) { + FrameState exitState = exit.stateAfter(); + if (exitState != null) { + exitState.applyToVirtual(v -> usagesToPatch.mark(v)); + } + for (ProxyNode proxy : exit.proxies()) { + usagesToPatch.mark(proxy); + } + } + for (PhiNode phi : loopBegin.phis().snapshot()) { if (phi.usages().isEmpty()) { continue; @@ -204,9 +224,8 @@ peel.putDuplicatedNode(phi, newPhi); newPhis.add(newPhi); for (Node usage : phi.usages().snapshot()) { - if (peel.getDuplicatedNode(usage) != null) { // patch only usages that should use - // the new phi ie usages that were - // peeled + // patch only usages that should use the new phi ie usages that were peeled + if (usagesToPatch.isMarked(usage)) { usage.replaceFirstInput(phi, newPhi); } } @@ -250,7 +269,7 @@ } } - private AbstractBeginNode mergeEnds() { + private BeginNode mergeEnds() { assert isDuplicate(); List<AbstractEndNode> endsToMerge = new LinkedList<>(); Map<AbstractEndNode, LoopEndNode> reverseEnds = new HashMap<>(); // map peel's exit to the @@ -264,7 +283,7 @@ } } mergedInitializers = new IdentityHashMap<>(); - AbstractBeginNode newExit; + BeginNode newExit; StructuredGraph graph = graph(); if (endsToMerge.size() == 1) { AbstractEndNode end = endsToMerge.get(0);