Search in sources :

Example 16 with LoopsData

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

the class SpeculativeGuardMovementPhase method run.

@Override
protected void run(StructuredGraph graph, MidTierContext context) {
    try {
        if (!graph.getGuardsStage().allowsFloatingGuards()) {
            return;
        }
        LoopsData loops = context.getLoopsDataProvider().getLoopsData(graph);
        loops.detectedCountedLoops();
        performSpeculativeGuardMovement(context, graph, loops);
    } finally {
        graph.setAfterStage(StageFlag.GUARD_MOVEMENT);
    }
}
Also used : LoopsData(org.graalvm.compiler.nodes.loop.LoopsData)

Example 17 with LoopsData

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

the class LoopsDataTest method testInnerFirst.

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

Example 18 with LoopsData

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

the class LoopsDataTest method sanityTests.

@Test
public void sanityTests() {
    LoopsData loops = getLoopsData();
    Assert.assertEquals(8, loops.outerFirst().size());
    Assert.assertEquals(1, loops.outerFirst().get(0).loop().getDepth());
    Assert.assertEquals(1, loops.outerFirst().get(1).loop().getDepth());
    Assert.assertEquals(2, loops.outerFirst().get(2).loop().getDepth());
    Assert.assertEquals(3, loops.outerFirst().get(3).loop().getDepth());
    Assert.assertEquals(2, loops.outerFirst().get(4).loop().getDepth());
    Assert.assertEquals(2, loops.outerFirst().get(5).loop().getDepth());
    Assert.assertEquals(3, loops.outerFirst().get(6).loop().getDepth());
    Assert.assertEquals(4, loops.outerFirst().get(7).loop().getDepth());
    for (LoopEx loop : loops.loops()) {
        if (loop.parent() != null) {
            Assert.assertEquals(loop.parent().loop().getDepth() + 1, loop.loop().getDepth());
        }
    }
}
Also used : LoopsData(org.graalvm.compiler.nodes.loop.LoopsData) LoopEx(org.graalvm.compiler.nodes.loop.LoopEx) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Example 19 with LoopsData

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

the class ConvertDeoptimizeToGuardPhase method run.

@Override
@SuppressWarnings("try")
protected void run(final StructuredGraph graph, final CoreProviders context) {
    assert graph.isBeforeStage(StageFlag.VALUE_PROXY_REMOVAL) : "ConvertDeoptimizeToGuardPhase always creates proxies";
    assert !graph.getGuardsStage().areFrameStatesAtDeopts() : graph.getGuardsStage();
    LazyValue<LoopsData> lazyLoops = new LazyValue<>(() -> context.getLoopsDataProvider().getLoopsData(graph));
    for (DeoptimizeNode d : graph.getNodes(DeoptimizeNode.TYPE)) {
        assert d.isAlive();
        if (d.getAction() == DeoptimizationAction.None) {
            continue;
        }
        try (DebugCloseable closable = d.withNodeSourcePosition()) {
            propagateFixed(d, d, context, lazyLoops);
        }
    }
    if (context != null) {
        for (FixedGuardNode fixedGuard : graph.getNodes(FixedGuardNode.TYPE)) {
            try (DebugCloseable closable = fixedGuard.withNodeSourcePosition()) {
                trySplitFixedGuard(fixedGuard, context, lazyLoops);
            }
        }
    }
    new DeadCodeEliminationPhase(Optional).apply(graph);
}
Also used : FixedGuardNode(org.graalvm.compiler.nodes.FixedGuardNode) LazyValue(org.graalvm.compiler.phases.common.LazyValue) LoopsData(org.graalvm.compiler.nodes.loop.LoopsData) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)

Example 20 with LoopsData

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

the class AMD64HotSpotAddressLowering method preProcess.

@Override
public void preProcess(StructuredGraph graph, LoopsDataProvider loopsDataProvider) {
    if (graph.hasLoops()) {
        LoopsData loopsData = loopsDataProvider.getLoopsData(graph);
        loopsData.detectedCountedLoops();
        for (LoopEx loop : loopsData.countedLoops()) {
            for (OffsetAddressNode offsetAdressNode : loop.whole().nodes().filter(OffsetAddressNode.class)) {
                tryOptimize(offsetAdressNode, loop);
            }
        }
    }
}
Also used : LoopsData(org.graalvm.compiler.nodes.loop.LoopsData) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) LoopEx(org.graalvm.compiler.nodes.loop.LoopEx)

Aggregations

LoopsData (org.graalvm.compiler.nodes.loop.LoopsData)23 LoopEx (org.graalvm.compiler.nodes.loop.LoopEx)19 DebugContext (org.graalvm.compiler.debug.DebugContext)8 Block (org.graalvm.compiler.nodes.cfg.Block)5 Node (org.graalvm.compiler.graph.Node)4 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)4 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)3 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)3 ValueNode (org.graalvm.compiler.nodes.ValueNode)3 DeadCodeEliminationPhase (org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)3 HashSet (java.util.HashSet)2 SpeculationLog (jdk.vm.ci.meta.SpeculationLog)2 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)2 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)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 Test (org.junit.Test)2 BytecodePosition (jdk.vm.ci.code.BytecodePosition)1