MLIR  18.0.0git
Typedefs | Functions
LoopAnalysis.cpp File Reference
#include "mlir/Dialect/Affine/Analysis/LoopAnalysis.h"
#include "mlir/Analysis/SliceAnalysis.h"
#include "mlir/Dialect/Affine/Analysis/AffineAnalysis.h"
#include "mlir/Dialect/Affine/Analysis/AffineStructures.h"
#include "mlir/Dialect/Affine/Analysis/NestedMatcher.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Affine/IR/AffineValueMap.h"
#include "mlir/Support/MathExtras.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
#include <numeric>
#include <optional>
#include <type_traits>

Go to the source code of this file.

Typedefs

using VectorizableOpFun = std::function< bool(AffineForOp, Operation &)>
 

Functions

static bool isAccessIndexInvariant (Value iv, Value index)
 Given an induction variable iv of type AffineForOp and an access index of type index, returns true if index is independent of iv and false otherwise. More...
 
template<typename LoadOrStoreOp >
static bool isContiguousAccess (Value iv, LoadOrStoreOp memoryOp, int *memRefDim)
 Given: More...
 
template<typename LoadOrStoreOp >
static bool isVectorElement (LoadOrStoreOp memoryOp)
 
static bool isVectorizableLoopBodyWithOpCond (AffineForOp loop, const VectorizableOpFun &isVectorizableOp, NestedPattern &vectorTransferMatcher)
 

Typedef Documentation

◆ VectorizableOpFun

using VectorizableOpFun = std::function<bool(AffineForOp, Operation &)>

Definition at line 268 of file LoopAnalysis.cpp.

Function Documentation

◆ isAccessIndexInvariant()

static bool isAccessIndexInvariant ( Value  iv,
Value  index 
)
static

Given an induction variable iv of type AffineForOp and an access index of type index, returns true if index is independent of iv and false otherwise.

The determination supports composition with at most one AffineApplyOp. The 'at most one AffineApplyOp' comes from the fact that the composition of AffineApplyOp needs to be canonicalized by construction to avoid writing code that composes arbitrary numbers of AffineApplyOps everywhere. To achieve this, at the very least, the compose-affine-apply pass must have been run.

Prerequisites:

  1. iv and index of the proper type;
  2. at most one reachable AffineApplyOp from index;

Returns false in cases with more than one AffineApplyOp, this is conservative.

Definition at line 163 of file LoopAnalysis.cpp.

References mlir::affine::getReachableAffineApplyOps(), mlir::Value::getType(), and mlir::affine::isAffineForInductionVar().

Referenced by mlir::affine::getInvariantAccesses(), and isContiguousAccess().

◆ isContiguousAccess()

template<typename LoadOrStoreOp >
static bool isContiguousAccess ( Value  iv,
LoadOrStoreOp  memoryOp,
int *  memRefDim 
)
static

Given:

  1. an induction variable iv of type AffineForOp;
  2. a memoryOp of type const LoadOp& or const StoreOp&; determines whether memoryOp has a contiguous access along iv. Contiguous is defined as either invariant or varying only along a unique MemRef dim. Upon success, the unique MemRef dim is written in memRefDim (or -1 to convey the memRef access is invariant along iv).

Prerequisites:

  1. memRefDim ~= nullptr;
  2. iv of the proper type;
  3. the MemRef accessed by memoryOp has no layout map or at most an identity layout map.

Currently only supports no layoutMap or identity layoutMap in the MemRef. Returns false if the MemRef has a non-identity layoutMap or more than 1 layoutMap. This is conservative.

Definition at line 218 of file LoopAnalysis.cpp.

References isAccessIndexInvariant().

◆ isVectorElement()

template<typename LoadOrStoreOp >
static bool isVectorElement ( LoadOrStoreOp  memoryOp)
static

Definition at line 263 of file LoopAnalysis.cpp.

◆ isVectorizableLoopBodyWithOpCond()

static bool isVectorizableLoopBodyWithOpCond ( AffineForOp  loop,
const VectorizableOpFun isVectorizableOp,
NestedPattern vectorTransferMatcher 
)
static