# HG changeset patch # User Tom Rodriguez # Date 1445880390 25200 # Node ID a2bf47587cc1241cc8833906c12d9004e05a0a15 # Parent afff05e25e65a0cdc9d40d3827c654bcc05d53f3 Correct guard logic to only rely on constants diff -r afff05e25e65 -r a2bf47587cc1 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java Mon Oct 26 09:14:01 2015 -0700 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java Mon Oct 26 10:26:30 2015 -0700 @@ -258,6 +258,7 @@ loopExits = oldLoopExits; }); } + // For now conservatively collect guards only within the same block. pendingTests.clear(); for (Node n : blockToNodes.apply(block)) { @@ -507,21 +508,21 @@ /* * For complex expressions involving constants, see if it's possible to fold the * tests by using stamps one level up in the expression. For instance, (x + n < y) - * might fold if something is known about x and y is a constant. + * might fold if something is known about x and all other values are constants. The + * reason for the constant restriction is that if more than 1 real value is involved + * the code might need to adopt multiple guards to have proper dependences. */ if (x instanceof BinaryArithmeticNode && y.isConstant()) { BinaryArithmeticNode binary = (BinaryArithmeticNode) x; - for (InfoElement infoElement : getInfoElements(binary.getX())) { - Stamp newStampX = binary.tryFoldStamp(infoElement.getStamp(), binary.getY().stamp()); - TriState result = binaryOpLogicNode.tryFold(newStampX, y.stamp()); - if (result.isKnown()) { - return rewireGuards(infoElement.getGuard(), result.toBoolean(), rewireGuardFunction); + if (binary.getY().isConstant()) { + for (InfoElement infoElement : getInfoElements(binary.getX())) { + Stamp newStampX = binary.tryFoldStamp(infoElement.getStamp(), binary.getY().stamp()); + TriState result = binaryOpLogicNode.tryFold(newStampX, y.stamp()); + if (result.isKnown()) { + return rewireGuards(infoElement.getGuard(), result.toBoolean(), rewireGuardFunction); + } } } - /* - * In all the interesting cases binary.getY() seems to be a constant so it's - * doesn't seem worth checking that case here.s - */ } } else if (node instanceof ShortCircuitOrNode) { final ShortCircuitOrNode shortCircuitOrNode = (ShortCircuitOrNode) node;