Mercurial > hg > graal-compiler
changeset 9493:38b07e59dcbb
CheckCastNode: better attempt to combine checkcasts
author | Bernhard Urban <bernhard.urban@jku.at> |
---|---|
date | Thu, 02 May 2013 10:55:07 +0200 |
parents | c5bdf71cb5d7 |
children | 82b2a2c652bb |
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, 5 insertions(+), 5 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: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());
--- 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(); }