# HG changeset patch # User Bernhard Urban # Date 1367484911 -7200 # Node ID 82b2a2c652bb7c8694e6cb1a4a97a61769e6676a # Parent 38b07e59dcbb947ca0cf4f3cfba76948e603955e CheckCastNode: check if input of next CheckCastNode is the node itself diff -r 38b07e59dcbb -r 82b2a2c652bb graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EliminateNestedCheckCastsTest.java --- 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() { diff -r 38b07e59dcbb -r 82b2a2c652bb graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java --- 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(); } }