Search in sources :

Example 21 with LoopEx

use of org.graalvm.compiler.nodes.loop.LoopEx in project graal by oracle.

the class PlaceholderLogicNode method explodeLoops.

public static void explodeLoops(final StructuredGraph snippetCopy, CoreProviders providers) {
    // Do any required loop explosion
    boolean exploded = false;
    do {
        exploded = false;
        ExplodeLoopNode explodeLoop = snippetCopy.getNodes().filter(ExplodeLoopNode.class).first();
        if (explodeLoop != null) {
            // Earlier canonicalization may have removed the loop
            // altogether
            LoopBeginNode loopBegin = explodeLoop.findLoopBegin();
            if (loopBegin != null) {
                LoopEx loop = providers.getLoopsDataProvider().getLoopsData(snippetCopy).loop(loopBegin);
                Mark mark = snippetCopy.getMark();
                CanonicalizerPhase canonicalizer = CanonicalizerPhase.create();
                try {
                    LoopTransformations.fullUnroll(loop, providers, canonicalizer);
                } catch (RetryableBailoutException e) {
                    // This is a hard error in this context
                    throw new GraalError(e, snippetCopy.toString());
                }
                CanonicalizerPhase.create().applyIncremental(snippetCopy, providers, mark, false);
                loop.deleteUnusedNodes();
            }
            GraphUtil.removeFixedWithUnusedInputs(explodeLoop);
            exploded = true;
        }
    } while (exploded);
}
Also used : LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) RetryableBailoutException(org.graalvm.compiler.core.common.RetryableBailoutException) GraalError(org.graalvm.compiler.debug.GraalError) LoopEx(org.graalvm.compiler.nodes.loop.LoopEx) ExplodeLoopNode(org.graalvm.compiler.replacements.nodes.ExplodeLoopNode) Mark(org.graalvm.compiler.graph.Graph.Mark) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) IncrementalCanonicalizerPhase(org.graalvm.compiler.phases.common.IncrementalCanonicalizerPhase)

Aggregations

LoopEx (org.graalvm.compiler.nodes.loop.LoopEx)21 LoopsData (org.graalvm.compiler.nodes.loop.LoopsData)19 DebugContext (org.graalvm.compiler.debug.DebugContext)8 Node (org.graalvm.compiler.graph.Node)4 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)4 ValueNode (org.graalvm.compiler.nodes.ValueNode)4 Block (org.graalvm.compiler.nodes.cfg.Block)4 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)3 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)3 HashSet (java.util.HashSet)2 SpeculationLog (jdk.vm.ci.meta.SpeculationLog)2 FixedNode (org.graalvm.compiler.nodes.FixedNode)2 FrameState (org.graalvm.compiler.nodes.FrameState)2 LogicNode (org.graalvm.compiler.nodes.LogicNode)2 LoopEndNode (org.graalvm.compiler.nodes.LoopEndNode)2 PiNode (org.graalvm.compiler.nodes.PiNode)2 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)2 DeadCodeEliminationPhase (org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)2 Test (org.junit.Test)2 BytecodePosition (jdk.vm.ci.code.BytecodePosition)1