changeset 7370:39a4192ae632

Experiment with new block order for LSRA.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Mon, 14 Jan 2013 16:52:44 +0100
parents 4c6e577d0c01
children d3c6fe53e631
files graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java
diffstat 2 files changed, 21 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java	Mon Jan 14 14:19:49 2013 +0100
+++ b/graal/com.oracle.graal.alloc/src/com/oracle/graal/alloc/ComputeBlockOrder.java	Mon Jan 14 16:52:44 2013 +0100
@@ -76,24 +76,27 @@
         countEdges(startBlock, null);
         computeOrder(startBlock);
 
+        List<Block> newLinearScanOrder = new ArrayList<>();
         List<Block> order = new ArrayList<>();
         PriorityQueue<Block> worklist = new PriorityQueue<>(10, blockComparator);
         BitSet orderedBlocks = new BitSet(maxBlockId);
         orderedBlocks.set(startBlock.getId());
         worklist.add(startBlock);
-        computeCodeEmittingOrder(order, worklist, orderedBlocks);
+        computeCodeEmittingOrder(order, newLinearScanOrder, worklist, orderedBlocks);
         assert codeEmittingOrder.size() == order.size();
         codeEmittingOrder = order;
+
+        linearScanOrder = newLinearScanOrder;
     }
 
-    private void computeCodeEmittingOrder(List<Block> order, PriorityQueue<Block> worklist, BitSet orderedBlocks) {
+    private void computeCodeEmittingOrder(List<Block> order, List<Block> newLinearScanOrder, PriorityQueue<Block> worklist, BitSet orderedBlocks) {
         while (!worklist.isEmpty()) {
             Block nextImportantPath = worklist.poll();
-            addImportantPath(nextImportantPath, order, worklist, orderedBlocks);
+            addImportantPath(nextImportantPath, order, newLinearScanOrder, worklist, orderedBlocks);
         }
     }
 
-    private void addImportantPath(Block block, List<Block> order, PriorityQueue<Block> worklist, BitSet orderedBlocks) {
+    private void addImportantPath(Block block, List<Block> order, List<Block> newLinearScanOrder, PriorityQueue<Block> worklist, BitSet orderedBlocks) {
         if (!skipLoopHeader(block)) {
             if (block.isLoopHeader()) {
                 block.align = true;
@@ -108,6 +111,7 @@
                 }
             }
         }
+        newLinearScanOrder.add(block);
         Block bestSucc = null;
         double bestSuccProb = 0;
 
@@ -133,7 +137,7 @@
 
         if (bestSucc != null) {
             orderedBlocks.set(bestSucc.getId());
-            addImportantPath(bestSucc, order, worklist, orderedBlocks);
+            addImportantPath(bestSucc, order, newLinearScanOrder, worklist, orderedBlocks);
         }
     }
 
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Mon Jan 14 14:19:49 2013 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Mon Jan 14 16:52:44 2013 +0100
@@ -241,11 +241,22 @@
 
             public void run() {
                 for (Block b : lir.linearScanOrder()) {
-                    lirGenerator.doBlock(b);
+                    emitBlock(b);
                 }
 
                 Debug.dump(lir, "After LIR generation");
             }
+
+            private void emitBlock(Block b) {
+                if (lir.lir(b) == null) {
+                    for (Block pred : b.getPredecessors()) {
+                        if (!b.isLoopHeader() || !pred.isLoopEnd()) {
+                            emitBlock(pred);
+                        }
+                    }
+                    lirGenerator.doBlock(b);
+                }
+            }
         });
 
         Debug.scope("Allocator", new Runnable() {