Mercurial > hg > graal-jvmci-8
changeset 21010:84ff24bc9604
Fixed unsigned compare construction when merging distinct values
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Fri, 17 Apr 2015 14:12:32 -0700 |
parents | 0fe8b02e5cb6 |
children | f6369bd988c7 |
files | graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IfCanonicalizerTest.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java |
diffstat | 2 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IfCanonicalizerTest.java Fri Apr 17 22:15:24 2015 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IfCanonicalizerTest.java Fri Apr 17 14:12:32 2015 -0700 @@ -179,6 +179,17 @@ return v - 1; } + @Test + public void test9() { + testCombinedIf("test9Snippet", 2); + test("test9Snippet", -1); + test("test9Snippet", 1025); + } + + public static int test9Snippet(int n) { + return (n < 0) ? 1 : (n >= 1024) ? 1024 : n + 1; + } + private void testCombinedIf(String snippet, int count) { StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES); PhaseContext context = new PhaseContext(getProviders());
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Fri Apr 17 22:15:24 2015 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/IfNode.java Fri Apr 17 14:12:32 2015 -0700 @@ -340,7 +340,12 @@ EndNode end1 = (EndNode) next1; EndNode end2 = (EndNode) next2; if (end1.merge() == end2.merge()) { - // They go to the same MergeNode + for (PhiNode phi : end1.merge().phis()) { + if (phi.valueAt(end1) != phi.valueAt(end2)) { + return false; + } + } + // They go to the same MergeNode and merge the same values return true; } } else if (next1 instanceof DeoptimizeNode && next2 instanceof DeoptimizeNode) {