use of org.graalvm.compiler.phases.tiers.PhaseContext in project graal by oracle.
the class ReassociateAndCanonicalTest method test.
private <T extends Node & IterableNodeType> void test(String test, String ref) {
StructuredGraph testGraph = parseEager(test, AllowAssumptions.NO);
new CanonicalizerPhase().apply(testGraph, new PhaseContext(getProviders()));
StructuredGraph refGraph = parseEager(ref, AllowAssumptions.NO);
new CanonicalizerPhase().apply(refGraph, new PhaseContext(getProviders()));
assertEquals(testGraph, refGraph);
}
use of org.graalvm.compiler.phases.tiers.PhaseContext in project graal by oracle.
the class IfCanonicalizerTest method test.
private void test(String snippet) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
DebugContext debug = graph.getDebug();
ParameterNode param = graph.getNodes(ParameterNode.TYPE).iterator().next();
ConstantNode constant = ConstantNode.forInt(0, graph);
for (Node n : param.usages().snapshot()) {
if (!(n instanceof FrameState)) {
n.replaceFirstInput(param, constant);
}
}
debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
for (FrameState fs : param.usages().filter(FrameState.class).snapshot()) {
fs.replaceFirstInput(param, null);
param.safeDelete();
}
StructuredGraph referenceGraph = parseEager(REFERENCE_SNIPPET, AllowAssumptions.YES);
assertEquals(referenceGraph, graph);
}
use of org.graalvm.compiler.phases.tiers.PhaseContext in project graal by oracle.
the class IntegerEqualsCanonicalizerTest method getCanonicalizedGraph.
private StructuredGraph getCanonicalizedGraph(String snippet) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
for (FrameState state : graph.getNodes(FrameState.TYPE).snapshot()) {
state.replaceAtUsages(null);
state.safeDelete();
}
return graph;
}
use of org.graalvm.compiler.phases.tiers.PhaseContext in project graal by oracle.
the class ConditionalEliminationTestBase method testProxies.
public void testProxies(String snippet, int expectedProxiesCreated) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
PhaseContext context = new PhaseContext(getProviders());
CanonicalizerPhase canonicalizer1 = new CanonicalizerPhase();
canonicalizer1.disableSimplification();
canonicalizer1.apply(graph, context);
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
canonicalizer.apply(graph, context);
int baseProxyCount = graph.getNodes().filter(ProxyNode.class).count();
new ConditionalEliminationPhase(true).apply(graph, context);
canonicalizer.apply(graph, context);
new SchedulePhase(graph.getOptions()).apply(graph, context);
int actualProxiesCreated = graph.getNodes().filter(ProxyNode.class).count() - baseProxyCount;
Assert.assertEquals(expectedProxiesCreated, actualProxiesCreated);
}
use of org.graalvm.compiler.phases.tiers.PhaseContext in project graal by oracle.
the class ConditionalEliminationTestBase method testConditionalElimination.
@SuppressWarnings("try")
protected void testConditionalElimination(String snippet, String referenceSnippet, boolean applyConditionalEliminationOnReference, boolean applyLowering) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
DebugContext debug = graph.getDebug();
debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
PhaseContext context = new PhaseContext(getProviders());
CanonicalizerPhase canonicalizer1 = new CanonicalizerPhase();
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
try (DebugContext.Scope scope = debug.scope("ConditionalEliminationTest", graph)) {
prepareGraph(graph, canonicalizer1, context, applyLowering);
new IterativeConditionalEliminationPhase(canonicalizer, true).apply(graph, context);
canonicalizer.apply(graph, context);
canonicalizer.apply(graph, context);
} catch (Throwable t) {
debug.handle(t);
}
StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.YES);
try (DebugContext.Scope scope = debug.scope("ConditionalEliminationTest.ReferenceGraph", referenceGraph)) {
prepareGraph(referenceGraph, canonicalizer, context, applyLowering);
if (applyConditionalEliminationOnReference) {
new ConditionalEliminationPhase(true).apply(referenceGraph, context);
}
canonicalizer.apply(referenceGraph, context);
canonicalizer.apply(referenceGraph, context);
} catch (Throwable t) {
debug.handle(t);
}
assertEquals(referenceGraph, graph);
}
Aggregations