use of org.graalvm.compiler.nodes.loop.LoopPolicies.UnswitchingDecision in project graal by oracle.
the class LoopUnswitchingPhase method run.
@Override
protected void run(StructuredGraph graph, CoreProviders context) {
DebugContext debug = graph.getDebug();
if (graph.hasLoops()) {
boolean unswitched;
do {
unswitched = false;
final LoopsData dataUnswitch = context.getLoopsDataProvider().getLoopsData(graph);
for (LoopEx loop : dataUnswitch.outerFirst()) {
if (getPolicies().shouldTryUnswitch(loop)) {
List<ControlSplitNode> controlSplits = LoopTransformations.findUnswitchable(loop);
if (controlSplits != null) {
UNSWITCH_CANDIDATES.increment(debug);
UnswitchingDecision decision = getPolicies().shouldUnswitch(loop, controlSplits);
if (decision.shouldUnswitch()) {
if (debug.isLogEnabled()) {
logUnswitch(loop, controlSplits);
}
LoopTransformations.unswitch(loop, controlSplits, decision.isTrivial());
debug.dump(DebugContext.DETAILED_LEVEL, graph, "After unswitch %s", controlSplits);
UNSWITCHED.increment(debug);
unswitched = true;
break;
}
}
} else {
UNSWITCH_EARLY_REJECTS.increment(debug);
}
}
} while (unswitched);
}
}
Aggregations