Search in sources :

Example 6 with LoopsData

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

the class ReassociateInvariantPhase method run.

@SuppressWarnings("try")
@Override
protected void run(StructuredGraph graph) {
    int iterations = 0;
    DebugContext debug = graph.getDebug();
    try (DebugContext.Scope s = debug.scope("ReassociateInvariants")) {
        boolean changed = true;
        while (changed) {
            changed = false;
            final LoopsData dataReassociate = new LoopsData(graph);
            for (LoopEx loop : dataReassociate.loops()) {
                changed |= loop.reassociateInvariants();
            }
            dataReassociate.deleteUnusedNodes();
            iterations++;
            debug.dump(DebugContext.VERBOSE_LEVEL, graph, "after iteration %d", iterations);
        }
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : LoopsData(org.graalvm.compiler.loop.LoopsData) LoopEx(org.graalvm.compiler.loop.LoopEx) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 7 with LoopsData

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

the class LoopsDataTest method testouterFirst.

@Test
public void testouterFirst() {
    LoopsData loops = getLoopsData();
    Set<LoopEx> seen = new HashSet<>();
    for (LoopEx loop : loops.outerFirst()) {
        assertFalse(seen.contains(loop), "%s has already been seen", loop);
        if (loop.parent() != null) {
            assertTrue(seen.contains(loop.parent()), "%s's parent (%s) should have already been seen", loop, loop.parent());
        }
        seen.add(loop);
    }
}
Also used : LoopsData(org.graalvm.compiler.loop.LoopsData) LoopEx(org.graalvm.compiler.loop.LoopEx) HashSet(java.util.HashSet) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Example 8 with LoopsData

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

the class LoopFullUnrollPhase method run.

@Override
protected void run(StructuredGraph graph, PhaseContext context) {
    DebugContext debug = graph.getDebug();
    if (graph.hasLoops()) {
        boolean peeled;
        do {
            peeled = false;
            final LoopsData dataCounted = new LoopsData(graph);
            dataCounted.detectedCountedLoops();
            for (LoopEx loop : dataCounted.countedLoops()) {
                if (getPolicies().shouldFullUnroll(loop)) {
                    debug.log("FullUnroll %s", loop);
                    LoopTransformations.fullUnroll(loop, context, canonicalizer);
                    FULLY_UNROLLED_LOOPS.increment(debug);
                    debug.dump(DebugContext.DETAILED_LEVEL, graph, "FullUnroll %s", loop);
                    peeled = true;
                    break;
                }
            }
            dataCounted.deleteUnusedNodes();
        } while (peeled);
    }
}
Also used : LoopsData(org.graalvm.compiler.loop.LoopsData) LoopEx(org.graalvm.compiler.loop.LoopEx) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 9 with LoopsData

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

the class LoopPartialUnrollPhase method checkCounted.

private static boolean checkCounted(StructuredGraph graph, Graph.Mark mark) {
    LoopsData dataCounted;
    dataCounted = new LoopsData(graph);
    dataCounted.detectedCountedLoops();
    for (LoopEx anyLoop : dataCounted.loops()) {
        if (graph.isNew(mark, anyLoop.loopBegin())) {
            assert anyLoop.isCounted() : "pre/post transformation loses counted loop " + anyLoop.loopBegin();
        }
    }
    return true;
}
Also used : LoopsData(org.graalvm.compiler.loop.LoopsData) LoopEx(org.graalvm.compiler.loop.LoopEx)

Example 10 with LoopsData

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

the class CountedLoopTest method checkHighTierGraph.

@Override
protected boolean checkHighTierGraph(StructuredGraph graph) {
    LoopsData loops = new LoopsData(graph);
    loops.detectedCountedLoops();
    for (IVPropertyNode node : graph.getNodes().filter(IVPropertyNode.class)) {
        node.rewrite(loops);
    }
    assert graph.getNodes().filter(IVPropertyNode.class).isEmpty();
    return true;
}
Also used : LoopsData(org.graalvm.compiler.loop.LoopsData)

Aggregations

LoopsData (org.graalvm.compiler.loop.LoopsData)17 LoopEx (org.graalvm.compiler.loop.LoopEx)14 DebugContext (org.graalvm.compiler.debug.DebugContext)6 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)3 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)3 Block (org.graalvm.compiler.nodes.cfg.Block)3 HashSet (java.util.HashSet)2 Node (org.graalvm.compiler.graph.Node)2 FixedNode (org.graalvm.compiler.nodes.FixedNode)2 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)2 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)2 DeadCodeEliminationPhase (org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)2 Test (org.junit.Test)2 JavaConstant (jdk.vm.ci.meta.JavaConstant)1 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)1 PermanentBailoutException (org.graalvm.compiler.core.common.PermanentBailoutException)1 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)1 Stamp (org.graalvm.compiler.core.common.type.Stamp)1