12 #include "mlir/Interfaces/InferIntRangeInterface.cpp.inc"
17 return umin().getBitWidth() == other.
umin().getBitWidth() &&
32 return IndexType::kInternalStorageBitWidth;
33 if (
auto integerType = dyn_cast<IntegerType>(type))
34 return integerType.getWidth();
44 return {value, value, value, value};
56 unsigned int width =
smin.getBitWidth();
58 if (
smin.isNonNegative() ==
smax.isNonNegative()) {
62 umin = APInt::getMinValue(width);
63 umax = APInt::getMaxValue(width);
70 unsigned int width =
umin.getBitWidth();
72 if (
umin.isNonNegative() ==
umax.isNonNegative()) {
76 smin = APInt::getSignedMinValue(width);
77 smax = APInt::getSignedMaxValue(width);
88 if (other.
umin().getBitWidth() == 0)
96 return {uminUnion, umaxUnion, sminUnion, smaxUnion};
105 if (other.
umin().getBitWidth() == 0)
108 const APInt &uminIntersect =
umin().ugt(other.
umin()) ?
umin() : other.
umin();
109 const APInt &umaxIntersect =
umax().ult(other.
umax()) ?
umax() : other.
umax();
110 const APInt &sminIntersect =
smin().sgt(other.
smin()) ?
smin() : other.
smin();
111 const APInt &smaxIntersect =
smax().slt(other.
smax()) ?
smax() : other.
smax();
113 return {uminIntersect, umaxIntersect, sminIntersect, smaxIntersect};
126 return os <<
"unsigned : [" << range.
umin() <<
", " << range.
umax()
127 <<
"] signed : [" << range.
smin() <<
", " << range.
smax() <<
"]";
static Value getZero(OpBuilder &b, Location loc, Type elementType)
Get zero value for an element type.
static Value max(ImplicitLocOpBuilder &builder, Value value, Value bound)
static Value min(ImplicitLocOpBuilder &builder, Value value, Value bound)
static unsigned getBitWidth(Type type)
Returns the bit width of integer, float or vector of float or integer values.
A set of arbitrary-precision integers representing bounds on a given integer value.
static ConstantIntRanges maxRange(unsigned bitwidth)
Create a ConstantIntRanges with the maximum bounds for the width bitwidth, that is - [0,...
const APInt & smax() const
The maximum value of an integer when it is interpreted as signed.
static ConstantIntRanges constant(const APInt &value)
Create a ConstantIntRanges with a constant value - that is, with the bounds [value,...
static ConstantIntRanges fromUnsigned(const APInt &umin, const APInt &umax)
Create an ConstantIntRanges with the unsigned minimum and maximum equal to umin and umax and the sign...
const APInt & smin() const
The minimum value of an integer when it is interpreted as signed.
static ConstantIntRanges range(const APInt &min, const APInt &max, bool isSigned)
Create a ConstantIntRanges whose minimum is min and maximum is max with isSigned specifying if the mi...
ConstantIntRanges intersection(const ConstantIntRanges &other) const
Returns the intersection (computed separately for signed and unsigned bounds) of this range and other...
static ConstantIntRanges fromSigned(const APInt &smin, const APInt &smax)
Create an ConstantIntRanges with the signed minimum and maximum equal to smin and smax,...
static unsigned getStorageBitwidth(Type type)
Return the bitwidth that should be used for integer ranges describing type.
std::optional< APInt > getConstantValue() const
If either the signed or unsigned interpretations of the range indicate that the value it bounds is a ...
const APInt & umax() const
The maximum value of an integer when it is interpreted as unsigned.
const APInt & umin() const
The minimum value of an integer when it is interpreted as unsigned.
ConstantIntRanges rangeUnion(const ConstantIntRanges &other) const
Returns the union (computed separately for signed and unsigned bounds) of this range and other.
bool operator==(const ConstantIntRanges &other) const
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This header declares functions that assist transformations in the MemRef dialect.
raw_ostream & operator<<(raw_ostream &os, const AliasResult &result)