use of org.graalvm.compiler.phases.common.ConditionalEliminationPhase in project graal by oracle.
the class ConditionalEliminationTest10 method test.
private void test(String snippet, int guardCount) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
PhaseContext context = new PhaseContext(getProviders());
new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
new ConditionalEliminationPhase(true).apply(graph, context);
Assert.assertEquals(guardCount, graph.getNodes().filter(GuardNode.class).count());
}
use of org.graalvm.compiler.phases.common.ConditionalEliminationPhase in project graal by oracle.
the class ConditionalEliminationTest2 method testInstanceOfCheckCastLowered.
@Test
public void testInstanceOfCheckCastLowered() {
StructuredGraph graph = parseEager("testInstanceOfCheckCastSnippet", AllowAssumptions.YES);
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
PhaseContext context = new PhaseContext(getProviders());
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
canonicalizer.apply(graph, context);
new ConditionalEliminationPhase(true).apply(graph, context);
canonicalizer.apply(graph, context);
assertDeepEquals(0, graph.getNodes().filter(GuardNode.class).count());
}
use of org.graalvm.compiler.phases.common.ConditionalEliminationPhase 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.common.ConditionalEliminationPhase 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);
}
use of org.graalvm.compiler.phases.common.ConditionalEliminationPhase in project graal by oracle.
the class LoopPartialUnrollTest method buildGraph.
@SuppressWarnings("try")
public StructuredGraph buildGraph(String name, boolean partialUnroll) {
CompilationIdentifier id = new CompilationIdentifier() {
@Override
public String toString(Verbosity verbosity) {
return name;
}
};
ResolvedJavaMethod method = getResolvedJavaMethod(name);
OptionValues options = new OptionValues(getInitialOptions(), DefaultLoopPolicies.Options.UnrollMaxIterations, 2);
StructuredGraph graph = parse(builder(method, StructuredGraph.AllowAssumptions.YES, id, options), getEagerGraphBuilderSuite());
try (DebugContext.Scope buildScope = graph.getDebug().scope(name, method, graph)) {
MidTierContext context = new MidTierContext(getProviders(), getTargetProvider(), OptimisticOptimizations.ALL, null);
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
canonicalizer.apply(graph, context);
new RemoveValueProxyPhase().apply(graph);
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
new FloatingReadPhase().apply(graph);
new DeadCodeEliminationPhase().apply(graph);
new ConditionalEliminationPhase(true).apply(graph, context);
ComputeLoopFrequenciesClosure.compute(graph);
new GuardLoweringPhase().apply(graph, context);
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, context);
new FrameStateAssignmentPhase().apply(graph);
new DeoptimizationGroupingPhase().apply(graph, context);
canonicalizer.apply(graph, context);
new ConditionalEliminationPhase(true).apply(graph, context);
if (partialUnroll) {
LoopsData dataCounted = new LoopsData(graph);
dataCounted.detectedCountedLoops();
for (LoopEx loop : dataCounted.countedLoops()) {
LoopFragmentInside newSegment = loop.inside().duplicate();
newSegment.insertWithinAfter(loop, false);
}
canonicalizer.apply(graph, getDefaultMidTierContext());
}
new DeadCodeEliminationPhase().apply(graph);
canonicalizer.apply(graph, context);
graph.getDebug().dump(DebugContext.BASIC_LEVEL, graph, "before compare");
return graph;
} catch (Throwable e) {
throw getDebugContext().handle(e);
}
}
Aggregations