use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class ScalarTypeSystemTest method test.
private void test(final String snippet, final String referenceSnippet) {
// No debug scope to reduce console noise for @Test(expected = ...) tests
StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
graph.getDebug().dump(DebugContext.BASIC_LEVEL, graph, "Graph");
PhaseContext context = new PhaseContext(getProviders());
new CanonicalizerPhase().apply(graph, context);
StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.NO);
assertEquals(referenceGraph, graph);
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class StampCanonicalizerTest method testZeroReturn.
private void testZeroReturn(String methodName) {
StructuredGraph graph = parseEager(methodName, AllowAssumptions.YES);
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
new DeadCodeEliminationPhase().apply(graph);
assertConstantReturn(graph, 0);
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class EarlyReadEliminationTest method processMethod.
protected StructuredGraph processMethod(String snippet, boolean doLowering) {
StructuredGraph graph = parseEager(getResolvedJavaMethod(snippet), AllowAssumptions.NO);
HighTierContext context = getDefaultHighTierContext();
new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
if (doLowering) {
new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
}
new EarlyReadEliminationPhase(new CanonicalizerPhase()).apply(graph, context);
return graph;
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class EscapeAnalysisTest method testRemovalSpecialCase.
/**
* Test the case where allocations before and during a loop that have no usages other than their
* phi need to be recognized as an important change. This needs a loop so that the allocation is
* not trivially removed by dead code elimination.
*/
@Test
public void testRemovalSpecialCase() {
prepareGraph("testRemovalSpecialCaseSnippet", false);
Assert.assertEquals(2, graph.getNodes().filter(CommitAllocationNode.class).count());
// create the situation by removing the if
graph.replaceFixedWithFloating(graph.getNodes().filter(LoadFieldNode.class).first(), graph.unique(ConstantNode.forInt(0)));
new CanonicalizerPhase().apply(graph, context);
// verify that an additional run removes all allocations
new PartialEscapePhase(false, false, new CanonicalizerPhase(), null, graph.getOptions()).apply(graph, context);
Assert.assertEquals(0, graph.getNodes().filter(CommitAllocationNode.class).count());
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class EscapeAnalysisTest method testChangeHandling.
/**
* Tests that a graph with allocations that does not make progress during PEA will not be
* changed.
*/
@Test
public void testChangeHandling() {
prepareGraph("testChangeHandlingSnippet", false);
Assert.assertEquals(2, graph.getNodes().filter(CommitAllocationNode.class).count());
Assert.assertEquals(1, graph.getNodes().filter(BoxNode.class).count());
List<Node> nodes = graph.getNodes().snapshot();
// verify that an additional run doesn't add or remove nodes
new PartialEscapePhase(false, false, new CanonicalizerPhase(), null, graph.getOptions()).apply(graph, context);
Assert.assertEquals(nodes.size(), graph.getNodeCount());
for (Node node : nodes) {
Assert.assertTrue(node.isAlive());
}
}
Aggregations