MLIR 22.0.0git
mlir::intrange Namespace Reference

Namespaces

namespace  detail

Typedefs

using InferRangeFn
 Function that performs inference on an array of ConstantIntRanges, abstracted away here to permit writing the function that handles both 64- and 32-bit index types.
using InferIntegerValueRangeFn
 Function that performs inferrence on an array of IntegerValueRange.
using InferRangeWithOvfFlagsFn
 Function that performs inference on an array of ConstantIntRanges while taking special overflow behavior into account.

Enumerations

enum class  CmpMode : uint32_t { Both , Signed , Unsigned }
enum class  OverflowFlags : uint32_t { None = 0 , Nsw = 1 , Nuw = 2 }
enum class  CmpPredicate : uint64_t {
  eq , ne , slt , sle ,
  sgt , sge , ult , ule ,
  ugt , uge
}
 Copy of the enum from arith and index to allow the common integer range infrastructure to not depend on either dialect. More...

Functions

ConstantIntRanges inferIndexOp (const InferRangeFn &inferFn, ArrayRef< ConstantIntRanges > argRanges, CmpMode mode)
 Compute inferFn on ranges, whose size should be the index storage bitwidth.
ConstantIntRanges extRange (const ConstantIntRanges &range, unsigned destWidth)
 Independently zero-extend the unsigned values and sign-extend the signed values in range to destWidth bits, returning the resulting range.
ConstantIntRanges extUIRange (const ConstantIntRanges &range, unsigned destWidth)
 Use the unsigned values in range to zero-extend it to destWidth.
ConstantIntRanges extSIRange (const ConstantIntRanges &range, unsigned destWidth)
 Use the signed values in range to sign-extend it to destWidth.
ConstantIntRanges truncRange (const ConstantIntRanges &range, unsigned destWidth)
 Truncate range to destWidth bits, taking care to handle cases such as the truncation of [255, 256] to i8 not being a uniform range.
ConstantIntRanges inferAdd (ArrayRef< ConstantIntRanges > argRanges, OverflowFlags ovfFlags=OverflowFlags::None)
ConstantIntRanges inferSub (ArrayRef< ConstantIntRanges > argRanges, OverflowFlags ovfFlags=OverflowFlags::None)
ConstantIntRanges inferMul (ArrayRef< ConstantIntRanges > argRanges, OverflowFlags ovfFlags=OverflowFlags::None)
ConstantIntRanges inferDivS (ArrayRef< ConstantIntRanges > argRanges)
ConstantIntRanges inferDivU (ArrayRef< ConstantIntRanges > argRanges)
ConstantIntRanges inferCeilDivS (ArrayRef< ConstantIntRanges > argRanges)
ConstantIntRanges inferCeilDivU (ArrayRef< ConstantIntRanges > argRanges)
ConstantIntRanges inferFloorDivS (ArrayRef< ConstantIntRanges > argRanges)
ConstantIntRanges inferRemS (ArrayRef< ConstantIntRanges > argRanges)
ConstantIntRanges inferRemU (ArrayRef< ConstantIntRanges > argRanges)
ConstantIntRanges inferMaxS (ArrayRef< ConstantIntRanges > argRanges)
ConstantIntRanges inferMaxU (ArrayRef< ConstantIntRanges > argRanges)
ConstantIntRanges inferMinS (ArrayRef< ConstantIntRanges > argRanges)
ConstantIntRanges inferMinU (ArrayRef< ConstantIntRanges > argRanges)
ConstantIntRanges inferAnd (ArrayRef< ConstantIntRanges > argRanges)
ConstantIntRanges inferOr (ArrayRef< ConstantIntRanges > argRanges)
ConstantIntRanges inferXor (ArrayRef< ConstantIntRanges > argRanges)
ConstantIntRanges inferShl (ArrayRef< ConstantIntRanges > argRanges, OverflowFlags ovfFlags=OverflowFlags::None)
ConstantIntRanges inferShrS (ArrayRef< ConstantIntRanges > argRanges)
ConstantIntRanges inferShrU (ArrayRef< ConstantIntRanges > argRanges)
std::optional< boolevaluatePred (CmpPredicate pred, const ConstantIntRanges &lhs, const ConstantIntRanges &rhs)
 Returns a boolean value if pred is statically true or false for anypossible inputs falling within lhs and rhs, and std::nullopt if the value of the predicate cannot be determined.
ConstantIntRanges inferShapedDimOpInterface (ShapedDimOpInterface op, const IntegerValueRange &maybeDim)
 Returns the integer range for the result of a ShapedDimOpInterface given the optional inferred ranges for the dimension index maybeDim.

Variables

static constexpr unsigned indexMinWidth = 32
static constexpr unsigned indexMaxWidth = 64

Typedef Documentation

◆ InferIntegerValueRangeFn

Initial value:
This lattice value represents the integer range of an SSA value.

Function that performs inferrence on an array of IntegerValueRange.

Definition at line 33 of file InferIntRangeCommon.h.

◆ InferRangeFn

Initial value:
A set of arbitrary-precision integers representing bounds on a given integer value.

Function that performs inference on an array of ConstantIntRanges, abstracted away here to permit writing the function that handles both 64- and 32-bit index types.

Definition at line 29 of file InferIntRangeCommon.h.

◆ InferRangeWithOvfFlagsFn

Initial value:

Function that performs inference on an array of ConstantIntRanges while taking special overflow behavior into account.

Definition at line 50 of file InferIntRangeCommon.h.

Enumeration Type Documentation

◆ CmpMode

enum class mlir::intrange::CmpMode : uint32_t
strong
Enumerator
Both 
Signed 
Unsigned 

Definition at line 39 of file InferIntRangeCommon.h.

◆ CmpPredicate

enum class mlir::intrange::CmpPredicate : uint64_t
strong

Copy of the enum from arith and index to allow the common integer range infrastructure to not depend on either dialect.

Enumerator
eq 
ne 
slt 
sle 
sgt 
sge 
ult 
ule 
ugt 
uge 

Definition at line 128 of file InferIntRangeCommon.h.

◆ OverflowFlags

enum class mlir::intrange::OverflowFlags : uint32_t
strong
Enumerator
None 
Nsw 
Nuw 

Definition at line 41 of file InferIntRangeCommon.h.

Function Documentation

◆ evaluatePred()

std::optional< bool > mlir::intrange::evaluatePred ( CmpPredicate pred,
const ConstantIntRanges & lhs,
const ConstantIntRanges & rhs )

Returns a boolean value if pred is statically true or false for anypossible inputs falling within lhs and rhs, and std::nullopt if the value of the predicate cannot be determined.

Definition at line 719 of file InferIntRangeCommon.cpp.

References invertPredicate(), isStaticallyTrue(), lhs, and rhs.

Referenced by foldCmpOfMaxOrMin().

◆ extRange()

ConstantIntRanges mlir::intrange::extRange ( const ConstantIntRanges & range,
unsigned destWidth )

Independently zero-extend the unsigned values and sign-extend the signed values in range to destWidth bits, returning the resulting range.

Referenced by inferIndexCast(), and inferIndexOp().

◆ extSIRange()

ConstantIntRanges mlir::intrange::extSIRange ( const ConstantIntRanges & range,
unsigned destWidth )

Use the signed values in range to sign-extend it to destWidth.

Definition at line 136 of file InferIntRangeCommon.cpp.

References mlir::ConstantIntRanges::fromSigned(), mlir::ConstantIntRanges::smax(), and mlir::ConstantIntRanges::smin().

Referenced by makeLikeDest().

◆ extUIRange()

ConstantIntRanges mlir::intrange::extUIRange ( const ConstantIntRanges & range,
unsigned destWidth )

Use the unsigned values in range to zero-extend it to destWidth.

Definition at line 129 of file InferIntRangeCommon.cpp.

References mlir::ConstantIntRanges::fromUnsigned(), mlir::ConstantIntRanges::umax(), and mlir::ConstantIntRanges::umin().

Referenced by makeLikeDest().

◆ inferAdd()

ConstantIntRanges mlir::intrange::inferAdd ( ArrayRef< ConstantIntRanges > argRanges,
OverflowFlags ovfFlags = OverflowFlags::None )

◆ inferAnd()

ConstantIntRanges mlir::intrange::inferAnd ( ArrayRef< ConstantIntRanges > argRanges)

Definition at line 546 of file InferIntRangeCommon.cpp.

References b, minMaxBy(), and widenBitwiseBounds().

◆ inferCeilDivS()

ConstantIntRanges mlir::intrange::inferCeilDivS ( ArrayRef< ConstantIntRanges > argRanges)

◆ inferCeilDivU()

ConstantIntRanges mlir::intrange::inferCeilDivU ( ArrayRef< ConstantIntRanges > argRanges)

Definition at line 319 of file InferIntRangeCommon.cpp.

References inferDivURange(), lhs, result, and rhs.

◆ inferDivS()

ConstantIntRanges mlir::intrange::inferDivS ( ArrayRef< ConstantIntRanges > argRanges)

Definition at line 360 of file InferIntRangeCommon.cpp.

References inferDivSRange(), lhs, result, and rhs.

◆ inferDivU()

ConstantIntRanges mlir::intrange::inferDivU ( ArrayRef< ConstantIntRanges > argRanges)

Definition at line 312 of file InferIntRangeCommon.cpp.

References inferDivURange(), lhs, result, and rhs.

◆ inferFloorDivS()

ConstantIntRanges mlir::intrange::inferFloorDivS ( ArrayRef< ConstantIntRanges > argRanges)

Definition at line 401 of file InferIntRangeCommon.cpp.

References inferDivSRange(), lhs, result, and rhs.

◆ inferIndexOp()

ConstantIntRanges mlir::intrange::inferIndexOp ( const InferRangeFn & inferFn,
ArrayRef< ConstantIntRanges > argRanges,
intrange::CmpMode mode )

Compute inferFn on ranges, whose size should be the index storage bitwidth.

Then, compute the function on argRanges again after truncating the ranges to 32 bits. Finally, if the truncation of the 64-bit result is equal to the 32-bit result, use it (to preserve compatibility with folders and inference precision), and take the union of the results otherwise.

The mode argument specifies if the unsigned, signed, or both results of the inference computation should be used when comparing the results.

Definition at line 82 of file InferIntRangeCommon.cpp.

References Both, extRange(), indexMaxWidth, indexMinWidth, mlir::ConstantIntRanges::rangeUnion(), Signed, mlir::ConstantIntRanges::smax(), mlir::ConstantIntRanges::smin(), truncRange(), mlir::ConstantIntRanges::umax(), mlir::ConstantIntRanges::umin(), and Unsigned.

◆ inferMaxS()

ConstantIntRanges mlir::intrange::inferMaxS ( ArrayRef< ConstantIntRanges > argRanges)

Definition at line 492 of file InferIntRangeCommon.cpp.

References mlir::ConstantIntRanges::fromSigned(), lhs, and rhs.

◆ inferMaxU()

ConstantIntRanges mlir::intrange::inferMaxU ( ArrayRef< ConstantIntRanges > argRanges)

Definition at line 501 of file InferIntRangeCommon.cpp.

References mlir::ConstantIntRanges::fromUnsigned(), lhs, and rhs.

◆ inferMinS()

ConstantIntRanges mlir::intrange::inferMinS ( ArrayRef< ConstantIntRanges > argRanges)

Definition at line 510 of file InferIntRangeCommon.cpp.

References mlir::ConstantIntRanges::fromSigned(), lhs, and rhs.

◆ inferMinU()

ConstantIntRanges mlir::intrange::inferMinU ( ArrayRef< ConstantIntRanges > argRanges)

Definition at line 519 of file InferIntRangeCommon.cpp.

References mlir::ConstantIntRanges::fromUnsigned(), lhs, and rhs.

◆ inferMul()

ConstantIntRanges mlir::intrange::inferMul ( ArrayRef< ConstantIntRanges > argRanges,
OverflowFlags ovfFlags = OverflowFlags::None )

◆ inferOr()

ConstantIntRanges mlir::intrange::inferOr ( ArrayRef< ConstantIntRanges > argRanges)

Definition at line 557 of file InferIntRangeCommon.cpp.

References b, minMaxBy(), and widenBitwiseBounds().

◆ inferRemS()

ConstantIntRanges mlir::intrange::inferRemS ( ArrayRef< ConstantIntRanges > argRanges)

Definition at line 422 of file InferIntRangeCommon.cpp.

References mlir::ConstantIntRanges::fromSigned(), lhs, rhs, and ult.

◆ inferRemU()

ConstantIntRanges mlir::intrange::inferRemU ( ArrayRef< ConstantIntRanges > argRanges)

Definition at line 461 of file InferIntRangeCommon.cpp.

References mlir::ConstantIntRanges::fromUnsigned(), lhs, rhs, and ult.

◆ inferShapedDimOpInterface()

ConstantIntRanges mlir::intrange::inferShapedDimOpInterface ( ShapedDimOpInterface op,
const IntegerValueRange & maybeDim )

Returns the integer range for the result of a ShapedDimOpInterface given the optional inferred ranges for the dimension index maybeDim.

When a dynamic dimension is encountered, returns [0, signed_max(type(result))].

Definition at line 734 of file InferIntRangeCommon.cpp.

References mlir::ConstantIntRanges::constant(), mlir::ConstantIntRanges::fromSigned(), mlir::ConstantIntRanges::getStorageBitwidth(), mlir::IntegerValueRange::getValue(), mlir::IntegerValueRange::isUninitialized(), result, mlir::ConstantIntRanges::smax(), and mlir::ConstantIntRanges::smin().

◆ inferShl()

ConstantIntRanges mlir::intrange::inferShl ( ArrayRef< ConstantIntRanges > argRanges,
OverflowFlags ovfFlags = OverflowFlags::None )

◆ inferShrS()

ConstantIntRanges mlir::intrange::inferShrS ( ArrayRef< ConstantIntRanges > argRanges)

Definition at line 627 of file InferIntRangeCommon.cpp.

References lhs, minMaxBy(), and rhs.

◆ inferShrU()

ConstantIntRanges mlir::intrange::inferShrU ( ArrayRef< ConstantIntRanges > argRanges)

Definition at line 639 of file InferIntRangeCommon.cpp.

References lhs, minMaxBy(), and rhs.

◆ inferSub()

ConstantIntRanges mlir::intrange::inferSub ( ArrayRef< ConstantIntRanges > argRanges,
OverflowFlags ovfFlags = OverflowFlags::None )

◆ inferXor()

ConstantIntRanges mlir::intrange::inferXor ( ArrayRef< ConstantIntRanges > argRanges)

◆ truncRange()

ConstantIntRanges mlir::intrange::truncRange ( const ConstantIntRanges & range,
unsigned destWidth )

Truncate range to destWidth bits, taking care to handle cases such as the truncation of [255, 256] to i8 not being a uniform range.

References None.

Referenced by inferIndexOp(), and makeLikeDest().

Variable Documentation

◆ indexMaxWidth

unsigned mlir::intrange::indexMaxWidth = 64
staticconstexpr

Definition at line 37 of file InferIntRangeCommon.h.

Referenced by inferIndexOp().

◆ indexMinWidth

unsigned mlir::intrange::indexMinWidth = 32
staticconstexpr

Definition at line 36 of file InferIntRangeCommon.h.

Referenced by inferIndexCast(), and inferIndexOp().