">

MLIR: lib/Analysis/FlatLinearValueConstraints.cpp File Reference (original) (raw)

#include "[mlir/Analysis//FlatLinearValueConstraints.h](FlatLinearValueConstraints%5F8h%5Fsource.html)"
#include "[mlir/Analysis/Presburger/LinearTransform.h](LinearTransform%5F8h%5Fsource.html)"
#include "[mlir/Analysis/Presburger/PresburgerSpace.h](PresburgerSpace%5F8h%5Fsource.html)"
#include "[mlir/Analysis/Presburger/Simplex.h](Simplex%5F8h%5Fsource.html)"
#include "[mlir/Analysis/Presburger/Utils.h](Analysis%5F2Presburger%5F2Utils%5F8h%5Fsource.html)"
#include "[mlir/IR/AffineExprVisitor.h](AffineExprVisitor%5F8h%5Fsource.html)"
#include "[mlir/IR/Builders.h](Builders%5F8h%5Fsource.html)"
#include "[mlir/IR/IntegerSet.h](mlir%5F2IR%5F2IntegerSet%5F8h%5Fsource.html)"
#include "[mlir/Support/LLVM.h](mlir%5F2Support%5F2LLVM%5F8h%5Fsource.html)"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/InterleavedRange.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>

Go to the source code of this file.

Macros
#define DEBUG_TYPE "flat-value-constraints"
Functions
static LogicalResult getFlattenedAffineExprs (ArrayRef< AffineExpr > exprs, unsigned numDims, unsigned numSymbols, std::vector< SmallVector< int64_t, 8 >> *flattenedExprs, FlatLinearConstraints *localVarCst, bool addConservativeSemiAffineBounds=false)
static bool detectAsMod (const FlatLinearConstraints &cst, unsigned pos, unsigned offset, unsigned num, int64_t lbConst, int64_t ubConst, MLIRContext *context, SmallVectorImpl< AffineExpr > &memo)
static bool detectAsFloorDiv (const FlatLinearConstraints &cst, unsigned pos, MLIRContext *context, SmallVectorImpl< AffineExpr > &exprs)
Check if the pos^th variable can be expressed as a floordiv of an affine function of other variables (where the divisor is a positive constant) given the initial set of expressions in exprs. More...
static bool detectAsExpr (const FlatLinearConstraints &cst, unsigned pos, unsigned idx, MLIRContext *context, SmallVectorImpl< AffineExpr > &exprs)
Express the pos^th identifier of cst as an affine expression in terms of other identifiers, if they are available in exprs, using the equality at position idx in cst. More...
static void computeUnknownVars (const FlatLinearConstraints &cst, MLIRContext *context, unsigned offset, unsigned num, SmallVectorImpl< AffineExpr > &memo)
Compute a representation of num identifiers starting at offset in cst as affine expressions involving other known identifiers. More...
static std::optional< AffineExpr > getAsExpr (const FlatLinearConstraints &cst, unsigned pos, MLIRContext *context, ArrayRef< AffineExpr > exprs, unsigned idx, bool isEquality)
Given an equality or inequality (isEquality used to disambiguate) of cst at idx, traverse and sum up AffineExprs of all known ids other than the posth. More...
static bool areVarsAligned (const FlatLinearValueConstraints &a, const FlatLinearValueConstraints &b)
Checks if two constraint systems are in the same space, i.e., if they are associated with the same set of variables, appearing in the same order. More...
static bool LLVM_ATTRIBUTE_UNUSED areVarsUnique (const FlatLinearValueConstraints &cst, unsigned start, unsigned end)
Checks if the SSA values associated with cst's variables in range [start, end) are unique. More...
static bool LLVM_ATTRIBUTE_UNUSED areVarsUnique (const FlatLinearValueConstraints &cst)
Checks if the SSA values associated with cst's variables are unique. More...
static bool LLVM_ATTRIBUTE_UNUSED areVarsUnique (const FlatLinearValueConstraints &cst, VarKind kind)
Checks if the SSA values associated with cst's variables of kind kind are unique. More...
static void mergeAndAlignVars (unsigned offset, FlatLinearValueConstraints *a, FlatLinearValueConstraints *b)
Merge and align the variables of A and B starting at 'offset', so that both constraint systems get the union of the contained variables that is dimension-wise and symbol-wise unique; both constraint systems are updated so that they have the union of all variables, with A's original variables appearing first followed by any of B's variables that didn't appear in A. More...

DEBUG_TYPE

#define DEBUG_TYPE "flat-value-constraints"

areVarsAligned()

areVarsUnique() [1/3]

areVarsUnique() [2/3]

areVarsUnique() [3/3]

computeUnknownVars()

Compute a representation of num identifiers starting at offset in cst as affine expressions involving other known identifiers.

Each identifier's expression (in terms of known identifiers) is populated into memo.

Definition at line 631 of file FlatLinearValueConstraints.cpp.

References mlir::changed, detectAsExpr(), detectAsFloorDiv(), detectAsMod(), mlir::presburger::IntegerRelation::findConstraintWithNonZeroAt(), mlir::getAffineConstantExpr(), mlir::getAffineDimExpr(), mlir::getAffineSymbolExpr(), mlir::presburger::IntegerRelation::getConstantBound64(), mlir::presburger::IntegerRelation::getNumDimAndSymbolVars(), mlir::presburger::IntegerRelation::getNumDimVars(), mlir::presburger::IntegerRelation::getNumVars(), mlir::presburger::LB, and mlir::presburger::UB.

Referenced by mlir::FlatLinearConstraints::getSliceBounds().

detectAsExpr()

detectAsFloorDiv()

detectAsMod()

getAsExpr()

getFlattenedAffineExprs()

static LogicalResult getFlattenedAffineExprs ( ArrayRef< AffineExpr > exprs, unsigned numDims, unsigned numSymbols, std::vector< SmallVector< int64_t, 8 >> * flattenedExprs, FlatLinearConstraints * localVarCst, bool addConservativeSemiAffineBounds = false ) static

mergeAndAlignVars()

Merge and align the variables of A and B starting at 'offset', so that both constraint systems get the union of the contained variables that is dimension-wise and symbol-wise unique; both constraint systems are updated so that they have the union of all variables, with A's original variables appearing first followed by any of B's variables that didn't appear in A.

Local variables in B that have the same division representation as local variables in A are merged into one. We allow A and B to have non-unique values for their variables; in such cases, they are still aligned with the variables appearing first aligned with those appearing first in the other system from left to right.

Definition at line 1302 of file FlatLinearValueConstraints.cpp.

References mlir::FlatLinearValueConstraints::appendDimVar(), areVarsAligned(), mlir::FlatLinearValueConstraints::findVar(), mlir::FlatLinearValueConstraints::getMaybeValues(), mlir::presburger::IntegerRelation::getNumDimVars(), mlir::FlatLinearValueConstraints::getValue(), mlir::FlatLinearValueConstraints::getValues(), mlir::FlatLinearValueConstraints::insertDimVar(), mlir::presburger::IntegerRelation::mergeLocalVars(), mlir::FlatLinearValueConstraints::mergeSymbolVars(), and mlir::presburger::IntegerRelation::swapVar().

Referenced by mlir::FlatLinearValueConstraints::mergeAndAlignVarsWithOther(), and mlir::FlatLinearValueConstraints::unionBoundingBox().