--- old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/SignedRemNode.java 2017-11-03 23:57:11.876585074 -0700 +++ new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/SignedRemNode.java 2017-11-03 23:57:11.549570441 -0700 @@ -72,13 +72,14 @@ return ConstantNode.forIntegerStamp(stamp(), 0); } else if (CodeUtil.isPowerOf2(constY)) { if (xStamp.isPositive()) { + // x & (y - 1) return new AndNode(forX, ConstantNode.forIntegerStamp(stamp(), constY - 1)); } else if (xStamp.isNegative()) { + // -((-x) & (y - 1)) return new NegateNode(new AndNode(new NegateNode(forX), ConstantNode.forIntegerStamp(stamp(), constY - 1))); } else { - return new ConditionalNode(IntegerLessThanNode.create(forX, ConstantNode.forIntegerStamp(forX.stamp(), 0)), - new NegateNode(new AndNode(new NegateNode(forX), ConstantNode.forIntegerStamp(stamp(), constY - 1))), - new AndNode(forX, ConstantNode.forIntegerStamp(stamp(), constY - 1))); + // x - ((x / y) << log2(y)) + return SubNode.create(forX, LeftShiftNode.create(SignedDivNode.canonical(forX, constY), ConstantNode.forInt(CodeUtil.log2(constY)))); } } }