use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.
the class IntegerSubOverflowsTest method testOverflowCheckStamp09.
@Test
public void testOverflowCheckStamp09() {
IntegerStamp s1 = StampFactory.forInteger(64, Long.MAX_VALUE, Long.MAX_VALUE);
IntegerStamp s2 = StampFactory.forInteger(64, Long.MAX_VALUE, Long.MAX_VALUE);
Assert.assertFalse(IntegerStamp.subtractionCanOverflow(s1, s2));
}
use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.
the class AArch64ReadNode method replace.
/**
* replace a ReadNode with an AArch64-specific variant which knows how to merge a downstream
* zero or sign extend into the read operation.
*
* @param readNode
*/
public static void replace(ReadNode readNode) {
assert readNode.getUsageCount() == 1;
assert readNode.getUsageAt(0) instanceof ZeroExtendNode || readNode.getUsageAt(0) instanceof SignExtendNode;
ValueNode usage = (ValueNode) readNode.getUsageAt(0);
boolean isSigned = usage instanceof SignExtendNode;
IntegerStamp accessStamp = ((IntegerStamp) readNode.getAccessStamp());
AddressNode address = readNode.getAddress();
LocationIdentity location = readNode.getLocationIdentity();
Stamp stamp = usage.stamp(NodeView.DEFAULT);
GuardingNode guard = readNode.getGuard();
BarrierType barrierType = readNode.getBarrierType();
boolean nullCheck = readNode.getNullCheck();
FrameState stateBefore = readNode.stateBefore();
AArch64ReadNode clone = new AArch64ReadNode(address, location, stamp, guard, barrierType, nullCheck, stateBefore, accessStamp, isSigned);
StructuredGraph graph = readNode.graph();
graph.add(clone);
// splice out the extend node
usage.replaceAtUsagesAndDelete(readNode);
// swap the clone for the read
graph.replaceFixedWithFixed(readNode, clone);
}
use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.
the class PrimitiveStampBoundaryTest method testShiftBoundaryValues.
private static void testShiftBoundaryValues(ShiftOp<?> shiftOp, HashSet<PrimitiveStamp> stamps, HashSet<IntegerStamp> shifts) {
for (PrimitiveStamp testStamp : stamps) {
if (testStamp instanceof IntegerStamp) {
IntegerStamp stamp = (IntegerStamp) testStamp;
for (IntegerStamp shiftStamp : shifts) {
IntegerStamp foldedStamp = (IntegerStamp) shiftOp.foldStamp(stamp, shiftStamp);
if (foldedStamp.isEmpty()) {
assertTrue(stamp.isEmpty() || shiftStamp.isEmpty());
continue;
}
checkShiftOperation(stamp.getBits(), shiftOp, foldedStamp, stamp.lowerBound(), shiftStamp.lowerBound());
checkShiftOperation(stamp.getBits(), shiftOp, foldedStamp, stamp.lowerBound(), shiftStamp.upperBound());
checkShiftOperation(stamp.getBits(), shiftOp, foldedStamp, stamp.upperBound(), shiftStamp.lowerBound());
checkShiftOperation(stamp.getBits(), shiftOp, foldedStamp, stamp.upperBound(), shiftStamp.upperBound());
}
}
}
}
use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.
the class PrimitiveStampBoundaryTest method checkShiftOperation.
private static void checkShiftOperation(int bits, ShiftOp<?> op, IntegerStamp result, long v1, long v2) {
IntegerStamp v1stamp = IntegerStamp.create(bits, v1, v1);
IntegerStamp v2stamp = IntegerStamp.create(32, v2, v2);
IntegerStamp folded = (IntegerStamp) op.foldStamp(v1stamp, v2stamp);
Constant constant = op.foldConstant(JavaConstant.forPrimitiveInt(bits, v1), (int) v2);
assertTrue(constant != null);
assertTrue(folded.asConstant() != null, "should constant fold %s %s %s %s", op, v1stamp, v2stamp, folded);
assertTrue(result.meet(folded).equals(result), "result out of range %s %s %s %s %s %s", op, v1stamp, v2stamp, folded, result, result.meet(folded));
}
use of org.graalvm.compiler.core.common.type.IntegerStamp in project graal by oracle.
the class PrimitiveStampBoundaryTest method boundaryStamp.
private static Stamp boundaryStamp(Stamp v1, boolean upper) {
if (v1.isEmpty()) {
return v1;
}
if (v1 instanceof IntegerStamp) {
IntegerStamp istamp = (IntegerStamp) v1;
long bound = upper ? istamp.upperBound() : istamp.lowerBound();
return IntegerStamp.create(istamp.getBits(), bound, bound);
} else if (v1 instanceof FloatStamp) {
FloatStamp floatStamp = (FloatStamp) v1;
double bound = upper ? floatStamp.upperBound() : floatStamp.lowerBound();
int bits = floatStamp.getBits();
return floatStampForConstant(bound, bits);
} else {
throw new InternalError("unexpected stamp type " + v1);
}
}
Aggregations