Search in sources :

Example 1 with ReadEliminationPhase

use of org.graalvm.compiler.virtual.phases.ea.ReadEliminationPhase in project graal by oracle.

the class NestedLoopEffectsPhaseComplexityTest method testAndTime.

private void testAndTime(String snippet) {
    for (int i = InliningCountLowerBound; i < InliningCountUpperBound; i++) {
        StructuredGraph g1 = prepareGraph(snippet, i);
        StructuredGraph g2 = (StructuredGraph) g1.copy(g1.getDebug());
        ResolvedJavaMethod method = g1.method();
        long elapsedRE = runAndTimePhase(g1, new ReadEliminationPhase(createCanonicalizerPhase()));
        long elapsedPEA = runAndTimePhase(g2, new PartialEscapePhase(true, createCanonicalizerPhase(), g1.getOptions()));
        if (LOG_PHASE_TIMINGS) {
            TTY.printf("Needed %dms to run early partial escape analysis on a graph with %d nested loops compiling method %s\n", elapsedPEA, i, method);
        }
        if (LOG_PHASE_TIMINGS) {
            TTY.printf("Needed %dms to run early read elimination on a graph with %d nested loops compiling method %s\n", elapsedRE, i, method);
        }
    }
}
Also used : PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ReadEliminationPhase(org.graalvm.compiler.virtual.phases.ea.ReadEliminationPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 2 with ReadEliminationPhase

use of org.graalvm.compiler.virtual.phases.ea.ReadEliminationPhase in project graal by oracle.

the class ReadEliminationTest method testDeadBranches.

@Test
public void testDeadBranches() {
    StructuredGraph graph = parseEager(getResolvedJavaMethod("cfgSnippet"), AllowAssumptions.NO);
    HighTierContext context = getDefaultHighTierContext();
    int index = 0;
    boolean[] conditions = new boolean[] { true, false, false, true, true, true, false };
    /*
         * Create a graph with "dead" branches in the beginning.
         */
    for (Node n : graph.getNodes()) {
        if (n instanceof IfNode) {
            IfNode ifNode = (IfNode) n;
            ifNode.setCondition(LogicConstantNode.forBoolean(conditions[index++], graph));
        }
    }
    new ReadEliminationPhase(createCanonicalizerPhase()).apply(graph, context);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) LoadFieldNode(org.graalvm.compiler.nodes.java.LoadFieldNode) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) IfNode(org.graalvm.compiler.nodes.IfNode) LogicConstantNode(org.graalvm.compiler.nodes.LogicConstantNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) StoreFieldNode(org.graalvm.compiler.nodes.java.StoreFieldNode) Node(org.graalvm.compiler.graph.Node) ProxyNode(org.graalvm.compiler.nodes.ProxyNode) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) IfNode(org.graalvm.compiler.nodes.IfNode) ReadEliminationPhase(org.graalvm.compiler.virtual.phases.ea.ReadEliminationPhase) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Example 3 with ReadEliminationPhase

use of org.graalvm.compiler.virtual.phases.ea.ReadEliminationPhase in project graal by oracle.

the class ConditionalEliminationTest15 method checkNodeCount.

private void checkNodeCount(String methodName, Class<? extends Node> nodeClass, int count) {
    StructuredGraph graph = parseEager(methodName, AllowAssumptions.YES);
    CanonicalizerPhase canonicalizer = this.createCanonicalizerPhase();
    CoreProviders context = getProviders();
    new LoweringPhase(this.createCanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    canonicalizer.apply(graph, context);
    // Merge arr.length reads.
    new ReadEliminationPhase(canonicalizer).apply(graph, context);
    new IterativeConditionalEliminationPhase(canonicalizer, true).apply(graph, context);
    getDebugContext().dump(DebugContext.BASIC_LEVEL, graph, "After ConditionalEliminationPhase");
    Assert.assertEquals(count, graph.getNodes().filter(nodeClass).count());
}
Also used : IterativeConditionalEliminationPhase(org.graalvm.compiler.phases.common.IterativeConditionalEliminationPhase) CoreProviders(org.graalvm.compiler.nodes.spi.CoreProviders) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) ReadEliminationPhase(org.graalvm.compiler.virtual.phases.ea.ReadEliminationPhase)

Example 4 with ReadEliminationPhase

use of org.graalvm.compiler.virtual.phases.ea.ReadEliminationPhase in project graal by oracle.

the class UnsafeReadEliminationTest method testEarlyReadElimination.

public void testEarlyReadElimination(StructuredGraph graph, int reads, int writes) {
    CoreProviders context = getDefaultHighTierContext();
    CanonicalizerPhase canonicalizer = createCanonicalizerPhase();
    canonicalizer.apply(graph, context);
    new ReadEliminationPhase(canonicalizer).apply(graph, context);
    Assert.assertEquals(3, graph.getNodes().filter(UnsafeAccessNode.class).count());
    // after lowering the same applies for reads and writes
    new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    canonicalizer.apply(graph, context);
    new ReadEliminationPhase(canonicalizer).apply(graph, context);
    Assert.assertEquals(reads, graph.getNodes().filter(ReadNode.class).count());
    Assert.assertEquals(writes, graph.getNodes().filter(WriteNode.class).count());
}
Also used : CoreProviders(org.graalvm.compiler.nodes.spi.CoreProviders) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) ReadEliminationPhase(org.graalvm.compiler.virtual.phases.ea.ReadEliminationPhase)

Example 5 with ReadEliminationPhase

use of org.graalvm.compiler.virtual.phases.ea.ReadEliminationPhase in project graal by oracle.

the class ReadEliminationTest method processMethod.

protected StructuredGraph processMethod(String snippet, boolean doLowering) {
    StructuredGraph graph = parseEager(getResolvedJavaMethod(snippet), AllowAssumptions.NO);
    HighTierContext context = getDefaultHighTierContext();
    createInliningPhase().apply(graph, context);
    if (doLowering) {
        new LoweringPhase(createCanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    }
    new ReadEliminationPhase(createCanonicalizerPhase()).apply(graph, context);
    return graph;
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) ReadEliminationPhase(org.graalvm.compiler.virtual.phases.ea.ReadEliminationPhase)

Aggregations

ReadEliminationPhase (org.graalvm.compiler.virtual.phases.ea.ReadEliminationPhase)5 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)4 LoweringPhase (org.graalvm.compiler.phases.common.LoweringPhase)3 CoreProviders (org.graalvm.compiler.nodes.spi.CoreProviders)2 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)2 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)2 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)1 Node (org.graalvm.compiler.graph.Node)1 IfNode (org.graalvm.compiler.nodes.IfNode)1 LogicConstantNode (org.graalvm.compiler.nodes.LogicConstantNode)1 ProxyNode (org.graalvm.compiler.nodes.ProxyNode)1 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1 ValuePhiNode (org.graalvm.compiler.nodes.ValuePhiNode)1 LoadFieldNode (org.graalvm.compiler.nodes.java.LoadFieldNode)1 StoreFieldNode (org.graalvm.compiler.nodes.java.StoreFieldNode)1 ReadNode (org.graalvm.compiler.nodes.memory.ReadNode)1 IterativeConditionalEliminationPhase (org.graalvm.compiler.phases.common.IterativeConditionalEliminationPhase)1 PartialEscapePhase (org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase)1