changeset 9494:82b2a2c652bb

CheckCastNode: check if input of next CheckCastNode is the node itself
author Bernhard Urban <bernhard.urban@jku.at>
date Thu, 02 May 2013 10:55:11 +0200
parents 38b07e59dcbb
children 6ad0bdcd76aa 9384ec90632b
files graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EliminateNestedCheckCastsTest.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java
diffstat 2 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EliminateNestedCheckCastsTest.java	Thu May 02 10:55:07 2013 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EliminateNestedCheckCastsTest.java	Thu May 02 10:55:11 2013 +0200
@@ -80,6 +80,17 @@
         compileSnippet("test3Snippet", 2, 2);
     }
 
+    public static long test4Snippet(A1 a1, A1 b1) {
+        A2 a2 = (A2) a1;
+        A3 b3 = (A3) b1;
+        return a2.x2 + b3.x3;
+    }
+
+    @Test
+    public void test4() {
+        compileSnippet("test4Snippet", 2, 2);
+    }
+
     private StructuredGraph compileSnippet(final String snippet, final int checkcasts, final int afterCanon) {
         return Debug.scope(snippet, new Callable<StructuredGraph>() {
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java	Thu May 02 10:55:07 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java	Thu May 02 10:55:11 2013 +0200
@@ -88,7 +88,7 @@
         // remove checkcast if next node is a more specific checkcast
         if (next() instanceof CheckCastNode) {
             CheckCastNode ccn = (CheckCastNode) next();
-            if (ccn != null && ccn.type() != null && type.isAssignableFrom(ccn.type())) {
+            if (ccn != null && ccn.type() != null && this == ccn.object() && type.isAssignableFrom(ccn.type())) {
                 return object();
             }
         }