use of org.graalvm.compiler.nodes.loop.DefaultLoopPolicies in project graal by oracle.
the class OptimizedBoxNodeTest method testCompare.
@Test
public void testCompare() throws InvalidInstalledCodeException {
final OptionValues testOptions = new OptionValues(getInitialOptions(), DefaultLoopPolicies.Options.FullUnrollMaxNodes, 10000, DefaultLoopPolicies.Options.ExactFullUnrollMaxNodes, 10000);
StructuredGraph g = parseEager(getResolvedJavaMethod("snippetConstantCompare"), AllowAssumptions.NO, testOptions);
CanonicalizerPhase.create().apply(g, getDefaultHighTierContext());
new LoopFullUnrollPhase(createCanonicalizerPhase(), new DefaultLoopPolicies()).apply(g, getDefaultHighTierContext());
CanonicalizerPhase.create().apply(g, getDefaultHighTierContext());
Assert.assertEquals("All ifs must be removed", 0, g.getNodes(IfNode.TYPE).count());
int[] res = new int[200 * 2];
int[] resCompiled = new int[200 * 2];
for (int i = -200; i < 200; i++) {
res[i + 200] = snippetConstantCompare(i);
}
InstalledCode code = getCode(getResolvedJavaMethod("snippetConstantCompare"), testOptions);
for (int i = -200; i < 200; i++) {
resCompiled[i + 200] = (int) code.executeVarargs(i);
}
Assert.assertArrayEquals(res, resCompiled);
}
use of org.graalvm.compiler.nodes.loop.DefaultLoopPolicies in project graal by oracle.
the class LoopUnswitchTest method test.
@SuppressWarnings("try")
private void test(String snippet, String referenceSnippet) {
DebugContext debug = getDebugContext();
final StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
final StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.NO);
new LoopUnswitchingPhase(new DefaultLoopPolicies()).apply(graph, getDefaultHighTierContext());
// Framestates create comparison problems
graph.clearAllStateAfterForTestingOnly();
referenceGraph.clearAllStateAfterForTestingOnly();
createCanonicalizerPhase().apply(graph, getProviders());
createCanonicalizerPhase().apply(referenceGraph, getProviders());
try (DebugContext.Scope s = debug.scope("Test", new DebugDumpScope("Test:" + snippet))) {
assertEquals(referenceGraph, graph);
} catch (Throwable e) {
throw debug.handle(e);
}
}
Aggregations