use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.
the class StampTool method unsignedCompare.
/**
* Compute the stamp resulting from the unsigned comparison being true.
*
* @return null if it's can't be true or it nothing useful can be encoded.
*/
public static Stamp unsignedCompare(Stamp stamp, Stamp stamp2) {
IntegerStamp x = (IntegerStamp) stamp;
IntegerStamp y = (IntegerStamp) stamp2;
if (x.isUnrestricted() && y.isUnrestricted()) {
// Don't know anything.
return null;
}
// c <| n, where c is a constant and n is known to be positive.
if (x.lowerBound() == x.upperBound()) {
if (y.isPositive()) {
if (x.lowerBound() == (1 << x.getBits()) - 1) {
// Constant is MAX_VALUE which must fail.
return null;
}
if (x.lowerBound() <= y.lowerBound()) {
// Test will fail. Return illegalStamp instead?
return null;
}
// are [c+1..-n.upperBound)].
return StampFactory.forInteger(x.getBits(), x.lowerBound() + 1, y.upperBound());
}
return null;
}
// n <| c, where c is a strictly positive constant
if (y.lowerBound() == y.upperBound() && y.isStrictlyPositive()) {
// The test proves that n is positive and less than c, [0..c-1]
return StampFactory.forInteger(y.getBits(), 0, y.lowerBound() - 1);
}
return null;
}
use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.
the class BasicInductionVariable method direction.
@Override
public Direction direction() {
Stamp stamp = rawStride.stamp(NodeView.DEFAULT);
if (stamp instanceof IntegerStamp) {
IntegerStamp integerStamp = (IntegerStamp) stamp;
Direction dir = null;
if (integerStamp.isStrictlyPositive()) {
dir = Direction.Up;
} else if (integerStamp.isStrictlyNegative()) {
dir = Direction.Down;
}
if (dir != null) {
if (op instanceof AddNode) {
return dir;
} else {
assert op instanceof SubNode;
return dir.opposite();
}
}
}
return null;
}
use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.
the class AArch64ReadNode method generate.
@Override
public void generate(NodeLIRBuilderTool gen) {
AArch64LIRGenerator lirgen = (AArch64LIRGenerator) gen.getLIRGeneratorTool();
AArch64ArithmeticLIRGenerator arithgen = (AArch64ArithmeticLIRGenerator) lirgen.getArithmetic();
AArch64Kind readKind = (AArch64Kind) lirgen.getLIRKind(accessStamp).getPlatformKind();
int resultBits = ((IntegerStamp) stamp(NodeView.DEFAULT)).getBits();
gen.setResult(this, arithgen.emitExtendMemory(isSigned, readKind, resultBits, (AArch64AddressValue) gen.operand(getAddress()), gen.state(this)));
}
use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.
the class IntegerExactFoldTest method testFoldingAfterLowering.
@Test
public void testFoldingAfterLowering() {
StructuredGraph graph = prepareGraph();
Node originalNode = graph.getNodes().filter(x -> x instanceof IntegerExactArithmeticNode).first();
assertNotNull("original node must be in the graph", originalNode);
graph.setGuardsStage(GuardsStage.FIXED_DEOPTS);
CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
PhaseContext context = new PhaseContext(getProviders());
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
IntegerExactArithmeticSplitNode loweredNode = graph.getNodes().filter(IntegerExactArithmeticSplitNode.class).first();
assertNotNull("the lowered node must be in the graph", loweredNode);
loweredNode.getX().setStamp(StampFactory.forInteger(bits, lowerBoundA, upperBoundA));
loweredNode.getY().setStamp(StampFactory.forInteger(bits, lowerBoundB, upperBoundB));
new CanonicalizerPhase().apply(graph, context);
ValueNode node = findNode(graph);
boolean overflowExpected = node instanceof IntegerExactArithmeticSplitNode;
IntegerStamp resultStamp = (IntegerStamp) node.stamp(NodeView.DEFAULT);
operation.verifyOverflow(lowerBoundA, upperBoundA, lowerBoundB, upperBoundB, bits, overflowExpected, resultStamp);
}
use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.
the class IntegerSubOverflowsTest method testOverflowCheckStamp.
@Test
public void testOverflowCheckStamp() {
IntegerStamp s1 = StampFactory.forInteger(32, Integer.MIN_VALUE, Integer.MIN_VALUE);
IntegerStamp s2 = StampFactory.forInteger(32, -1, -1);
Assert.assertFalse(IntegerStamp.subtractionCanOverflow(s1, s2));
}
Aggregations