Search in sources :

Example 1 with UnswitchingDecision

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);
    }
}
Also used : LoopsData(org.graalvm.compiler.nodes.loop.LoopsData) LoopEx(org.graalvm.compiler.nodes.loop.LoopEx) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) DebugContext(org.graalvm.compiler.debug.DebugContext) UnswitchingDecision(org.graalvm.compiler.nodes.loop.LoopPolicies.UnswitchingDecision)

Aggregations

DebugContext (org.graalvm.compiler.debug.DebugContext)1 ControlSplitNode (org.graalvm.compiler.nodes.ControlSplitNode)1 LoopEx (org.graalvm.compiler.nodes.loop.LoopEx)1 UnswitchingDecision (org.graalvm.compiler.nodes.loop.LoopPolicies.UnswitchingDecision)1 LoopsData (org.graalvm.compiler.nodes.loop.LoopsData)1