< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.loop.phases/src/org/graalvm/compiler/loop/phases/LoopTransformations.java

Print this page

        

*** 52,62 **** import org.graalvm.compiler.nodes.FixedNode; import org.graalvm.compiler.nodes.FixedWithNextNode; import org.graalvm.compiler.nodes.IfNode; import org.graalvm.compiler.nodes.LogicNode; import org.graalvm.compiler.nodes.LoopBeginNode; - import org.graalvm.compiler.nodes.LoopExitNode; import org.graalvm.compiler.nodes.NodeView; import org.graalvm.compiler.nodes.PhiNode; import org.graalvm.compiler.nodes.SafepointNode; import org.graalvm.compiler.nodes.StructuredGraph; import org.graalvm.compiler.nodes.ValueNode; --- 52,61 ----
*** 229,243 **** public static LoopBeginNode insertPrePostLoops(LoopEx loop) { StructuredGraph graph = loop.loopBegin().graph(); graph.getDebug().log("LoopTransformations.insertPrePostLoops %s", loop); LoopFragmentWhole preLoop = loop.whole(); CountedLoopInfo preCounted = loop.counted(); - IfNode preLimit = preCounted.getLimitTest(); - assert preLimit != null; LoopBeginNode preLoopBegin = loop.loopBegin(); ! LoopExitNode preLoopExitNode = preLoopBegin.getSingleLoopExit(); ! FixedNode continuationNode = preLoopExitNode.next(); // Each duplication is inserted after the original, ergo create the post loop first LoopFragmentWhole mainLoop = preLoop.duplicate(); LoopFragmentWhole postLoop = preLoop.duplicate(); preLoopBegin.incrementSplits(); --- 228,242 ---- public static LoopBeginNode insertPrePostLoops(LoopEx loop) { StructuredGraph graph = loop.loopBegin().graph(); graph.getDebug().log("LoopTransformations.insertPrePostLoops %s", loop); LoopFragmentWhole preLoop = loop.whole(); CountedLoopInfo preCounted = loop.counted(); LoopBeginNode preLoopBegin = loop.loopBegin(); ! AbstractBeginNode preLoopExitNode = preCounted.getCountedExit(); ! ! assert preLoop.nodes().contains(preLoopBegin); ! assert preLoop.nodes().contains(preLoopExitNode); // Each duplication is inserted after the original, ergo create the post loop first LoopFragmentWhole mainLoop = preLoop.duplicate(); LoopFragmentWhole postLoop = preLoop.duplicate(); preLoopBegin.incrementSplits();
*** 247,273 **** LoopBeginNode mainLoopBegin = mainLoop.getDuplicatedNode(preLoopBegin); mainLoopBegin.setMainLoop(); LoopBeginNode postLoopBegin = postLoop.getDuplicatedNode(preLoopBegin); postLoopBegin.setPostLoop(); ! EndNode postEndNode = getBlockEndAfterLoopExit(postLoopBegin); AbstractMergeNode postMergeNode = postEndNode.merge(); - LoopExitNode postLoopExitNode = postLoopBegin.getSingleLoopExit(); // Update the main loop phi initialization to carry from the pre loop for (PhiNode prePhiNode : preLoopBegin.phis()) { PhiNode mainPhiNode = mainLoop.getDuplicatedNode(prePhiNode); mainPhiNode.setValueAt(0, prePhiNode); } ! EndNode mainEndNode = getBlockEndAfterLoopExit(mainLoopBegin); AbstractMergeNode mainMergeNode = mainEndNode.merge(); AbstractEndNode postEntryNode = postLoopBegin.forwardEnd(); // In the case of no Bounds tests, we just flow right into the main loop AbstractBeginNode mainLandingNode = BeginNode.begin(postEntryNode); - LoopExitNode mainLoopExitNode = mainLoopBegin.getSingleLoopExit(); mainLoopExitNode.setNext(mainLandingNode); preLoopExitNode.setNext(mainLoopBegin.forwardEnd()); // Add and update any phi edges as per merge usage as needed and update usages processPreLoopPhis(loop, mainLoop, postLoop); --- 246,275 ---- LoopBeginNode mainLoopBegin = mainLoop.getDuplicatedNode(preLoopBegin); mainLoopBegin.setMainLoop(); LoopBeginNode postLoopBegin = postLoop.getDuplicatedNode(preLoopBegin); postLoopBegin.setPostLoop(); ! AbstractBeginNode postLoopExitNode = postLoop.getDuplicatedNode(preLoopExitNode); ! EndNode postEndNode = getBlockEndAfterLoopExit(postLoopExitNode); AbstractMergeNode postMergeNode = postEndNode.merge(); // Update the main loop phi initialization to carry from the pre loop for (PhiNode prePhiNode : preLoopBegin.phis()) { PhiNode mainPhiNode = mainLoop.getDuplicatedNode(prePhiNode); mainPhiNode.setValueAt(0, prePhiNode); } ! AbstractBeginNode mainLoopExitNode = mainLoop.getDuplicatedNode(preLoopExitNode); ! EndNode mainEndNode = getBlockEndAfterLoopExit(mainLoopExitNode); AbstractMergeNode mainMergeNode = mainEndNode.merge(); AbstractEndNode postEntryNode = postLoopBegin.forwardEnd(); + // Exits have been merged, find the continuation below the merge + FixedNode continuationNode = mainMergeNode.next(); + // In the case of no Bounds tests, we just flow right into the main loop AbstractBeginNode mainLandingNode = BeginNode.begin(postEntryNode); mainLoopExitNode.setNext(mainLandingNode); preLoopExitNode.setNext(mainLoopBegin.forwardEnd()); // Add and update any phi edges as per merge usage as needed and update usages processPreLoopPhis(loop, mainLoop, postLoop);
*** 335,346 **** } /** * Find the end of the block following the LoopExit. */ ! private static EndNode getBlockEndAfterLoopExit(LoopBeginNode curLoopBegin) { ! FixedNode node = curLoopBegin.getSingleLoopExit().next(); // Find the last node after the exit blocks starts return getBlockEnd(node); } private static EndNode getBlockEnd(FixedNode node) { --- 337,348 ---- } /** * Find the end of the block following the LoopExit. */ ! private static EndNode getBlockEndAfterLoopExit(AbstractBeginNode exit) { ! FixedNode node = exit.next(); // Find the last node after the exit blocks starts return getBlockEnd(node); } private static EndNode getBlockEnd(FixedNode node) {
*** 421,430 **** --- 423,435 ---- Math.addExact(stride, stride); } catch (ArithmeticException ae) { condition.getDebug().log(DebugContext.VERBOSE_LEVEL, "isUnrollableLoop %s doubling the stride overflows %d", loopBegin, stride); return false; } + if (!loop.canDuplicateLoop()) { + return false; + } if (loopBegin.isMainLoop() || loopBegin.isSimpleLoop()) { // Flow-less loops to partial unroll for now. 3 blocks corresponds to an if that either // exits or continues the loop. There might be fixed and floating work within the loop // as well. if (loop.loop().getBlocks().size() < 3) {
< prev index next >