Search in sources :

Example 6 with DefaultLoopPolicies

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

the class OptimizedBoxNodeTest method testCompare.

@Test
public void testCompare() throws InvalidInstalledCodeException {
    final OptionValues testOptions = new OptionValues(getInitialOptions(), DefaultLoopPolicies.Options.FullUnrollMaxNodes, 10000, DefaultLoopPolicies.Options.ExactFullUnrollMaxNodes, 10000);
    StructuredGraph g = parseEager(getResolvedJavaMethod("snippetConstantCompare"), AllowAssumptions.NO, testOptions);
    CanonicalizerPhase.create().apply(g, getDefaultHighTierContext());
    new LoopFullUnrollPhase(createCanonicalizerPhase(), new DefaultLoopPolicies()).apply(g, getDefaultHighTierContext());
    CanonicalizerPhase.create().apply(g, getDefaultHighTierContext());
    Assert.assertEquals("All ifs must be removed", 0, g.getNodes(IfNode.TYPE).count());
    int[] res = new int[200 * 2];
    int[] resCompiled = new int[200 * 2];
    for (int i = -200; i < 200; i++) {
        res[i + 200] = snippetConstantCompare(i);
    }
    InstalledCode code = getCode(getResolvedJavaMethod("snippetConstantCompare"), testOptions);
    for (int i = -200; i < 200; i++) {
        resCompiled[i + 200] = (int) code.executeVarargs(i);
    }
    Assert.assertArrayEquals(res, resCompiled);
}
Also used : LoopFullUnrollPhase(org.graalvm.compiler.loop.phases.LoopFullUnrollPhase) OptionValues(org.graalvm.compiler.options.OptionValues) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DefaultLoopPolicies(org.graalvm.compiler.nodes.loop.DefaultLoopPolicies) InstalledCode(jdk.vm.ci.code.InstalledCode) Test(org.junit.Test)

Example 7 with DefaultLoopPolicies

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

the class LoopUnswitchTest method test.

@SuppressWarnings("try")
private void test(String snippet, String referenceSnippet) {
    DebugContext debug = getDebugContext();
    final StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
    final StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.NO);
    new LoopUnswitchingPhase(new DefaultLoopPolicies()).apply(graph, getDefaultHighTierContext());
    // Framestates create comparison problems
    graph.clearAllStateAfterForTestingOnly();
    referenceGraph.clearAllStateAfterForTestingOnly();
    createCanonicalizerPhase().apply(graph, getProviders());
    createCanonicalizerPhase().apply(referenceGraph, getProviders());
    try (DebugContext.Scope s = debug.scope("Test", new DebugDumpScope("Test:" + snippet))) {
        assertEquals(referenceGraph, graph);
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) DefaultLoopPolicies(org.graalvm.compiler.nodes.loop.DefaultLoopPolicies) LoopUnswitchingPhase(org.graalvm.compiler.loop.phases.LoopUnswitchingPhase) DebugContext(org.graalvm.compiler.debug.DebugContext)

Aggregations

DefaultLoopPolicies (org.graalvm.compiler.nodes.loop.DefaultLoopPolicies)7 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)5 LoopFullUnrollPhase (org.graalvm.compiler.loop.phases.LoopFullUnrollPhase)4 Test (org.junit.Test)4 DebugContext (org.graalvm.compiler.debug.DebugContext)2 DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)2 LoopPeelingPhase (org.graalvm.compiler.loop.phases.LoopPeelingPhase)2 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)2 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)2 PartialEscapePhase (org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase)2 InstalledCode (jdk.vm.ci.code.InstalledCode)1 LoopUnswitchingPhase (org.graalvm.compiler.loop.phases.LoopUnswitchingPhase)1 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)1 CoreProviders (org.graalvm.compiler.nodes.spi.CoreProviders)1 AllocatedObjectNode (org.graalvm.compiler.nodes.virtual.AllocatedObjectNode)1 CommitAllocationNode (org.graalvm.compiler.nodes.virtual.CommitAllocationNode)1 OptionValues (org.graalvm.compiler.options.OptionValues)1 DeadCodeEliminationPhase (org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)1 LockEliminationPhase (org.graalvm.compiler.phases.common.LockEliminationPhase)1 SchedulePhase (org.graalvm.compiler.phases.schedule.SchedulePhase)1