< prev index next >
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/SignedRemNode.java
Print this page
*** 70,86 ****
if (constY == 1) {
return ConstantNode.forIntegerStamp(stamp(), 0);
} else if (CodeUtil.isPowerOf2(constY)) {
if (xStamp.isPositive()) {
return new AndNode(forX, ConstantNode.forIntegerStamp(stamp(), constY - 1));
} else if (xStamp.isNegative()) {
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)));
}
}
}
return this;
}
--- 70,87 ----
if (constY == 1) {
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 {
! // x - ((x / y) << log2(y))
! return SubNode.create(forX, LeftShiftNode.create(SignedDivNode.canonical(forX, constY), ConstantNode.forInt(CodeUtil.log2(constY))));
}
}
}
return this;
}
< prev index next >