MLIR 22.0.0git
LoopUtils.cpp File Reference
#include "mlir/Dialect/Affine/LoopUtils.h"
#include "mlir/Analysis/SliceAnalysis.h"
#include "mlir/Dialect/Affine/Analysis/LoopAnalysis.h"
#include "mlir/Dialect/Affine/Analysis/Utils.h"
#include "mlir/Dialect/Affine/IR/AffineValueMap.h"
#include "mlir/Dialect/Affine/Utils.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/IntegerSet.h"
#include "mlir/IR/OperationSupport.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/DebugLog.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>

Go to the source code of this file.

Classes

struct  StrideInfo

Macros

#define DEBUG_TYPE   "loop-utils"

Functions

static void getCleanupLoopLowerBound (AffineForOp forOp, unsigned unrollFactor, AffineMap &cleanupLbMap, SmallVectorImpl< Value > &cleanupLbOperands)
 Computes the cleanup loop lower bound of the loop being unrolled with the specified unroll factor; this bound will also be upper bound of the main part of the unrolled loop.
static void replaceIterArgsAndYieldResults (AffineForOp forOp)
 Helper to replace uses of loop carried values (iter_args) and loop yield values while promoting single iteration affine.for ops.
static AffineForOp generateShiftedLoop (AffineMap lbMap, AffineMap ubMap, const std::vector< std::pair< uint64_t, ArrayRef< Operation * > > > &opGroupQueue, unsigned offset, AffineForOp srcForOp, OpBuilder b)
 Generates an affine.for op with the specified lower and upper bounds while generating the right IV remappings to realize shifts for operations in its body.
static LogicalResult checkIfHyperRectangular (MutableArrayRef< AffineForOp > input)
 Checks whether a loop nest is hyper-rectangular or not.
template<typename t>
static LogicalResult performPreTilingChecks (MutableArrayRef< AffineForOp > input, ArrayRef< t > tileSizes)
 Check if the input nest is supported for tiling and whether tiling would be legal or not.
static void moveLoopBodyImpl (AffineForOp src, AffineForOp dest, Block::iterator loc)
 Move the loop body of AffineForOp 'src' from 'src' into the specified location in destination's body, ignoring the terminator.
static void moveLoopBody (AffineForOp src, AffineForOp dest)
 Move the loop body of AffineForOp 'src' from 'src' to the start of dest body.
static void constructTiledLoopNest (MutableArrayRef< AffineForOp > origLoops, AffineForOp rootAffineForOp, unsigned width, MutableArrayRef< AffineForOp > tiledLoops)
 Constructs tiled loop nest, without setting the loop bounds and move the body of the original loop nest to the tiled loop nest.
static void setIntraTileBoundsParametric (OpBuilder &b, AffineForOp origLoop, AffineForOp newInterTileLoop, AffineForOp newIntraTileLoop, Value tileSize)
 Set lower and upper bounds of intra-tile loops for parametric tiling.
static void setInterTileBoundsParametric (OpBuilder &b, AffineForOp origLoop, AffineForOp newLoop, Value tileSize)
 Set lower and upper bounds of inter-tile loops for parametric tiling.
static void constructParametricallyTiledIndexSetHyperRect (MutableArrayRef< AffineForOp > origLoops, MutableArrayRef< AffineForOp > newLoops, ArrayRef< Value > tileSizes)
 Constructs and sets new loop bounds after tiling for the case of hyper-rectangular index sets, where the bounds of one dimension do not depend on other dimensions and tiling parameters are captured from SSA values.
static void constructTiledIndexSetHyperRect (MutableArrayRef< AffineForOp > origLoops, MutableArrayRef< AffineForOp > newLoops, ArrayRef< unsigned > tileSizes)
 Constructs and sets new loop bounds after tiling for the case of hyper-rectangular index sets, where the bounds of one dimension do not depend on other dimensions.
static void generateUnrolledLoop (Block *loopBodyBlock, Value forOpIV, uint64_t unrollFactor, function_ref< Value(unsigned, Value, OpBuilder)> ivRemapFn, function_ref< void(unsigned, Operation *, OpBuilder)> annotateFn, ValueRange iterArgs, ValueRange yieldedValues)
 Generates unrolled copies of AffineForOp 'loopBodyBlock', with associated 'forOpIV' by 'unrollFactor', calling 'ivRemapFn' to remap 'forOpIV' for each unrolled body.
static LogicalResult generateCleanupLoopForUnroll (AffineForOp forOp, uint64_t unrollFactor)
 Helper to generate cleanup loop for unroll or unroll-and-jam when the trip count is not a multiple of unrollFactor.
static bool areInnerBoundsInvariant (AffineForOp forOp)
 Check if all control operands of all loops are defined outside of forOp and return false if not.
static bool checkLoopInterchangeDependences (const std::vector< SmallVector< DependenceComponent, 2 > > &depCompsVec, ArrayRef< AffineForOp > loops, ArrayRef< unsigned > loopPermMap)
static void augmentMapAndBounds (OpBuilder &b, Value iv, AffineMap *map, SmallVector< Value, 4 > *operands, int64_t offset=0)
static SmallVector< AffineForOp, 8 > stripmineSink (AffineForOp forOp, uint64_t factor, ArrayRef< AffineForOp > targets)
template<typename SizeType>
static AffineForOp stripmineSink (AffineForOp forOp, SizeType factor, AffineForOp target)
static void findHighestBlockForPlacement (const MemRefRegion &region, Block &block, Block::iterator &begin, Block::iterator &end, Block **copyPlacementBlock, Block::iterator *copyInPlacementStart, Block::iterator *copyOutPlacementStart)
 Given a memref region, determine the lowest depth at which transfers can be placed for it, and return the corresponding block, start and end positions in the block for placing incoming (read) and outgoing (write) copies respectively.
static void getMultiLevelStrides (const MemRefRegion &region, ArrayRef< int64_t > bufferShape, SmallVectorImpl< StrideInfo > *strideInfos)
 Returns striding information for a copy/transfer of this region with potentially multiple striding levels from outermost to innermost.
b getContext ())
 for (auto applyOp :mayBeDeadApplys) if(applyOp.use_empty()) applyOp.erase()
 if (!isCopyOut)
static InFlightDiagnostic emitRemarkForBlock (Block &block)
*if copies could not be generated due to yet unimplemented cases *copyInPlacementStart and copyOutPlacementStart in copyPlacementBlock *specify the insertion points where the incoming copies and outgoing should be inserted (the insertion happens right before the *insertion point). Since `begin` can itself be invalidated due to the memref *rewriting done from this method
*if copies could not be generated due to yet unimplemented cases *copyInPlacementStart and copyOutPlacementStart in copyPlacementBlock *specify the insertion points where the incoming copies and outgoing should be the output argument nBegin is set to its * replacement (set to `begin` if no invalidation happens). Since outgoing *copies could have been inserted at `end`
*if copies could not be generated due to yet unimplemented cases *copyInPlacementStart and copyOutPlacementStart in copyPlacementBlock *specify the insertion points where the incoming copies and outgoing should be the output argument nBegin is set to its the output argument nEnd is set *to the new end sizeInBytes is set to the size of the fast buffer *allocated *static LogicalResult generateCopy (const MemRefRegion &region, Block *block, Block::iterator begin, Block::iterator end, Block *copyPlacementBlock, Block::iterator copyInPlacementStart, Block::iterator copyOutPlacementStart, const AffineCopyOptions &copyOptions, DenseMap< Value, Value > &fastBufferMap, DenseSet< Operation * > &copyNests, uint64_t *sizeInBytes, Block::iterator *nBegin, Block::iterator *nEnd)
static bool getFullMemRefAsRegion (Operation *op, unsigned numParamLoopIVs, MemRefRegion *region)
 Construct the memref region to just include the entire memref.
static void gatherLoopsInBlock (Block *block, unsigned currLoopDepth, std::vector< SmallVector< AffineForOp, 2 > > &depthToLoops)
 Gathers all AffineForOps in 'block' at 'currLoopDepth' in 'depthToLoops'.
static AffineIfOp createSeparationCondition (MutableArrayRef< AffineForOp > loops, OpBuilder b)
 Creates an AffineIfOp that encodes the conditional to choose between the constant trip count version and an unknown trip count version of this nest of loops.
static LogicalResult createFullTiles (MutableArrayRef< AffineForOp > inputNest, SmallVectorImpl< AffineForOp > &fullTileLoops, OpBuilder b)
 Create the full tile loop nest (along with its body).

Variables

 fastBufExprs
fullyComposeAffineMapAndOperands & fastBufMap = simplifyAffineMap(fastBufMap)
auto load
return copyNestRoot
*if copies could not be generated due to yet unimplemented cases *copyInPlacementStart and copyOutPlacementStart in copyPlacementBlock *specify the insertion points where the incoming copies and outgoing copies
 Creates a buffer in the faster memory space for the specified memref region (memref has to be non-zero ranked); generates a copy from the lower memory space to this one, and replaces all loads/stores in the block range [‘begin’, ‘end’) of ‘block’ to load/store from that buffer. Returns failure.
*if copies could not be generated due to yet unimplemented cases *copyInPlacementStart and copyOutPlacementStart in copyPlacementBlock *specify the insertion points where the incoming copies and outgoing * respectively

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "loop-utils"

Definition at line 32 of file LoopUtils.cpp.

Function Documentation

◆ areInnerBoundsInvariant()

bool areInnerBoundsInvariant ( AffineForOp forOp)
static

Check if all control operands of all loops are defined outside of forOp and return false if not.

Definition at line 1072 of file LoopUtils.cpp.

References mlir::WalkResult::advance(), and mlir::WalkResult::interrupt().

Referenced by mlir::affine::loopUnrollJamByFactor().

◆ augmentMapAndBounds()

void augmentMapAndBounds ( OpBuilder & b,
Value iv,
AffineMap * map,
SmallVector< Value, 4 > * operands,
int64_t offset = 0 )
static

◆ checkIfHyperRectangular()

LogicalResult checkIfHyperRectangular ( MutableArrayRef< AffineForOp > input)
static

Checks whether a loop nest is hyper-rectangular or not.

Definition at line 363 of file LoopUtils.cpp.

References mlir::affine::getIndexSet(), mlir::presburger::IntegerRelation::isHyperRectangular(), and success().

Referenced by performPreTilingChecks().

◆ checkLoopInterchangeDependences()

bool checkLoopInterchangeDependences ( const std::vector< SmallVector< DependenceComponent, 2 > > & depCompsVec,
ArrayRef< AffineForOp > loops,
ArrayRef< unsigned > loopPermMap )
static

◆ constructParametricallyTiledIndexSetHyperRect()

void constructParametricallyTiledIndexSetHyperRect ( MutableArrayRef< AffineForOp > origLoops,
MutableArrayRef< AffineForOp > newLoops,
ArrayRef< Value > tileSizes )
static

Constructs and sets new loop bounds after tiling for the case of hyper-rectangular index sets, where the bounds of one dimension do not depend on other dimensions and tiling parameters are captured from SSA values.

Bounds of each dimension can thus be treated independently, and deriving the new bounds is much simpler and faster than for the case of tiling arbitrary polyhedral shapes.

Definition at line 660 of file LoopUtils.cpp.

References b, setInterTileBoundsParametric(), and setIntraTileBoundsParametric().

Referenced by mlir::affine::tilePerfectlyNestedParametric().

◆ constructTiledIndexSetHyperRect()

void constructTiledIndexSetHyperRect ( MutableArrayRef< AffineForOp > origLoops,
MutableArrayRef< AffineForOp > newLoops,
ArrayRef< unsigned > tileSizes )
static

Constructs and sets new loop bounds after tiling for the case of hyper-rectangular index sets, where the bounds of one dimension do not depend on other dimensions.

Bounds of each dimension can thus be treated independently, and deriving the new bounds is much simpler and faster than for the case of tiling arbitrary polyhedral shapes.

Definition at line 688 of file LoopUtils.cpp.

References b, mlir::AffineMap::get(), mlir::affine::getConstantTripCount(), mlir::affine::getLargestDivisorOfTripCount(), mlir::AffineMap::getNumDims(), mlir::AffineMap::getNumResults(), mlir::AffineMap::getNumSymbols(), and mlir::AffineMap::getResults().

Referenced by mlir::affine::tilePerfectlyNested().

◆ constructTiledLoopNest()

void constructTiledLoopNest ( MutableArrayRef< AffineForOp > origLoops,
AffineForOp rootAffineForOp,
unsigned width,
MutableArrayRef< AffineForOp > tiledLoops )
static

Constructs tiled loop nest, without setting the loop bounds and move the body of the original loop nest to the tiled loop nest.

Definition at line 423 of file LoopUtils.cpp.

References b, mlir::Operation::getBlock(), mlir::Block::getOperations(), and moveLoopBody().

Referenced by mlir::affine::tilePerfectlyNested(), and mlir::affine::tilePerfectlyNestedParametric().

◆ createFullTiles()

◆ createSeparationCondition()

◆ emitRemarkForBlock()

InFlightDiagnostic emitRemarkForBlock ( Block & block)
static

Definition at line 1923 of file LoopUtils.cpp.

References mlir::Operation::emitRemark(), and mlir::Block::getParentOp().

Referenced by generateCopy().

◆ findHighestBlockForPlacement()

void findHighestBlockForPlacement ( const MemRefRegion & region,
Block & block,
Block::iterator & begin,
Block::iterator & end,
Block ** copyPlacementBlock,
Block::iterator * copyInPlacementStart,
Block::iterator * copyOutPlacementStart )
static

Given a memref region, determine the lowest depth at which transfers can be placed for it, and return the corresponding block, start and end positions in the block for placing incoming (read) and outgoing (write) copies respectively.

The lowest depth depends on whether the region being accessed is hoistable with respect to one or more immediately surrounding loops.

Definition at line 1758 of file LoopUtils.cpp.

References mlir::Block::begin(), mlir::affine::MemRefRegion::getConstraints(), mlir::affine::getEnclosingAffineOps(), mlir::Operation::getParentRegion(), and mlir::affine::MemRefRegion::memref.

◆ for()

for ( auto applyOp :mayBeDeadApplys )

◆ gatherLoopsInBlock()

void gatherLoopsInBlock ( Block * block,
unsigned currLoopDepth,
std::vector< SmallVector< AffineForOp, 2 > > & depthToLoops )
static

Gathers all AffineForOps in 'block' at 'currLoopDepth' in 'depthToLoops'.

Definition at line 2528 of file LoopUtils.cpp.

References gatherLoopsInBlock().

Referenced by gatherLoopsInBlock().

◆ generateCleanupLoopForUnroll()

LogicalResult generateCleanupLoopForUnroll ( AffineForOp forOp,
uint64_t unrollFactor )
static

Helper to generate cleanup loop for unroll or unroll-and-jam when the trip count is not a multiple of unrollFactor.

Definition at line 960 of file LoopUtils.cpp.

References mlir::OpBuilder::clone(), getCleanupLoopLowerBound(), mlir::affine::promoteIfSingleIteration(), and success().

Referenced by mlir::affine::loopUnrollByFactor(), and mlir::affine::loopUnrollJamByFactor().

◆ generateCopy()

*if copies could not be generated due to yet unimplemented cases *copyInPlacementStart and copyOutPlacementStart in copyPlacementBlock *specify the insertion points where the incoming copies and outgoing should be the output argument nBegin is set to its the output argument nEnd is set *to the new end sizeInBytes is set to the size of the fast buffer *allocated *static LogicalResult generateCopy ( const MemRefRegion & region,
Block * block,
Block::iterator begin,
Block::iterator end,
Block * copyPlacementBlock,
Block::iterator copyInPlacementStart,
Block::iterator copyOutPlacementStart,
const AffineCopyOptions & copyOptions,
DenseMap< Value, Value > & fastBufferMap,
DenseSet< Operation * > & copyNests,
uint64_t * sizeInBytes,
Block::iterator * nBegin,
Block::iterator * nEnd )
static

◆ generateShiftedLoop()

AffineForOp generateShiftedLoop ( AffineMap lbMap,
AffineMap ubMap,
const std::vector< std::pair< uint64_t, ArrayRef< Operation * > > > & opGroupQueue,
unsigned offset,
AffineForOp srcForOp,
OpBuilder b )
static

Generates an affine.for op with the specified lower and upper bounds while generating the right IV remappings to realize shifts for operations in its body.

The operations that go into the loop body are specified in opGroupQueue starting from the specified offset, and in that order. The first element of the pair specifies the shift applied to that group of operations; the shift is multiplied by the loop step before being applied. Returns nullptr if the generated loop simplifies to a single iteration one.

Definition at line 175 of file LoopUtils.cpp.

References mlir::OpBuilder::atBlockTerminator(), b, mlir::AffineMap::getNumInputs(), mlir::IRMapping::map(), and mlir::affine::promoteIfSingleIteration().

Referenced by mlir::affine::affineForOpBodySkew().

◆ generateUnrolledLoop()

void generateUnrolledLoop ( Block * loopBodyBlock,
Value forOpIV,
uint64_t unrollFactor,
function_ref< Value(unsigned, Value, OpBuilder)> ivRemapFn,
function_ref< void(unsigned, Operation *, OpBuilder)> annotateFn,
ValueRange iterArgs,
ValueRange yieldedValues )
static

Generates unrolled copies of AffineForOp 'loopBodyBlock', with associated 'forOpIV' by 'unrollFactor', calling 'ivRemapFn' to remap 'forOpIV' for each unrolled body.

If specified, annotates the Ops in each unrolled iteration using annotateFn.

Definition at line 899 of file LoopUtils.cpp.

References mlir::OpBuilder::atBlockTerminator(), mlir::Block::begin(), mlir::Operation::clone(), mlir::Block::end(), mlir::Operation::getBlock(), mlir::Block::getTerminator(), mlir::IRMapping::lookup(), mlir::IRMapping::map(), mlir::Operation::setOperands(), and mlir::Value::use_empty().

◆ getCleanupLoopLowerBound()

void getCleanupLoopLowerBound ( AffineForOp forOp,
unsigned unrollFactor,
AffineMap & cleanupLbMap,
SmallVectorImpl< Value > & cleanupLbOperands )
static

Computes the cleanup loop lower bound of the loop being unrolled with the specified unroll factor; this bound will also be upper bound of the main part of the unrolled loop.

Computes the bound as an AffineMap with its operands or a null map when the trip count can't be expressed as an affine expression.

Definition at line 45 of file LoopUtils.cpp.

References b, mlir::affine::canonicalizeMapAndOperands(), mlir::affine::fullyComposeAffineMapAndOperands(), mlir::AffineMap::get(), mlir::AffineMap::getNumDims(), mlir::AffineMap::getNumResults(), mlir::AffineMap::getNumSymbols(), mlir::AffineMap::getResult(), mlir::affine::getTripCountMapAndOperands(), and mlir::simplifyAffineMap().

Referenced by generateCleanupLoopForUnroll().

◆ getContext()

b getContext ( )

Referenced by mlir::detail::AsmStateImpl::AsmStateImpl(), mlir::impl::LowerSparseOpsToForeachBase< DerivedT >::classof(), mlir::memref::impl::ExpandReallocPassBase< DerivedT >::clonePass(), mlir::computeLinearIndex(), mlir::affine::computeSliceUnion(), constifyIndexValues(), mlir::detail::ConversionPatternRewriterImpl::ConversionPatternRewriterImpl(), mlir::ConvertOpInterfaceToLLVMPattern< SourceOp >::ConvertOpInterfaceToLLVMPattern(), mlir::OneToNOpAdaptor< SelectOp >::ConvertOpToLLVMPattern(), mlir::ConvertToLLVMPattern::copyUnrankedDescriptor(), mlir::memref::createExpandOpsPass(), mlir::LLVM::detail::DebugTranslation::DebugTranslation(), mlir::PassManager::enableCrashReproducerGeneration(), mlir::spirv::ImageType::get(), mlir::impl::BubbleDownMemorySpaceCastsBase< DerivedT >::getArgumentName(), mlir::sparse_tensor::SparseTensorType::getCOOType(), mlir::omp::impl::PrepareForOMPOffloadPrivatizationPassBase< DerivedT >::getDependentDialects(), mlir::quant::impl::NormalizeQuantTypesBase< DerivedT >::getDependentDialects(), mlir::SPIRVTypeConverter::getIndexType(), mlir::ConvertToLLVMPattern::getIntPtrType(), mlir::dataflow::CFGEdge::getLoc(), mlir::impl::LowerSparseIterationToSCFBase< DerivedT >::getName(), mlir::impl::SparseAssemblerBase< DerivedT >::getName(), mlir::impl::LowerForeachToSCFBase< DerivedT >::getPassName(), mlir::ConvertToLLVMPattern::getPtrType(), mlir::getSymbolLessAffineMaps(), mlir::ConvertToLLVMPattern::getVoidType(), L0RTContextWrapper::L0RTContextWrapper(), mlirAffineExprGetContext(), mlirAffineMapGetContext(), mlirAttributeGetContext(), mlirDialectGetContext(), mlirIdentifierGetContext(), mlirIntegerSetGetContext(), mlirLocationGetContext(), mlirModuleGetContext(), mlirOperationGetContext(), mlirOperationSetInherentAttributeByName(), mlirRewriterBaseGetContext(), mlirTypeGetContext(), mlirValueGetContext(), mlir::LLVM::ModuleImport::ModuleImport(), mlir::detail::StorageUserBase< ConcreteType, BaseType, StorageType, detail::AttributeUniquer, Traits... >::mutate(), mlir::detail::ParserState::ParserState(), mlir::AffineExpr::print(), mlir::AffineMap::print(), mlir::Attribute::print(), mlir::IntegerSet::print(), mlir::Type::print(), mlir::Attribute::printStripped(), mlir::BytecodeReader::Impl::read(), mlir::detail::RecoveryReproducerContext::RecoveryReproducerContext(), mlir::SymbolTable::rename(), mlir::SymbolTable::rename(), ConvertMathToROCDLPass::runOnOperation(), mlir::detail::OpToOpPassAdaptor::runOnOperation(), mlir::spirv::Serializer::Serializer(), and mlir::StructuredGenerator< StructuredOpInterface, IteratorTypeT >::StructuredGenerator().

◆ getFullMemRefAsRegion()

bool getFullMemRefAsRegion ( Operation * op,
unsigned numParamLoopIVs,
MemRefRegion * region )
static

Construct the memref region to just include the entire memref.

Returns false dynamic shaped memref's for now. numParamLoopIVs is the number of enclosing loop IVs of op (starting from the outermost) that the region is parametric on.

Definition at line 2257 of file LoopUtils.cpp.

References mlir::affine::extractForInductionVars(), mlir::affine::getAffineForIVs(), mlir::affine::MemRefRegion::getConstraints(), mlir::Value::getType(), mlir::affine::MemRefRegion::memref, and mlir::affine::MemRefRegion::setWrite().

◆ getMultiLevelStrides()

void getMultiLevelStrides ( const MemRefRegion & region,
ArrayRef< int64_t > bufferShape,
SmallVectorImpl< StrideInfo > * strideInfos )
static

Returns striding information for a copy/transfer of this region with potentially multiple striding levels from outermost to innermost.

For an n-dimensional region, there can be at most n-1 levels of striding successively nested.

Definition at line 1814 of file LoopUtils.cpp.

References mlir::Value::getType(), and mlir::affine::MemRefRegion::memref.

Referenced by generateCopy().

◆ if()

◆ inserted()

*if copies could not be generated due to yet unimplemented cases *copyInPlacementStart and copyOutPlacementStart in copyPlacementBlock *specify the insertion points where the incoming copies and outgoing should be inserted ( the insertion happens right before the *insertion point)

Referenced by mlir::AsmParserState::addAttrAliasDefinition(), mlir::AsmParserState::addDefinition(), mlir::AnalysisState::addDependency(), mlir::AsmParserState::addTypeAliasDefinition(), mlir::AsmParserState::addUses(), mlir::tblgen::SymbolInfoMap::bindAttr(), mlir::tblgen::SymbolInfoMap::bindMultipleValues(), mlir::tblgen::SymbolInfoMap::bindOpResult(), mlir::tblgen::SymbolInfoMap::bindProp(), mlir::tblgen::SymbolInfoMap::bindValue(), buildPackingLoopNestImpl(), checkCorrectAnyOf(), createIndex(), createSplitPart(), mlir::LLVM::detail::LoopAnnotationTranslation::getAccessGroup(), mlir::impl::OutlineShapeComputationPassBase< DerivedT >::getArgument(), mlir::impl::OutlineShapeComputationPassBase< DerivedT >::getArgumentName(), mlir::transform::impl::CheckUsesPassBase< DerivedT >::getArgumentName(), getConstraintPredicates(), mlir::tblgen::DagNode::getDialectOp(), getMemoryFootprintBytes(), getOrCreateBlockIndices(), mlir::DialectRegistry::insert(), mlir::linalg::insertSlicesBack(), mlir::sparse_tensor::isBlockSparsity(), mlir::CyclicReplacerCache< InT, OutT >::lookupOrInit(), mlir::GPUFuncOpLowering::matchAndRewrite(), mlir::Namespace::newName(), mlir::Namespace::newName(), remapInlinedLocations(), mlir::linalg::DownscaleConv2DOp::returningMatchAndRewrite(), mlir::linalg::DownscaleDepthwiseConv2DNhwcHwcOp::returningMatchAndRewrite(), mlir::linalg::DownscaleSizeOneWindowed2DConvolution< Conv2DOp, Conv1DOp >::returningMatchAndRewrite(), mlir::SymbolTable::SymbolTable(), mlir::transformCFGToSCF(), transformToReduceLoop(), and visitUpward().

◆ moveLoopBody()

void moveLoopBody ( AffineForOp src,
AffineForOp dest )
static

Move the loop body of AffineForOp 'src' from 'src' to the start of dest body.

Definition at line 417 of file LoopUtils.cpp.

References moveLoopBodyImpl().

Referenced by constructTiledLoopNest().

◆ moveLoopBodyImpl()

void moveLoopBodyImpl ( AffineForOp src,
AffineForOp dest,
Block::iterator loc )
static

Move the loop body of AffineForOp 'src' from 'src' into the specified location in destination's body, ignoring the terminator.

Definition at line 408 of file LoopUtils.cpp.

Referenced by moveLoopBody().

◆ performPreTilingChecks()

template<typename t>
LogicalResult performPreTilingChecks ( MutableArrayRef< AffineForOp > input,
ArrayRef< t > tileSizes )
static

Check if the input nest is supported for tiling and whether tiling would be legal or not.

Definition at line 383 of file LoopUtils.cpp.

References checkIfHyperRectangular(), mlir::affine::isPerfectlyNested(), and success().

Referenced by mlir::affine::tilePerfectlyNested(), and mlir::affine::tilePerfectlyNestedParametric().

◆ replaceIterArgsAndYieldResults()

void replaceIterArgsAndYieldResults ( AffineForOp forOp)
static

Helper to replace uses of loop carried values (iter_args) and loop yield values while promoting single iteration affine.for ops.

Definition at line 103 of file LoopUtils.cpp.

Referenced by mlir::affine::promoteIfSingleIteration().

◆ replacement()

*if copies could not be generated due to yet unimplemented cases *copyInPlacementStart and copyOutPlacementStart in copyPlacementBlock *specify the insertion points where the incoming copies and outgoing should be the output argument nBegin is set to its * replacement ( set to `begin` if no invalidation happens)

Referenced by mlir::alignAffineMapWithValues(), applyTilingToAll(), mlir::bufferization::func_ext::CallOpInterface::bufferize(), mlir::bufferization::buildSubsetExtraction(), castSameSizedTypes(), mlir::async::cloneConstantsIntoTheRegion(), createExtractAndCast(), mlir::bufferization::eliminateEmptyTensors(), mlir::bufferization::foldToBufferToTensorPair(), generateFusedElementwiseOpRegion(), mlir::LLVM::ModuleTranslation::getOrCreateAliasScope(), mlir::CyclicReplacerCache< void *, const void * >::lookupOrInit(), DropUnitDimsFromScfForOp::matchAndRewrite(), mlir::linalg::FoldTensorCastPackOp::matchAndRewrite(), mlir::linalg::FoldTensorCastUnPackOp::matchAndRewrite(), mlirAffineMapReplace(), mlir::RewriterBase::ForwardingListener::notifyOperationReplaced(), mlir::RewriterBase::Listener::notifyOperationReplaced(), mlir::RewriterBase::Listener::notifyOperationReplaced(), mlir::RewriterBase::PatternLoggingListener::notifyOperationReplaced(), mlir::transform::TransformRewriter::notifyPayloadOperationReplaced(), SliceCanonicalizer::operator()(), pruneRedundantArguments(), mlir::irdl::detail::Template::render(), mlir::AffineExpr::replace(), mlir::AffineMap::replace(), mlir::replaceAllUsesInRegionWith(), mlir::scf::replaceAndCastForOpIterArg(), mlir::detail::AttrTypeReplacerBase< Concrete >::replaceElementsIn(), mlir::transform::TransformState::Extension::replacePayloadOp(), mlir::transform::TransformState::Extension::replacePayloadValue(), replaceUnitMappingIdsHelper(), mlir::memref::replaceWithIndependentOp(), mlir::LLVM::DIExpressionRewriter::simplify(), and mlir::transform::TransformRewriter::TransformState.

◆ setInterTileBoundsParametric()

void setInterTileBoundsParametric ( OpBuilder & b,
AffineForOp origLoop,
AffineForOp newLoop,
Value tileSize )
static

Set lower and upper bounds of inter-tile loops for parametric tiling.

Definition at line 559 of file LoopUtils.cpp.

References b, mlir::AffineMap::get(), mlir::AffineMap::getNumDims(), mlir::AffineMap::getNumResults(), mlir::AffineMap::getNumSymbols(), and mlir::AffineMap::getResults().

Referenced by constructParametricallyTiledIndexSetHyperRect().

◆ setIntraTileBoundsParametric()

void setIntraTileBoundsParametric ( OpBuilder & b,
AffineForOp origLoop,
AffineForOp newInterTileLoop,
AffineForOp newIntraTileLoop,
Value tileSize )
static

◆ stripmineSink() [1/2]

template<typename SizeType>
AffineForOp stripmineSink ( AffineForOp forOp,
SizeType factor,
AffineForOp target )
static

Definition at line 1572 of file LoopUtils.cpp.

References stripmineSink(), and target.

◆ stripmineSink() [2/2]

SmallVector< AffineForOp, 8 > stripmineSink ( AffineForOp forOp,
uint64_t factor,
ArrayRef< AffineForOp > targets )
static

Variable Documentation

◆ copies

* if copies could not be generated due to yet unimplemented cases* copyInPlacementStart and copyOutPlacementStart in copyPlacementBlock* specify the insertion points where the incoming copies and outgoing copies

Creates a buffer in the faster memory space for the specified memref region (memref has to be non-zero ranked); generates a copy from the lower memory space to this one, and replaces all loads/stores in the block range [‘begin’, ‘end’) of ‘block’ to load/store from that buffer. Returns failure.

Definition at line 1933 of file LoopUtils.cpp.

◆ copyNestRoot

return copyNestRoot

Definition at line 1920 of file LoopUtils.cpp.

Referenced by if().

◆ fastBufExprs

fastBufExprs

Definition at line 1898 of file LoopUtils.cpp.

◆ fastBufMap

canonicalizeMapAndOperands & fastBufMap = simplifyAffineMap(fastBufMap)

Definition at line 1899 of file LoopUtils.cpp.

Referenced by if().

◆ load

◆ respectively

* if copies could not be generated due to yet unimplemented cases* copyInPlacementStart and copyOutPlacementStart in copyPlacementBlock* specify the insertion points where the incoming copies and outgoing * respectively

Definition at line 1934 of file LoopUtils.cpp.