changeset 3015:02a3d70f6fc0

Fixed bug where a ControlSplit with only one successor (e.g. degenerated switch) would cause infinite loops.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Sat, 18 Jun 2011 11:33:58 +0200
parents 681a227c332b
children 2f5f6ffbafa0
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java
diffstat 2 files changed, 16 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java	Fri Jun 17 17:30:35 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/DeadCodeEliminationPhase.java	Sat Jun 18 11:33:58 2011 +0200
@@ -54,20 +54,20 @@
             }
         }
         // remove if nodes with constant-value comparison
-        for (If ifNode : graph.getNodes(If.class)) {
-            Compare compare = ifNode.compare();
-            if (compare.x().isConstant() && compare.y().isConstant()) {
-                CiConstant constX = compare.x().asConstant();
-                CiConstant constY = compare.y().asConstant();
-                Boolean result = compare.condition().foldCondition(constX, constY, GraalCompilation.compilation().runtime);
-                if (result != null) {
-                    Node actualSuccessor = result ? ifNode.trueSuccessor() : ifNode.falseSuccessor();
-                    ifNode.replace(actualSuccessor);
-                } else {
-                    TTY.println("if not removed %s %s %s (%s %s)", constX, compare.condition(), constY, constX.kind, constY.kind);
-                }
-            }
-        }
+//        for (If ifNode : graph.getNodes(If.class)) {
+//            Compare compare = ifNode.compare();
+//            if (compare.x().isConstant() && compare.y().isConstant()) {
+//                CiConstant constX = compare.x().asConstant();
+//                CiConstant constY = compare.y().asConstant();
+//                Boolean result = compare.condition().foldCondition(constX, constY, GraalCompilation.compilation().runtime);
+//                if (result != null) {
+//                    Node actualSuccessor = result ? ifNode.trueSuccessor() : ifNode.falseSuccessor();
+//                    ifNode.replace(actualSuccessor);
+//                } else {
+//                    TTY.println("if not removed %s %s %s (%s %s)", constX, compare.condition(), constY, constX.kind, constY.kind);
+//                }
+//            }
+//        }
 
         flood.add(graph.start());
 
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java	Fri Jun 17 17:30:35 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/schedule/IdentifyBlocksPhase.java	Sat Jun 18 11:33:58 2011 +0200
@@ -102,7 +102,7 @@
                     Block block = null;
                     Node currentNode = n;
                     while (nodeToBlock.get(currentNode) == null) {
-                        if (block != null && IdentifyBlocksPhase.trueSuccessorCount(currentNode) > 1) {
+                        if (block != null && (currentNode instanceof ControlSplit || trueSuccessorCount(currentNode) > 1)) {
                             // We are at a split node => start a new block.
                             block = null;
                         }
@@ -372,6 +372,7 @@
         visited.set(dominatorRoot.blockID());
         LinkedList<Block> workList = new LinkedList<Block>();
         workList.add(dominatorRoot);
+        // TODO: Add all predecessor.size()==0 nodes.
 
         while (!workList.isEmpty()) {
             Block b = workList.remove();