changeset 12688:76a6070f7164

LIRGenerator: don't create end-of-block JumpOps for blocks that end in a FallThroughOp with a target
author Lukas Stadler <lukas.stadler@jku.at>
date Wed, 06 Nov 2013 11:04:01 +0100
parents 43301f080126
children 697ef4cf18c0
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/EdgeMoveOptimizer.java
diffstat 2 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Tue Nov 05 20:03:42 2013 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Wed Nov 06 11:04:01 2013 +0100
@@ -39,6 +39,7 @@
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.StandardOp.FallThroughOp;
 import com.oracle.graal.lir.StandardOp.JumpOp;
 import com.oracle.graal.lir.StandardOp.LabelOp;
 import com.oracle.graal.nodes.*;
@@ -426,7 +427,12 @@
             return false;
         }
         LIRInstruction lirInstruction = instructions.get(instructions.size() - 1);
-        return lirInstruction instanceof StandardOp.JumpOp;
+        if (lirInstruction instanceof StandardOp.JumpOp) {
+            return true;
+        } else if (lirInstruction instanceof FallThroughOp) {
+            return ((FallThroughOp) lirInstruction).fallThroughTarget() != null;
+        }
+        return false;
     }
 
     private void doRoot(ValueNode instr) {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/EdgeMoveOptimizer.java	Tue Nov 05 20:03:42 2013 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/EdgeMoveOptimizer.java	Wed Nov 06 11:04:01 2013 +0100
@@ -24,7 +24,7 @@
 
 import java.util.*;
 
-import com.oracle.graal.lir.StandardOp.*;
+import com.oracle.graal.lir.StandardOp.MoveOp;
 import com.oracle.graal.nodes.cfg.*;
 
 /**
@@ -182,9 +182,16 @@
 
         assert numSux == 2 : "method should not be called otherwise";
 
-        assert instructions.get(instructions.size() - 1) instanceof StandardOp.JumpOp : "block must end with unconditional jump";
+        LIRInstruction lastInstruction = instructions.get(instructions.size() - 1);
+        if (lastInstruction instanceof StandardOp.FallThroughOp) {
+            assert ((StandardOp.FallThroughOp) lastInstruction).fallThroughTarget() != null : "block must end with unconditional jump";
+            // fall through ops like switches cannot be optimized anyway - they have input operands
+            return;
+        } else {
+            assert lastInstruction instanceof StandardOp.JumpOp : "block must end with unconditional jump";
+        }
 
-        if (instructions.get(instructions.size() - 1).hasState()) {
+        if (lastInstruction.hasState()) {
             // cannot optimize instructions when debug info is needed
             return;
         }