changeset 5404:873a1fb5b349

look at the probability of IfNodes during ComputeLinearScanOrder
author Lukas Stadler <lukas.stadler@jku.at>
date Tue, 15 May 2012 20:13:25 +0200
parents c574c4540791
children 136e9e8daf3d
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/ComputeLinearScanOrder.java
diffstat 1 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/ComputeLinearScanOrder.java	Tue May 15 14:29:14 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/ComputeLinearScanOrder.java	Tue May 15 20:13:25 2012 +0200
@@ -304,13 +304,21 @@
             Block cur = workList.remove(workList.size() - 1);
             appendBlock(cur);
 
-            int i;
-            int numSux = cur.numberOfSux();
-            // changed loop order to get "intuitive" order of if- and else-blocks
-            for (i = 0; i < numSux; i++) {
-                Block sux = cur.suxAt(i);
-                if (readyForProcessing(sux)) {
-                    sortIntoWorkList(sux);
+            // make the most successor with the highest probability the immediate successor
+            Node endNode = cur.getEndNode();
+            if (endNode instanceof IfNode && ((IfNode) endNode).probability() < 0.5) {
+                assert cur.numberOfSux() == 2;
+                if (readyForProcessing(cur.suxAt(1))) {
+                    sortIntoWorkList(cur.suxAt(1));
+                }
+                if (readyForProcessing(cur.suxAt(0))) {
+                    sortIntoWorkList(cur.suxAt(0));
+                }
+            } else {
+                for (Block sux : cur.getSuccessors()) {
+                    if (readyForProcessing(sux)) {
+                        sortIntoWorkList(sux);
+                    }
                 }
             }
         } while (workList.size() > 0);