# HG changeset patch # User Bernhard Urban # Date 1367484907 -7200 # Node ID 38b07e59dcbb947ca0cf4f3cfba76948e603955e # Parent c5bdf71cb5d745ae363e77329eefd71e993c0ee4 CheckCastNode: better attempt to combine checkcasts diff -r c5bdf71cb5d7 -r 38b07e59dcbb 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:04 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/EliminateNestedCheckCastsTest.java Thu May 02 10:55:07 2013 +0200 @@ -62,7 +62,7 @@ @Test public void test2() { - compileSnippet("test2Snippet", 5, 2); + compileSnippet("test2Snippet", 5, 1); } public static long test3Snippet(A1 a1) { @@ -75,7 +75,6 @@ return result; } - @Ignore @Test public void test3() { compileSnippet("test3Snippet", 2, 2); @@ -87,6 +86,7 @@ @Override public StructuredGraph call() throws Exception { StructuredGraph graph = parse(snippet); + Debug.dump(graph, "After parsing: " + snippet); Assert.assertEquals(checkcasts, graph.getNodes().filter(CheckCastNode.class).count()); new CanonicalizerPhase.Instance(runtime(), new Assumptions(false)).apply(graph); Assert.assertEquals(afterCanon, graph.getNodes(CheckCastNode.class).count()); diff -r c5bdf71cb5d7 -r 38b07e59dcbb 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:04 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Thu May 02 10:55:07 2013 +0200 @@ -85,9 +85,9 @@ // checkcast. return object(); } - // remove checkcast if the only usage is a more specific checkcast - if (usages().count() == 1) { - CheckCastNode ccn = usages().filter(CheckCastNode.class).first(); + // 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())) { return object(); }