# HG changeset patch # User Gilles Duboscq # Date 1311180559 -7200 # Node ID 8793d44991fdaec67be1947eab18616462216265 # Parent 7610d0b83fd12af88c1c17338c6ab17b4a18ef10 Added Verify option to be able to diable graph verification, ideal graph printing now also print string value for colors, removed redundant DCE/Canon phases diff -r 7610d0b83fd1 -r 8793d44991fd ProblemsIdeas.txt --- a/ProblemsIdeas.txt Tue Jul 19 13:48:43 2011 +0200 +++ b/ProblemsIdeas.txt Wed Jul 20 18:49:19 2011 +0200 @@ -31,6 +31,7 @@ } Here invoke 1 and 2 should always be inlined regardless of the size of the inlined graph/method size and without increasing the inlining depth + specializations should always be inlined if we are in a trivial method, not only he methods with only one invoke, we shoudl also do it for exemple for methods that invoke and only do simple operations on paramteres or result * 'computable' slots in Framstates/debug info @@ -49,3 +50,29 @@ This requires going through the compiler and asking for further profiling there are 2 main options here : - Reprofile the method in interpreter with the new profiled expression (we may modify the method bytecode to insert a conditional branch on the expression we want to profile, thus using the classical branch probability infrastructure) - insert a profiling snippet in the compiled code and ask runtime to recompile the method after N executions + + +* Transform some contiguous array accesses into phis when possible + Example : (most probably found in scientific code, for example relaxation code) + + for (int i = 1; i < A.length - 1; i++) { + vm1 = A[i-1]; + v0 = A[i]; + vp1 = A[i+1]; + // ... + } + + should be transformed into + vm1 = A[0]; + v0 = A[1]; + for (int i = 0; i < A.length - 1; i++) { + vp1 = A[i+1]; + // ... + vm1 = v0; + v0 = vp1; + } + + This could be done in the context of a more advanced induction varaible analysis to be able to detect such access patterns. In this example we removed 2 array access (2 loads + 2 address computation + 2 bounds checks if not hoisted) while only adding 2 moves (phis) + + +* Implement array bounds check elimination diff -r 7610d0b83fd1 -r 8793d44991fd graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java Tue Jul 19 13:48:43 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java Wed Jul 20 18:49:19 2011 +0200 @@ -73,7 +73,7 @@ public static boolean StressLinearScan = ____; public static boolean BailoutOnException = ____; public static boolean DeoptALot = ____; - + public static boolean Verify = true; public static boolean TestGraphDuplication = ____; /** diff -r 7610d0b83fd1 -r 8793d44991fd graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java Tue Jul 19 13:48:43 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java Wed Jul 20 18:49:19 2011 +0200 @@ -168,6 +168,7 @@ } Map>> colors = new HashMap>>(); + Map>> colorsToString = new HashMap>>(); Map> bits = new HashMap>(); if (debugObjects != null) { for (Entry entry : debugObjects.entrySet()) { @@ -191,6 +192,12 @@ colors.put(node, nodeColors); } nodeColors.add(new SimpleImmutableEntry(name + "Color", colorNumber)); + Set> nodeColorStrings = colorsToString.get(node); + if (nodeColorStrings == null) { + nodeColorStrings = new HashSet>(); + colorsToString.put(node, nodeColorStrings); + } + nodeColorStrings.add(new SimpleImmutableEntry(name, color.toString())); } } else if (obj instanceof NodeBitMap) { NodeBitMap bitmap = (NodeBitMap) obj; @@ -261,6 +268,14 @@ stream.printf("

%d

%n", name, value); } } + Set> nodeColorStrings = colorsToString.get(node); + if (nodeColorStrings != null) { + for (Entry color : nodeColorStrings) { + String name = color.getKey(); + String value = color.getValue(); + stream.printf("

%s

%n", name, value); + } + } Set nodeBits = bits.get(node); if (nodeBits != null) { for (String bit : nodeBits) { diff -r 7610d0b83fd1 -r 8793d44991fd graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/CompilerGraph.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/CompilerGraph.java Tue Jul 19 13:48:43 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/CompilerGraph.java Wed Jul 20 18:49:19 2011 +0200 @@ -35,7 +35,6 @@ private Unwind unwindSingleton; private CiAssumptions assumptions = new CiAssumptions(); - public CompilerGraph(RiRuntime runtime) { this.runtime = runtime; } diff -r 7610d0b83fd1 -r 8793d44991fd graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java Tue Jul 19 13:48:43 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java Wed Jul 20 18:49:19 2011 +0200 @@ -85,23 +85,22 @@ new GraphBuilderPhase(compilation, compilation.method, false).apply(compilation.graph); // } + Graph graph = compilation.graph; + if (GraalOptions.TestGraphDuplication) { - new DuplicationPhase().apply(compilation.graph); + new DuplicationPhase().apply(graph); } - new DeadCodeEliminationPhase().apply(compilation.graph); + new DeadCodeEliminationPhase().apply(graph); if (GraalOptions.ProbabilityAnalysis) { - new ComputeProbabilityPhase().apply(compilation.graph); + new ComputeProbabilityPhase().apply(graph); } if (GraalOptions.Inline) { - new InliningPhase(compilation, this, null).apply(compilation.graph); - new CanonicalizerPhase().apply(compilation.graph); - new DeadCodeEliminationPhase().apply(compilation.graph); + new InliningPhase(compilation, this, null).apply(graph); } - Graph graph = compilation.graph; if (GraalOptions.OptCanonicalizer) { new CanonicalizerPhase().apply(graph); @@ -130,6 +129,7 @@ if (GraalOptions.OptGVN) { new GlobalValueNumberingPhase().apply(graph); if (GraalOptions.Rematerialize) { + //new Rematerialization2Phase().apply(graph); new RematerializationPhase().apply(graph); } } diff -r 7610d0b83fd1 -r 8793d44991fd graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Phi.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Phi.java Tue Jul 19 13:48:43 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Phi.java Wed Jul 20 18:49:19 2011 +0200 @@ -170,7 +170,6 @@ return new Iterable() { @Override public Iterator iterator() { - // TODO Auto-generated method stub return new FilteringIterator(input, Merge.class); } }; diff -r 7610d0b83fd1 -r 8793d44991fd graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java Tue Jul 19 13:48:43 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java Wed Jul 20 18:49:19 2011 +0200 @@ -36,7 +36,7 @@ protected Phase() { this.name = this.getClass().getSimpleName(); - this.shouldVerify = true; + this.shouldVerify = GraalOptions.Verify; this.detailedName = name; } diff -r 7610d0b83fd1 -r 8793d44991fd graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/RematerializationPhase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/RematerializationPhase.java Tue Jul 19 13:48:43 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/RematerializationPhase.java Wed Jul 20 18:49:19 2011 +0200 @@ -101,7 +101,7 @@ Node copy = node.copyWithEdges(); newNodesToBlock.put(copy, sux); GraalMetrics.Rematerializations++; - //System.out.println("Rematerialized " + node + " : " + toString(usageProbability)); + //System.out.println("> Rematerialized " + node + " : " + toString(usageProbability)); for (Node usage : usages) { usage.inputs().replace(node, copy); }