Mercurial > hg > graal-compiler
changeset 22782:ef56f81f88ee
Merge.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Thu, 08 Oct 2015 15:59:44 +0200 |
parents | 4c101dcc419d (diff) 4899ae79cf25 (current diff) |
children | da7d39c53b92 |
files | |
diffstat | 3 files changed, 27 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTestBase.java Thu Oct 08 14:26:52 2015 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ConditionalEliminationTestBase.java Thu Oct 08 15:59:44 2015 +0200 @@ -60,6 +60,7 @@ canonicalizer.apply(graph, context); canonicalizer.apply(graph, context); StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.YES); + new ConvertDeoptimizeToGuardPhase().apply(referenceGraph, context); if (applyConditionalEliminationOnReference) { new DominatorConditionalEliminationPhase(true).apply(referenceGraph, context); canonicalizer.apply(referenceGraph, context);
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IntegerEqualsCanonicalizerTest.java Thu Oct 08 14:26:52 2015 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/IntegerEqualsCanonicalizerTest.java Thu Oct 08 15:59:44 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,10 +33,29 @@ public class IntegerEqualsCanonicalizerTest extends GraalCompilerTest { @Test + public void testSubtractEqualsZero() { + test("testSubtractEqualsZeroSnippet", "testSubtractEqualsZeroReference"); + } + + public static int testSubtractEqualsZeroReference(int a, int b) { + if (a == b) { + return 1; + } + return 0; + } + + public static int testSubtractEqualsZeroSnippet(int a, int b) { + if (a - b == 0) { + return 1; + } + return 0; + } + + /** + * Tests the canonicalization of (x >>> const) == 0 to x |test| (-1 << const). + */ + @Test public void testShiftEquals() { - /* - * tests the canonicalization of (x >>> const) == 0 to x |test| (-1 << const) - */ test("testShiftEqualsSnippet", "testShiftEqualsReference"); }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerEqualsNode.java Thu Oct 08 14:26:52 2015 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/IntegerEqualsNode.java Thu Oct 08 15:59:44 2015 +0200 @@ -126,6 +126,9 @@ if (nonConstant instanceof AndNode) { AndNode andNode = (AndNode) nonConstant; return new IntegerTestNode(andNode.getX(), andNode.getY()); + } else if (nonConstant instanceof SubNode) { + SubNode subNode = (SubNode) nonConstant; + return IntegerEqualsNode.create(subNode.getX(), subNode.getY(), tool.getConstantReflection()); } else if (nonConstant instanceof ShiftNode && nonConstant.stamp() instanceof IntegerStamp) { if (nonConstant instanceof LeftShiftNode) { LeftShiftNode shift = (LeftShiftNode) nonConstant;