changeset 3227:8793d44991fd

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
author Gilles Duboscq <gilles.duboscq@oracle.com>
date Wed, 20 Jul 2011 18:49:19 +0200
parents 7610d0b83fd1
children b95c8fa99e8c
files ProblemsIdeas.txt graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/CompilerGraph.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/ir/Phi.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/RematerializationPhase.java
diffstat 8 files changed, 52 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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               = ____;
 
     /**
--- 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<Node, Set<Entry<String, Integer>>> colors = new HashMap<Node, Set<Entry<String, Integer>>>();
+        Map<Node, Set<Entry<String, String>>> colorsToString = new HashMap<Node, Set<Entry<String, String>>>();
         Map<Node, Set<String>> bits = new HashMap<Node, Set<String>>();
         if (debugObjects != null) {
             for (Entry<String, Object> entry : debugObjects.entrySet()) {
@@ -191,6 +192,12 @@
                             colors.put(node, nodeColors);
                         }
                         nodeColors.add(new SimpleImmutableEntry<String, Integer>(name + "Color", colorNumber));
+                        Set<Entry<String, String>> nodeColorStrings = colorsToString.get(node);
+                        if (nodeColorStrings == null) {
+                            nodeColorStrings = new HashSet<Entry<String, String>>();
+                            colorsToString.put(node, nodeColorStrings);
+                        }
+                        nodeColorStrings.add(new SimpleImmutableEntry<String, String>(name, color.toString()));
                     }
                 } else if (obj instanceof NodeBitMap) {
                     NodeBitMap bitmap = (NodeBitMap) obj;
@@ -261,6 +268,14 @@
                     stream.printf("    <p name='%s'>%d</p>%n", name, value);
                 }
             }
+            Set<Entry<String, String>> nodeColorStrings = colorsToString.get(node);
+            if (nodeColorStrings != null) {
+                for (Entry<String, String> color : nodeColorStrings) {
+                    String name = color.getKey();
+                    String value = color.getValue();
+                    stream.printf("    <p name='%s'>%s</p>%n", name, value);
+                }
+            }
             Set<String> nodeBits = bits.get(node);
             if (nodeBits != null) {
                 for (String bit : nodeBits) {
--- 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;
     }
--- 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);
             }
         }
--- 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<Node>() {
             @Override
             public Iterator<Node> iterator() {
-                // TODO Auto-generated method stub
                 return new FilteringIterator(input, Merge.class);
             }
         };
--- 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;
     }
 
--- 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);
                         }