use of org.graalvm.compiler.nodes.LoopExitNode in project graal by oracle.
the class DeoptimizationGroupingPhase method exitLoops.
private static void exitLoops(AbstractDeoptimizeNode deopt, EndNode end, ControlFlowGraph cfg) {
Block block = cfg.blockFor(deopt);
Loop<Block> loop = block.getLoop();
while (loop != null) {
end.graph().addBeforeFixed(end, end.graph().add(new LoopExitNode((LoopBeginNode) loop.getHeader().getBeginNode())));
loop = loop.getParent();
}
}
use of org.graalvm.compiler.nodes.LoopExitNode in project graal by oracle.
the class SchedulingTest method testValueProxyInputs.
@Test
public void testValueProxyInputs() {
StructuredGraph graph = parseEager("testValueProxyInputsSnippet", AllowAssumptions.YES);
for (FrameState fs : graph.getNodes().filter(FrameState.class).snapshot()) {
fs.replaceAtUsages(null);
GraphUtil.killWithUnusedFloatingInputs(fs);
}
SchedulePhase schedulePhase = new SchedulePhase(SchedulingStrategy.LATEST);
schedulePhase.apply(graph);
ScheduleResult schedule = graph.getLastSchedule();
NodeMap<Block> nodeToBlock = schedule.getCFG().getNodeToBlock();
assertTrue(graph.getNodes().filter(LoopExitNode.class).count() == 1);
LoopExitNode loopExit = graph.getNodes().filter(LoopExitNode.class).first();
List<Node> list = schedule.nodesFor(nodeToBlock.get(loopExit));
for (BinaryArithmeticNode<?> node : graph.getNodes().filter(BinaryArithmeticNode.class)) {
if (!(node instanceof AddNode)) {
assertTrue(node.toString(), nodeToBlock.get(node) == nodeToBlock.get(loopExit));
assertTrue(list.indexOf(node) + " < " + list.indexOf(loopExit) + ", " + node + ", " + loopExit, list.indexOf(node) < list.indexOf(loopExit));
}
}
}
use of org.graalvm.compiler.nodes.LoopExitNode in project graal by oracle.
the class ComputeInliningRelevance method createLoopScope.
/**
* Determines the parent of the given loop and creates a {@link Scope} object for each one. This
* method will call itself recursively if no {@link Scope} for the parent loop exists.
*/
private Scope createLoopScope(LoopBeginNode loopBegin, EconomicMap<LoopBeginNode, Scope> loops, Scope topScope) {
Scope scope = loops.get(loopBegin);
if (scope == null) {
final Scope parent;
// look for the parent scope
FixedNode current = loopBegin.forwardEnd();
while (true) {
if (current.predecessor() == null) {
if (current instanceof LoopBeginNode) {
// if we reach a LoopBeginNode then we're within this loop
parent = createLoopScope((LoopBeginNode) current, loops, topScope);
break;
} else if (current instanceof StartNode) {
// we're within the outermost scope
parent = topScope;
break;
} else {
assert current instanceof MergeNode : current;
// follow any path upwards - it doesn't matter which one
current = ((AbstractMergeNode) current).forwardEndAt(0);
}
} else if (current instanceof LoopExitNode) {
// if we reach a loop exit then we follow this loop and have the same parent
parent = createLoopScope(((LoopExitNode) current).loopBegin(), loops, topScope).parent;
break;
} else {
current = (FixedNode) current.predecessor();
}
}
scope = new Scope(loopBegin, parent);
loops.put(loopBegin, scope);
}
return scope;
}
use of org.graalvm.compiler.nodes.LoopExitNode in project graal by oracle.
the class ReentrantNodeIterator method processLoop.
public static <StateT> LoopInfo<StateT> processLoop(NodeIteratorClosure<StateT> closure, LoopBeginNode loop, StateT initialState) {
EconomicMap<FixedNode, StateT> blockEndStates = apply(closure, loop, initialState, loop);
LoopInfo<StateT> info = new LoopInfo<>(loop.loopEnds().count(), loop.loopExits().count());
for (LoopEndNode end : loop.loopEnds()) {
if (blockEndStates.containsKey(end)) {
info.endStates.put(end, blockEndStates.get(end));
}
}
for (LoopExitNode exit : loop.loopExits()) {
if (blockEndStates.containsKey(exit)) {
info.exitStates.put(exit, blockEndStates.get(exit));
}
}
return info;
}
use of org.graalvm.compiler.nodes.LoopExitNode in project graal by oracle.
the class ScopedPostOrderNodeIterator method processScope.
public void processScope() {
FixedNode current;
queue(currentScopeStart);
while ((current = nextQueuedNode()) != null) {
assert current.isAlive();
if (current instanceof Invoke) {
invoke((Invoke) current);
queueSuccessors(current);
} else if (current instanceof LoopBeginNode) {
queueLoopBeginSuccessors((LoopBeginNode) current);
} else if (current instanceof LoopExitNode) {
queueLoopExitSuccessors((LoopExitNode) current);
} else if (current instanceof LoopEndNode) {
// nothing todo
} else if (current instanceof AbstractMergeNode) {
queueSuccessors(current);
} else if (current instanceof FixedWithNextNode) {
queueSuccessors(current);
} else if (current instanceof EndNode) {
queueMerge((EndNode) current);
} else if (current instanceof ControlSinkNode) {
// nothing todo
} else if (current instanceof ControlSplitNode) {
queueSuccessors(current);
} else {
assert false : current;
}
}
}
Aggregations