use of org.graalvm.compiler.phases.common.CanonicalizerPhase 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.CanonicalizerPhase 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.CanonicalizerPhase in project graal by oracle.
the class GraalCompilerTest method createSuites.
protected Suites createSuites(OptionValues opts) {
Suites ret = backend.getSuites().getDefaultSuites(opts).copy();
ListIterator<BasePhase<? super HighTierContext>> iter = ret.getHighTier().findPhase(ConvertDeoptimizeToGuardPhase.class, true);
if (iter == null) {
/*
* in the economy configuration, we don't have the ConvertDeoptimizeToGuard phase, so we
* just select the first CanonicalizerPhase in HighTier
*/
iter = ret.getHighTier().findPhase(CanonicalizerPhase.class);
}
iter.add(new Phase() {
@Override
protected void run(StructuredGraph graph) {
ComputeLoopFrequenciesClosure.compute(graph);
}
@Override
public float codeSizeIncrease() {
return NodeSize.IGNORE_SIZE_CONTRACT_FACTOR;
}
@Override
protected CharSequence getName() {
return "ComputeLoopFrequenciesPhase";
}
});
ret.getHighTier().appendPhase(new Phase() {
@Override
protected void run(StructuredGraph graph) {
assert checkHighTierGraph(graph) : "failed HighTier graph check";
}
@Override
public float codeSizeIncrease() {
return NodeSize.IGNORE_SIZE_CONTRACT_FACTOR;
}
@Override
protected CharSequence getName() {
return "CheckGraphPhase";
}
});
ret.getMidTier().appendPhase(new Phase() {
@Override
protected void run(StructuredGraph graph) {
assert checkMidTierGraph(graph) : "failed MidTier graph check";
}
@Override
public float codeSizeIncrease() {
return NodeSize.IGNORE_SIZE_CONTRACT_FACTOR;
}
@Override
protected CharSequence getName() {
return "CheckGraphPhase";
}
});
ret.getLowTier().appendPhase(new Phase() {
@Override
protected void run(StructuredGraph graph) {
assert checkLowTierGraph(graph) : "failed LowTier graph check";
}
@Override
public float codeSizeIncrease() {
return NodeSize.IGNORE_SIZE_CONTRACT_FACTOR;
}
@Override
protected CharSequence getName() {
return "CheckGraphPhase";
}
});
return ret;
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class MemoryGraphCanonicalizeTest method testGraph.
public void testGraph(String name, int expectedWrites) {
StructuredGraph graph = parseEager(name, StructuredGraph.AllowAssumptions.YES);
HighTierContext context = getDefaultHighTierContext();
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
new IncrementalCanonicalizerPhase<>(canonicalizer, new FloatingReadPhase()).apply(graph, context);
new CanonicalizerPhase().apply(graph, context);
int writes = graph.getNodes().filter(WriteNode.class).count();
assertTrue(writes == expectedWrites, "Expected %d writes, found %d", expectedWrites, writes);
}
use of org.graalvm.compiler.phases.common.CanonicalizerPhase in project graal by oracle.
the class MemoryScheduleTest method getFinalSchedule.
@SuppressWarnings("try")
private ScheduleResult getFinalSchedule(final String snippet, final TestMode mode, final SchedulingStrategy schedulingStrategy) {
OptionValues options = new OptionValues(getInitialOptions(), OptScheduleOutOfLoops, schedulingStrategy == SchedulingStrategy.LATEST_OUT_OF_LOOPS, OptImplicitNullChecks, false);
final StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO, options);
DebugContext debug = graph.getDebug();
try (DebugContext.Scope d = debug.scope("FloatingReadTest", graph)) {
HighTierContext context = getDefaultHighTierContext();
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
canonicalizer.apply(graph, context);
if (mode == TestMode.INLINED_WITHOUT_FRAMESTATES) {
new InliningPhase(canonicalizer).apply(graph, context);
}
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
if (mode == TestMode.WITHOUT_FRAMESTATES || mode == TestMode.INLINED_WITHOUT_FRAMESTATES) {
graph.clearAllStateAfter();
}
debug.dump(DebugContext.BASIC_LEVEL, graph, "after removal of framestates");
new FloatingReadPhase().apply(graph);
new RemoveValueProxyPhase().apply(graph);
MidTierContext midContext = new MidTierContext(getProviders(), getTargetProvider(), OptimisticOptimizations.ALL, graph.getProfilingInfo());
new GuardLoweringPhase().apply(graph, midContext);
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.MID_TIER).apply(graph, midContext);
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.LOW_TIER).apply(graph, midContext);
SchedulePhase schedule = new SchedulePhase(schedulingStrategy);
schedule.apply(graph);
assertDeepEquals(1, graph.getNodes().filter(StartNode.class).count());
return graph.getLastSchedule();
} catch (Throwable e) {
throw debug.handle(e);
}
}
Aggregations