MLIR  16.0.0git
Macros | Functions
Hoisting.cpp File Reference
#include "mlir/Dialect/Linalg/Transforms/Hoisting.h"
#include "mlir/Analysis/SliceAnalysis.h"
#include "mlir/Dialect/Affine/Analysis/AffineStructures.h"
#include "mlir/Dialect/Affine/IR/AffineValueMap.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/Linalg/Transforms/Transforms.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/SCF/Utils/Utils.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Vector/IR/VectorOps.h"
#include "mlir/Dialect/Vector/Utils/VectorUtils.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Dominance.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "mlir/Transforms/LoopInvariantCodeMotionUtils.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Debug.h"
+ Include dependency graph for Hoisting.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "linalg-hoisting"
 
#define DBGS()   (dbgs() << '[' << DEBUG_TYPE << "] ")
 

Functions

static bool isEqualOffsetSizeOrStride (OpFoldResult op1, OpFoldResult op2)
 Return true if op1 and op2 are the same constant or the same SSA value. More...
 
static bool sameOffsetsSizesAndStrides (tensor::ExtractSliceOp s, tensor::InsertSliceOp si)
 Return true is all offsets, sizes and strides are equal. More...
 
static HoistableRead findMatchingTransferRead (HoistableWrite write, Value srcTensor)
 Look for a HoistableRead, in the given tensor uses, accessing the same offset as the HoistableWrite. More...
 
static bool tensorChunkAccessedByUnknownOp (HoistableWrite write, HoistableRead candidateRead, BlockArgument tensorArg)
 Check if the chunk of data inserted by the HoistableWrite are read by any other op than the HoistableRead candidate. More...
 
static HoistableWrite getLoopInvariantTransferWriteOpDefining (scf::ForOp forOp, OpOperand &yieldOperand)
 Return the forOp-invariant HoistableWrite that produces yieldOperand. More...
 
static void hoistReadWrite (HoistableRead read, HoistableWrite write, BlockArgument tensorBBArg)
 Mechanical hoisting of a matching HoistableRead / HoistableWrite pair. More...
 

Macro Definition Documentation

◆ DBGS

#define DBGS ( )    (dbgs() << '[' << DEBUG_TYPE << "] ")

Definition at line 38 of file Hoisting.cpp.

◆ DEBUG_TYPE

#define DEBUG_TYPE   "linalg-hoisting"

Definition at line 36 of file Hoisting.cpp.

Function Documentation

◆ findMatchingTransferRead()

static HoistableRead findMatchingTransferRead ( HoistableWrite  write,
Value  srcTensor 
)
static

Look for a HoistableRead, in the given tensor uses, accessing the same offset as the HoistableWrite.

Definition at line 99 of file Hoisting.cpp.

References DBGS, mlir::Operation::getUsers(), mlir::Value::getUsers(), mlir::vector::isDisjointTransferIndices(), and sameOffsetsSizesAndStrides().

Referenced by mlir::linalg::hoistRedundantVectorTransfersOnTensor().

◆ getLoopInvariantTransferWriteOpDefining()

static HoistableWrite getLoopInvariantTransferWriteOpDefining ( scf::ForOp  forOp,
OpOperand yieldOperand 
)
static

Return the forOp-invariant HoistableWrite that produces yieldOperand.

Return the null HoistableWrite() if it is not comprised of a vector.transfer_write + optional insert_slice or if any of the indexings is forOp-dependent.

Definition at line 235 of file Hoisting.cpp.

References mlir::IROperand< DerivedT, IRValueT >::get(), mlir::Value::getDefiningOp(), and mlir::OpOperand::getOperandNumber().

◆ hoistReadWrite()

static void hoistReadWrite ( HoistableRead  read,
HoistableWrite  write,
BlockArgument  tensorBBArg 
)
static

Mechanical hoisting of a matching HoistableRead / HoistableWrite pair.

Definition at line 273 of file Hoisting.cpp.

References DBGS, mlir::BlockArgument::getArgNumber(), mlir::BlockArgument::getOwner(), mlir::Block::getParentOp(), and mlir::replaceLoopWithNewYields().

Referenced by mlir::linalg::hoistRedundantVectorTransfersOnTensor().

◆ isEqualOffsetSizeOrStride()

static bool isEqualOffsetSizeOrStride ( OpFoldResult  op1,
OpFoldResult  op2 
)
static

Return true if op1 and op2 are the same constant or the same SSA value.

Definition at line 59 of file Hoisting.cpp.

References mlir::Attribute::dyn_cast(), mlir::Attribute::dyn_cast_or_null(), mlir::getConstantIntValue(), and mlir::Value::getDefiningOp().

Referenced by sameOffsetsSizesAndStrides().

◆ sameOffsetsSizesAndStrides()

static bool sameOffsetsSizesAndStrides ( tensor::ExtractSliceOp  s,
tensor::InsertSliceOp  si 
)
static

Return true is all offsets, sizes and strides are equal.

Definition at line 77 of file Hoisting.cpp.

References isEqualOffsetSizeOrStride().

Referenced by findMatchingTransferRead().

◆ tensorChunkAccessedByUnknownOp()

static bool tensorChunkAccessedByUnknownOp ( HoistableWrite  write,
HoistableRead  candidateRead,
BlockArgument  tensorArg 
)
static

Check if the chunk of data inserted by the HoistableWrite are read by any other op than the HoistableRead candidate.

Definition at line 174 of file Hoisting.cpp.

References mlir::Value::getUses(), and mlir::vector::isDisjointTransferIndices().

Referenced by mlir::linalg::hoistRedundantVectorTransfersOnTensor().