use of org.graalvm.compiler.loop.LoopEx in project graal by oracle.
the class AMD64HotSpotAddressLowering method preProcess.
@Override
public void preProcess(StructuredGraph graph) {
if (graph.hasLoops()) {
LoopsData loopsData = new LoopsData(graph);
loopsData.detectedCountedLoops();
for (LoopEx loop : loopsData.countedLoops()) {
for (OffsetAddressNode offsetAdressNode : loop.whole().nodes().filter(OffsetAddressNode.class)) {
tryOptimize(offsetAdressNode, loop);
}
}
}
}
use of org.graalvm.compiler.loop.LoopEx in project graal by oracle.
the class SnippetTemplate method explodeLoops.
public static void explodeLoops(final StructuredGraph snippetCopy, PhaseContext phaseContext) {
// Do any required loop explosion
boolean exploded = false;
do {
exploded = false;
ExplodeLoopNode explodeLoop = snippetCopy.getNodes().filter(ExplodeLoopNode.class).first();
if (explodeLoop != null) {
// Earlier canonicalization may have removed the loop
// altogether
LoopBeginNode loopBegin = explodeLoop.findLoopBegin();
if (loopBegin != null) {
LoopEx loop = new LoopsData(snippetCopy).loop(loopBegin);
Mark mark = snippetCopy.getMark();
LoopTransformations.fullUnroll(loop, phaseContext, new CanonicalizerPhase());
new CanonicalizerPhase().applyIncremental(snippetCopy, phaseContext, mark);
loop.deleteUnusedNodes();
}
GraphUtil.removeFixedWithUnusedInputs(explodeLoop);
exploded = true;
}
} while (exploded);
}
use of org.graalvm.compiler.loop.LoopEx in project graal by oracle.
the class ReferenceGetLoopTest method checkMidTierGraph.
@Override
protected boolean checkMidTierGraph(StructuredGraph graph) {
final LoopsData loops = new LoopsData(graph);
boolean found = false;
for (LoopEx loop : loops.loops()) {
for (Node node : loop.inside().nodes()) {
if (node instanceof Access) {
Access access = (Access) 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));
}
return true;
}
use of org.graalvm.compiler.loop.LoopEx in project graal by oracle.
the class ReassociateInvariantPhase method run.
@SuppressWarnings("try")
@Override
protected void run(StructuredGraph graph) {
int iterations = 0;
DebugContext debug = graph.getDebug();
try (DebugContext.Scope s = debug.scope("ReassociateInvariants")) {
boolean changed = true;
while (changed) {
changed = false;
final LoopsData dataReassociate = new LoopsData(graph);
for (LoopEx loop : dataReassociate.loops()) {
changed |= loop.reassociateInvariants();
}
dataReassociate.deleteUnusedNodes();
iterations++;
debug.dump(DebugContext.VERBOSE_LEVEL, graph, "after iteration %d", iterations);
}
} catch (Throwable e) {
throw debug.handle(e);
}
}
use of org.graalvm.compiler.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);
}
}
Aggregations