22 #include "llvm/Support/Debug.h"
23 #include "llvm/Support/DebugLog.h"
25 #define DEBUG_TYPE "strided-metadata-range-analysis"
36 auto mTy = dyn_cast<BaseMemRefType>(v.
getType());
39 if (!mTy || !mTy.hasRank())
53 if (!ShapedType::isDynamic(offset)) {
54 metadata.getOffsets()[0] =
57 for (
auto &&[size, range] :
58 llvm::zip_equal(mTy.getShape(), metadata.getSizes())) {
59 if (ShapedType::isDynamic(size))
63 for (
auto &&[stride, range] :
64 llvm::zip_equal(strides, metadata.getStrides())) {
65 if (ShapedType::isDynamic(stride))
76 assert(indexBitwidth > 0 &&
"invalid bitwidth");
88 auto inferrable = dyn_cast<InferStridedMetadataOpInterface>(op);
96 LDBG() <<
"Inferring metadata for: "
101 auto lattice = getOrCreateFor<IntegerValueRangeLattice>(
114 auto result = cast<OpResult>(v);
115 assert(llvm::is_contained(op->
getResults(), result));
116 LDBG() <<
"- Inferred metadata: " << md;
119 LDBG() <<
"- Joined metadata: " << lattice->
getValue();
124 inferrable.inferStridedMetadataRanges(argRanges, getIntRange, joinCallback,
static LogicalResult getStridesAndOffset(AffineMap m, ArrayRef< int64_t > shape, SmallVectorImpl< AffineExpr > &strides, AffineExpr &offset)
A stride specification is a list of integer values that are either static or dynamic (encoded with Sh...
static ConstantIntRanges constant(const APInt &value)
Create a ConstantIntRanges with a constant value - that is, with the bounds [value,...
void propagateIfChanged(AnalysisState *state, ChangeResult changed)
Propagate an update to a state if it changed.
ProgramPoint * getProgramPointAfter(Operation *op)
The general data-flow analysis solver.
This lattice value represents the integer range of an SSA value.
Set of flags used to control the behavior of the various IR print methods (e.g.
A wrapper class that allows for printing an operation with a set of flags, useful to act as a "stream...
Operation is the basic unit of execution within MLIR.
result_range getResults()
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Type getType() const
Return the type of this value.
Value getAnchor() const
Return the value this lattice is located at.
ValueT & getValue()
Return the value held by this lattice.
ChangeResult join(const AbstractSparseLattice &rhs) override
Join the information contained in the 'rhs' lattice into this lattice.
A sparse forward data-flow analysis for propagating SSA value lattices across the IR by implementing ...
void setAllToEntryStates(ArrayRef< StridedMetadataRangeLattice * > lattices)
Include the generated interface declarations.
const FrozenRewritePatternSet GreedyRewriteConfig bool * changed
ChangeResult
A result type used to indicate if a change happened.