use of org.graalvm.compiler.nodes.loop.LoopEx in project graal by oracle.
the class CountedLoopMaxTripCountPiTest method checkGraph.
/**
* In the high and mid tiers, make sure that all max trip count nodes are the unique pi node in
* the graph (i.e., exactly the one proved by the guard). We don't check the low tier because pi
* nodes are eliminated by FixReads.
*/
void checkGraph(StructuredGraph graph, LoopsData loops) {
loops.detectedCountedLoops();
for (LoopEx loop : loops.loops()) {
Assert.assertTrue("expect all loops to be counted", loop.isCounted());
ValueNode maxTripCountNode = loop.counted().maxTripCountNode();
Assert.assertTrue("expect a PiNode for the guarded maxTripCount, got: " + maxTripCountNode, maxTripCountNode instanceof PiNode);
}
PiNode[] pis = graph.getNodes().filter(PiNode.class).snapshot().toArray(new PiNode[0]);
Assert.assertEquals("number of PiNodes in the graph", 1, pis.length);
}
use of org.graalvm.compiler.nodes.loop.LoopEx in project graal by oracle.
the class ReferenceGetLoopTest method checkMidTierGraph.
@Override
protected void checkMidTierGraph(StructuredGraph graph) {
final LoopsData loops = getDefaultMidTierContext().getLoopsDataProvider().getLoopsData(graph);
boolean found = false;
for (LoopEx loop : loops.loops()) {
for (Node node : loop.inside().nodes()) {
if (node instanceof MemoryAccess) {
MemoryAccess access = (MemoryAccess) node;
LocationIdentity location = access.getLocationIdentity();
if (location instanceof FieldLocationIdentity) {
ResolvedJavaField field = ((FieldLocationIdentity) location).getField();
if (field.getName().equals("referent") && field.getDeclaringClass().equals(getMetaAccess().lookupJavaType(Reference.class))) {
found = true;
}
}
}
}
}
if (!found) {
assertTrue(false, "Reference.referent not found in loop: " + getCanonicalGraphString(graph, true, false));
}
}
use of org.graalvm.compiler.nodes.loop.LoopEx in project graal by oracle.
the class LoopsDataTest method testouterFirst.
@Test
public void testouterFirst() {
LoopsData loops = getLoopsData();
Set<LoopEx> seen = new HashSet<>();
for (LoopEx loop : loops.outerFirst()) {
assertFalse(seen.contains(loop), "%s has already been seen", loop);
if (loop.parent() != null) {
assertTrue(seen.contains(loop.parent()), "%s's parent (%s) should have already been seen", loop, loop.parent());
}
seen.add(loop);
}
}
use of org.graalvm.compiler.nodes.loop.LoopEx in project graal by oracle.
the class LoopFullUnrollPhase method run.
@Override
protected void run(StructuredGraph graph, CoreProviders context) {
if (GraalOptions.FullUnroll.getValue(graph.getOptions())) {
DebugContext debug = graph.getDebug();
if (graph.hasLoops()) {
boolean peeled;
int applications = 0;
do {
peeled = false;
final LoopsData dataCounted = context.getLoopsDataProvider().getLoopsData(graph);
dataCounted.detectedCountedLoops();
List<LoopEx> countedLoops = dataCounted.countedLoops();
countedLoops.sort(LOOP_COMPARATOR);
for (LoopEx loop : countedLoops) {
if (getPolicies().shouldFullUnroll(loop)) {
debug.log("FullUnroll %s", loop);
LoopTransformations.fullUnroll(loop, context, canonicalizer);
FULLY_UNROLLED_LOOPS.increment(debug);
debug.dump(DebugContext.DETAILED_LEVEL, graph, "FullUnroll %s", loop);
peeled = true;
break;
}
}
dataCounted.deleteUnusedNodes();
applications++;
} while (peeled && applications < Options.FullUnrollMaxApplication.getValue(graph.getOptions()));
}
}
}
use of org.graalvm.compiler.nodes.loop.LoopEx in project graal by oracle.
the class LoopPeelingPhase method run.
@Override
@SuppressWarnings("try")
protected void run(StructuredGraph graph, CoreProviders context) {
DebugContext debug = graph.getDebug();
if (graph.hasLoops()) {
LoopsData data = context.getLoopsDataProvider().getLoopsData(graph);
try (DebugContext.Scope s = debug.scope("peeling", data.getCFG())) {
for (LoopEx loop : data.outerFirst()) {
if (canPeel(loop)) {
if (LoopPolicies.Options.PeelALot.getValue(graph.getOptions()) || getPolicies().shouldPeel(loop, data.getCFG(), context)) {
debug.log("Peeling %s", loop);
PEELED.increment(debug);
LoopTransformations.peel(loop);
debug.dump(DebugContext.DETAILED_LEVEL, graph, "Peeling %s", loop);
}
}
}
data.deleteUnusedNodes();
} catch (Throwable t) {
throw debug.handle(t);
}
}
}
Aggregations