use of org.graalvm.compiler.nodes.loop.LoopFragmentInside 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 = this.createCanonicalizerPhase();
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);
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 = getDefaultMidTierContext().getLoopsDataProvider().getLoopsData(graph);
dataCounted.detectedCountedLoops();
assertTrue(!dataCounted.countedLoops().isEmpty(), "must have counted loops");
for (LoopEx loop : dataCounted.countedLoops()) {
LoopFragmentInside newSegment = loop.inside().duplicate();
newSegment.insertWithinAfter(loop, null);
}
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);
}
}
use of org.graalvm.compiler.nodes.loop.LoopFragmentInside in project graal by oracle.
the class LoopTransformations method partialUnroll.
public static void partialUnroll(LoopEx loop, EconomicMap<LoopBeginNode, OpaqueNode> opaqueUnrolledStrides) {
assert loop.loopBegin().isMainLoop();
loop.loopBegin().graph().getDebug().log("LoopPartialUnroll %s", loop);
adaptCountedLoopExitProbability(loop.counted().getCountedExit(), loop.localLoopFrequency() / 2D);
LoopFragmentInside newSegment = loop.inside().duplicate();
newSegment.insertWithinAfter(loop, opaqueUnrolledStrides);
}
use of org.graalvm.compiler.nodes.loop.LoopFragmentInside in project graal by oracle.
the class LoopTransformations method peel.
public static LoopFragmentInside peel(LoopEx loop) {
loop.detectCounted();
double frequencyBefore = -1D;
AbstractBeginNode countedExit = null;
if (loop.isCounted()) {
frequencyBefore = loop.localLoopFrequency();
countedExit = loop.counted().getCountedExit();
}
LoopFragmentInside inside = loop.inside().duplicate();
inside.insertBefore(loop);
loop.loopBegin().incrementPeelings();
if (countedExit != null) {
adaptCountedLoopExitProbability(countedExit, frequencyBefore - 1D);
}
return inside;
}
Aggregations