Mercurial > hg > graal-jvmci-8
changeset 5696:f592c22421e7
Look for LoopUnswitch opportunities (LoopUnswitch currently disabled)
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Tue, 26 Jun 2012 16:54:44 +0200 |
parents | a63ed5993987 |
children | 62f1b4b8de5c |
files | graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopPolicies.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoopTransformLowPhase.java |
diffstat | 3 files changed, 30 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java Tue Jun 26 16:51:48 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java Tue Jun 26 16:54:44 2012 +0200 @@ -104,6 +104,7 @@ public static boolean ReassociateInvariants = true; public static boolean FullUnroll = true; public static int FullUnrollMaxNodes = 150; // TODO (gd) tune + public static boolean LoopUnswitch = ____; // debugging settings public static int MethodEndBreakpointGuards = 0;
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopPolicies.java Tue Jun 26 16:51:48 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopPolicies.java Tue Jun 26 16:54:44 2012 +0200 @@ -47,4 +47,9 @@ int size = Math.max(1, loop.size() - 1 - loop.loopBegin().phis().count()); return size * exactTrips <= maxNodes; } + + public static boolean shouldTryUnswitch(@SuppressWarnings("unused") LoopEx loop) { + // TODO (gd) maybe there should be a may number of unswitching per loop + return true; + } }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoopTransformLowPhase.java Tue Jun 26 16:51:48 2012 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoopTransformLowPhase.java Tue Jun 26 16:54:44 2012 +0200 @@ -25,9 +25,11 @@ import com.oracle.graal.compiler.*; import com.oracle.graal.compiler.loop.*; import com.oracle.graal.debug.*; +import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; public class LoopTransformLowPhase extends Phase { + private static final DebugMetric UNSWITCHED = Debug.metric("Unswitched"); @Override protected void run(StructuredGraph graph) { @@ -43,6 +45,28 @@ } }); } + if (GraalOptions.LoopUnswitch) { + NodeBitMap unswitchedDebug = graph.createNodeBitMap(); + boolean unswitched; + do { + unswitched = false; + final LoopsData dataUnswitch = new LoopsData(graph); + for (LoopEx loop : dataUnswitch.loops()) { + if (LoopPolicies.shouldTryUnswitch(loop)) { + IfNode ifNode = LoopTransformations.findUnswitchableIf(loop); + if (ifNode != null && !unswitchedDebug.isMarked(ifNode)) { + unswitchedDebug.mark(ifNode); + Debug.log("Unswitching %s at %s [%f - %f]", loop, ifNode, ifNode.probability(0), ifNode.probability(1)); + //LoopTransformations.unswitch(loop, ifNode); + UNSWITCHED.increment(); + //Debug.dump(graph, "After unswitch %s", loop); + unswitched = true; + break; + } + } + } + } while(unswitched); + } } } }