changeset 16004:f5ae86b125fd

LSRA optimization: skip walking to blocks with more than one predecessor.
author Josef Eisl <josef.eisl@jku.at>
date Tue, 03 Jun 2014 14:32:43 +0200
parents 83433cf49019
children dea42a47850e
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/OptimizingLinearScanWalker.java
diffstat 1 files changed, 27 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/OptimizingLinearScanWalker.java	Tue Jun 03 11:01:58 2014 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/OptimizingLinearScanWalker.java	Tue Jun 03 14:32:43 2014 +0200
@@ -74,31 +74,33 @@
     void walk() {
         try (Scope s = Debug.scope("OptimizingLinearScanWalker")) {
             for (AbstractBlock<?> block : allocator.sortedBlocks) {
-                int nextBlock = allocator.getFirstLirInstructionId(block);
-                try (Scope s1 = Debug.scope("LSRAOptimization")) {
-                    Debug.log("next block: %s (%d)", block, nextBlock);
-                }
-                try (Indent indent0 = Debug.indent()) {
-                    walkTo(nextBlock);
-
+                if (block.getPredecessorCount() == 1) {
+                    int nextBlock = allocator.getFirstLirInstructionId(block);
                     try (Scope s1 = Debug.scope("LSRAOptimization")) {
-                        boolean changed = true;
-                        // we need to do this because the active lists might change
-                        loop: while (changed) {
-                            changed = false;
-                            try (Indent indent1 = Debug.logAndIndent("Active intervals: (block %s [%d])", block, nextBlock)) {
-                                for (Interval active = activeLists.get(RegisterBinding.Any); active != Interval.EndMarker; active = active.next) {
-                                    Debug.log("active   (any): %s", active);
-                                    if (optimize(nextBlock, block, active, RegisterBinding.Any)) {
-                                        changed = true;
-                                        break loop;
+                        Debug.log("next block: %s (%d)", block, nextBlock);
+                    }
+                    try (Indent indent0 = Debug.indent()) {
+                        walkTo(nextBlock);
+
+                        try (Scope s1 = Debug.scope("LSRAOptimization")) {
+                            boolean changed = true;
+                            // we need to do this because the active lists might change
+                            loop: while (changed) {
+                                changed = false;
+                                try (Indent indent1 = Debug.logAndIndent("Active intervals: (block %s [%d])", block, nextBlock)) {
+                                    for (Interval active = activeLists.get(RegisterBinding.Any); active != Interval.EndMarker; active = active.next) {
+                                        Debug.log("active   (any): %s", active);
+                                        if (optimize(nextBlock, block, active, RegisterBinding.Any)) {
+                                            changed = true;
+                                            break loop;
+                                        }
                                     }
-                                }
-                                for (Interval active = activeLists.get(RegisterBinding.Stack); active != Interval.EndMarker; active = active.next) {
-                                    Debug.log("active (stack): %s", active);
-                                    if (optimize(nextBlock, block, active, RegisterBinding.Stack)) {
-                                        changed = true;
-                                        break loop;
+                                    for (Interval active = activeLists.get(RegisterBinding.Stack); active != Interval.EndMarker; active = active.next) {
+                                        Debug.log("active (stack): %s", active);
+                                        if (optimize(nextBlock, block, active, RegisterBinding.Stack)) {
+                                            changed = true;
+                                            break loop;
+                                        }
                                     }
                                 }
                             }
@@ -115,10 +117,8 @@
         assert currentBlock != null : "block must not be null";
         assert currentInterval != null : "interval must not be null";
 
-        if (currentBlock.getPredecessorCount() != 1) {
-            // more than one predecessors -> optimization not possible
-            return false;
-        }
+        assert currentBlock.getPredecessorCount() == 1 : "more than one predecessors -> optimization not possible";
+
         if (!currentInterval.isSplitChild()) {
             // interval is not a split child -> no need for optimization
             return false;