Search in sources :

Example 71 with CanonicalizerPhase

use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.

the class ConditionalEliminationTest10 method test.

private void test(String snippet, int guardCount) {
    StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
    PhaseContext context = new PhaseContext(getProviders());
    new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    new ConditionalEliminationPhase(true).apply(graph, context);
    Assert.assertEquals(guardCount, graph.getNodes().filter(GuardNode.class).count());
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) ConditionalEliminationPhase(org.graalvm.compiler.phases.common.ConditionalEliminationPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase)

Example 72 with CanonicalizerPhase

use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.

the class ConditionalEliminationTest2 method testInstanceOfCheckCastLowered.

@Test
public void testInstanceOfCheckCastLowered() {
    StructuredGraph graph = parseEager("testInstanceOfCheckCastSnippet", AllowAssumptions.YES);
    CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
    PhaseContext context = new PhaseContext(getProviders());
    new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    canonicalizer.apply(graph, context);
    new ConditionalEliminationPhase(true).apply(graph, context);
    canonicalizer.apply(graph, context);
    assertDeepEquals(0, graph.getNodes().filter(GuardNode.class).count());
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) ConditionalEliminationPhase(org.graalvm.compiler.phases.common.ConditionalEliminationPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) Test(org.junit.Test)

Example 73 with CanonicalizerPhase

use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.

the class GraalCompilerTest method createSuites.

protected Suites createSuites(OptionValues opts) {
    Suites ret = backend.getSuites().getDefaultSuites(opts).copy();
    ListIterator<BasePhase<? super HighTierContext>> iter = ret.getHighTier().findPhase(ConvertDeoptimizeToGuardPhase.class, true);
    if (iter == null) {
        /*
             * in the economy configuration, we don't have the ConvertDeoptimizeToGuard phase, so we
             * just select the first CanonicalizerPhase in HighTier
             */
        iter = ret.getHighTier().findPhase(CanonicalizerPhase.class);
    }
    iter.add(new Phase() {

        @Override
        protected void run(StructuredGraph graph) {
            ComputeLoopFrequenciesClosure.compute(graph);
        }

        @Override
        public float codeSizeIncrease() {
            return NodeSize.IGNORE_SIZE_CONTRACT_FACTOR;
        }

        @Override
        protected CharSequence getName() {
            return "ComputeLoopFrequenciesPhase";
        }
    });
    ret.getHighTier().appendPhase(new Phase() {

        @Override
        protected void run(StructuredGraph graph) {
            assert checkHighTierGraph(graph) : "failed HighTier graph check";
        }

        @Override
        public float codeSizeIncrease() {
            return NodeSize.IGNORE_SIZE_CONTRACT_FACTOR;
        }

        @Override
        protected CharSequence getName() {
            return "CheckGraphPhase";
        }
    });
    ret.getMidTier().appendPhase(new Phase() {

        @Override
        protected void run(StructuredGraph graph) {
            assert checkMidTierGraph(graph) : "failed MidTier graph check";
        }

        @Override
        public float codeSizeIncrease() {
            return NodeSize.IGNORE_SIZE_CONTRACT_FACTOR;
        }

        @Override
        protected CharSequence getName() {
            return "CheckGraphPhase";
        }
    });
    ret.getLowTier().appendPhase(new Phase() {

        @Override
        protected void run(StructuredGraph graph) {
            assert checkLowTierGraph(graph) : "failed LowTier graph check";
        }

        @Override
        public float codeSizeIncrease() {
            return NodeSize.IGNORE_SIZE_CONTRACT_FACTOR;
        }

        @Override
        protected CharSequence getName() {
            return "CheckGraphPhase";
        }
    });
    return ret;
}
Also used : BasePhase(org.graalvm.compiler.phases.BasePhase) SchedulePhase(org.graalvm.compiler.phases.schedule.SchedulePhase) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) Phase(org.graalvm.compiler.phases.Phase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) ConvertDeoptimizeToGuardPhase(org.graalvm.compiler.phases.common.ConvertDeoptimizeToGuardPhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) BasePhase(org.graalvm.compiler.phases.BasePhase) LIRSuites(org.graalvm.compiler.lir.phases.LIRSuites) Suites(org.graalvm.compiler.phases.tiers.Suites)

Example 74 with CanonicalizerPhase

use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.

the class MemoryGraphCanonicalizeTest method testGraph.

public void testGraph(String name, int expectedWrites) {
    StructuredGraph graph = parseEager(name, StructuredGraph.AllowAssumptions.YES);
    HighTierContext context = getDefaultHighTierContext();
    CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
    new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    new IncrementalCanonicalizerPhase<>(canonicalizer, new FloatingReadPhase()).apply(graph, context);
    new CanonicalizerPhase().apply(graph, context);
    int writes = graph.getNodes().filter(WriteNode.class).count();
    assertTrue(writes == expectedWrites, "Expected %d writes, found %d", expectedWrites, writes);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) IncrementalCanonicalizerPhase(org.graalvm.compiler.phases.common.IncrementalCanonicalizerPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) WriteNode(org.graalvm.compiler.nodes.memory.WriteNode) FloatingReadPhase(org.graalvm.compiler.phases.common.FloatingReadPhase)

Example 75 with CanonicalizerPhase

use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.

the class MemoryScheduleTest method getFinalSchedule.

@SuppressWarnings("try")
private ScheduleResult getFinalSchedule(final String snippet, final TestMode mode, final SchedulingStrategy schedulingStrategy) {
    OptionValues options = new OptionValues(getInitialOptions(), OptScheduleOutOfLoops, schedulingStrategy == SchedulingStrategy.LATEST_OUT_OF_LOOPS, OptImplicitNullChecks, false);
    final StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO, options);
    DebugContext debug = graph.getDebug();
    try (DebugContext.Scope d = debug.scope("FloatingReadTest", graph)) {
        HighTierContext context = getDefaultHighTierContext();
        CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
        canonicalizer.apply(graph, context);
        if (mode == TestMode.INLINED_WITHOUT_FRAMESTATES) {
            new InliningPhase(canonicalizer).apply(graph, context);
        }
        new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
        if (mode == TestMode.WITHOUT_FRAMESTATES || mode == TestMode.INLINED_WITHOUT_FRAMESTATES) {
            graph.clearAllStateAfter();
        }
        debug.dump(DebugContext.BASIC_LEVEL, graph, "after removal of framestates");
        new FloatingReadPhase().apply(graph);
        new RemoveValueProxyPhase().apply(graph);
        MidTierContext midContext = new MidTierContext(getProviders(), getTargetProvider(), OptimisticOptimizations.ALL, graph.getProfilingInfo());
        new GuardLoweringPhase().apply(graph, midContext);
        new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, midContext);
        new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.LOW_TIER).apply(graph, midContext);
        SchedulePhase schedule = new SchedulePhase(schedulingStrategy);
        schedule.apply(graph);
        assertDeepEquals(1, graph.getNodes().filter(StartNode.class).count());
        return graph.getLastSchedule();
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : SchedulePhase(org.graalvm.compiler.phases.schedule.SchedulePhase) OptionValues(org.graalvm.compiler.options.OptionValues) RemoveValueProxyPhase(org.graalvm.compiler.phases.common.RemoveValueProxyPhase) GuardLoweringPhase(org.graalvm.compiler.phases.common.GuardLoweringPhase) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) FloatingReadPhase(org.graalvm.compiler.phases.common.FloatingReadPhase) MidTierContext(org.graalvm.compiler.phases.tiers.MidTierContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) GuardLoweringPhase(org.graalvm.compiler.phases.common.GuardLoweringPhase)

Aggregations

CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)114 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)98 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)60 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)48 DebugContext (org.graalvm.compiler.debug.DebugContext)34 Test (org.junit.Test)33 LoweringPhase (org.graalvm.compiler.phases.common.LoweringPhase)31 InliningPhase (org.graalvm.compiler.phases.common.inlining.InliningPhase)27 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)17 DeadCodeEliminationPhase (org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)16 PartialEscapePhase (org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase)14 Node (org.graalvm.compiler.graph.Node)12 FloatingReadPhase (org.graalvm.compiler.phases.common.FloatingReadPhase)12 DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)10 OptionValues (org.graalvm.compiler.options.OptionValues)10 GuardLoweringPhase (org.graalvm.compiler.phases.common.GuardLoweringPhase)10 ConditionalEliminationPhase (org.graalvm.compiler.phases.common.ConditionalEliminationPhase)9 MidTierContext (org.graalvm.compiler.phases.tiers.MidTierContext)9 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)8 Invoke (org.graalvm.compiler.nodes.Invoke)8