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);
}
}
}
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);
}
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());
}
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());
}
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;
}
Aggregations