original) (raw)
MLIR: lib/Interfaces/Utils/InferIntRangeCommon.cpp File Reference (#include "[mlir/Interfaces/Utils/InferIntRangeCommon.h](InferIntRangeCommon%5F8h%5Fsource.html)"
#include "[mlir/Interfaces/InferIntRangeInterface.h](InferIntRangeInterface%5F8h%5Fsource.html)"
#include "[mlir/Interfaces/ShapedOpInterfaces.h](ShapedOpInterfaces%5F8h%5Fsource.html)"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Debug.h"
#include <iterator>
#include <optional>
Go to the source code of this file.
Typedefs | |
---|---|
using | ConstArithFn = function_ref< std::optional< APInt >(const APInt &, const APInt &)> |
Function that evaluates the result of doing something on arithmetic constants and returns std::nullopt on overflow. More... | |
using | ConstArithStdFn = std::function< std::optional< APInt >(const APInt &, const APInt &)> |
using | DivisionFixupFn = function_ref< std::optional< APInt >(const APInt &lhs, const APInt &rhs, const APInt &result)> |
Fix up division results (ex. More... | |
Functions | |
---|---|
static ConstantIntRanges | computeBoundsBy (ConstArithFn op, const APInt &minLeft, const APInt &minRight, const APInt &maxLeft, const APInt &maxRight, bool isSigned) |
Compute op(minLeft, minRight) and op(maxLeft, maxRight) if possible, If either computation overflows, make the result unbounded. More... | |
static ConstantIntRanges | minMaxBy (ConstArithFn op, ArrayRef< APInt > lhs, ArrayRef< APInt > rhs, bool isSigned) |
Compute the minimum and maximum of (op(l, r) for l in lhs for r in rhs), ignoring unbounded values. More... | |
static ConstantIntRanges | inferDivURange (const ConstantIntRanges &lhs, const ConstantIntRanges &rhs, DivisionFixupFn fixup) |
static ConstantIntRanges | inferDivSRange (const ConstantIntRanges &lhs, const ConstantIntRanges &rhs, DivisionFixupFn fixup) |
static std::tuple< APInt, APInt > | widenBitwiseBounds (const ConstantIntRanges &bound) |
"Widen" bounds - if 0bvvvvv??? <= a <= 0bvvvvv???, relax the bounds to 0bvvvvv000 <= a <= 0bvvvvv111, where vvvvv are the bits that both bonuds have in common. More... | |
static APInt | getVaryingBitsMask (const ConstantIntRanges &bound) |
Get bitmask of all bits which can change while iterating in [bound.umin(), bound.umax()]. More... | |
static intrange::CmpPredicate | invertPredicate (intrange::CmpPredicate pred) |
static bool | isStaticallyTrue (intrange::CmpPredicate pred, const ConstantIntRanges &lhs, const ConstantIntRanges &rhs) |
◆ DEBUG_TYPE
#define DEBUG_TYPE "int-range-analysis"
◆ ConstArithFn
Function that evaluates the result of doing something on arithmetic constants and returns std::nullopt on overflow.
Definition at line 37 of file InferIntRangeCommon.cpp.
◆ ConstArithStdFn
using ConstArithStdFn = std::function<std::optional(const APInt &, const APInt &)>
◆ DivisionFixupFn
Fix up division results (ex.
for ceiling and floor), returning an APInt if there has been no overflow
Definition at line 285 of file InferIntRangeCommon.cpp.
◆ computeBoundsBy()
static ConstantIntRanges computeBoundsBy ( ConstArithFn op, const APInt & minLeft, const APInt & minRight, const APInt & maxLeft, const APInt & maxRight, bool isSigned ) | static |
---|
◆ getVaryingBitsMask()
◆ inferDivSRange()
◆ inferDivURange()
◆ invertPredicate()
◆ isStaticallyTrue()
Definition at line 680 of file InferIntRangeCommon.cpp.
References mlir::intrange::eq, mlir::ConstantIntRanges::getConstantValue(), mlir::intrange::ne, mlir::intrange::sge, mlir::intrange::sgt, mlir::intrange::sle, mlir::intrange::slt, mlir::ConstantIntRanges::smax(), mlir::ConstantIntRanges::smin(), mlir::intrange::uge, mlir::intrange::ugt, mlir::intrange::ule, mlir::intrange::ult, mlir::ConstantIntRanges::umax(), and mlir::ConstantIntRanges::umin().
Referenced by mlir::intrange::evaluatePred().
◆ minMaxBy()
Compute the minimum and maximum of (op(l, r) for l in lhs for r in rhs)
, ignoring unbounded values.
Returns the maximal range if op
overflows.
Definition at line 57 of file InferIntRangeCommon.cpp.
References getZero(), max(), mlir::ConstantIntRanges::maxRange(), min(), and mlir::ConstantIntRanges::range().
Referenced by mlir::intrange::inferAnd(), inferDivSRange(), inferDivURange(), mlir::intrange::inferMul(), and mlir::intrange::inferOr().
◆ widenBitwiseBounds()
static std::tuple<APInt, APInt> widenBitwiseBounds ( const ConstantIntRanges & bound) | static |
---|