use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class PushNodesThroughPiTest method compileTestSnippet.
private StructuredGraph compileTestSnippet(final String snippet) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
PhaseContext context = new PhaseContext(getProviders());
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
canonicalizer.apply(graph, context);
canonicalizer.apply(graph, context);
return graph;
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase 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.common.CanonicalizerPhase 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.common.CanonicalizerPhase 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.common.CanonicalizerPhase in project graal by oracle.
the class InvokeExceptionTest method test.
private void test(String snippet) {
StructuredGraph graph = parseProfiled(snippet, AllowAssumptions.NO);
Map<Invoke, Double> hints = new HashMap<>();
for (Invoke invoke : graph.getInvokes()) {
hints.put(invoke, 1000d);
}
HighTierContext context = getDefaultHighTierContext();
new InliningPhase(hints, new CanonicalizerPhase()).apply(graph, context);
new CanonicalizerPhase().apply(graph, context);
new DeadCodeEliminationPhase().apply(graph);
}
Aggregations