MLIR  20.0.0git
Functions
IndependenceTransforms.cpp File Reference
#include "mlir/Dialect/MemRef/Transforms/Transforms.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Affine/Transforms/Transforms.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/Utils/StaticValueUtils.h"
#include "mlir/Interfaces/ValueBoundsOpInterface.h"

Go to the source code of this file.

Functions

static FailureOr< OpFoldResultmakeIndependent (OpBuilder &b, Location loc, OpFoldResult ofr, ValueRange independencies)
 Make the given OpFoldResult independent of all independencies. More...
 
static UnrealizedConversionCastOp propagateSubViewOp (RewriterBase &rewriter, UnrealizedConversionCastOp conversionOp, SubViewOp op)
 Push down an UnrealizedConversionCastOp past a SubViewOp. More...
 
static void replaceAndPropagateMemRefType (RewriterBase &rewriter, Operation *from, Operation *to)
 Given an original op and a new, modified op with the same number of results, whose memref return types may differ, replace all uses of the original op with the new op and propagate the new memref types through the IR. More...
 

Function Documentation

◆ makeIndependent()

static FailureOr<OpFoldResult> makeIndependent ( OpBuilder b,
Location  loc,
OpFoldResult  ofr,
ValueRange  independencies 
)
static

Make the given OpFoldResult independent of all independencies.

Definition at line 21 of file IndependenceTransforms.cpp.

References mlir::ValueBoundsConstraintSet::computeIndependentBound(), mlir::affine::materializeComputedBound(), and mlir::presburger::UB.

◆ propagateSubViewOp()

static UnrealizedConversionCastOp propagateSubViewOp ( RewriterBase rewriter,
UnrealizedConversionCastOp  conversionOp,
SubViewOp  op 
)
static

Push down an UnrealizedConversionCastOp past a SubViewOp.

Definition at line 69 of file IndependenceTransforms.cpp.

References mlir::OpBuilder::create(), mlir::RewriterBase::replaceAllUsesWith(), and mlir::OpBuilder::setInsertionPoint().

Referenced by replaceAndPropagateMemRefType().

◆ replaceAndPropagateMemRefType()

static void replaceAndPropagateMemRefType ( RewriterBase rewriter,
Operation from,
Operation to 
)
static

Given an original op and a new, modified op with the same number of results, whose memref return types may differ, replace all uses of the original op with the new op and propagate the new memref types through the IR.

Example: from = memref.alloca(sz) : memref<?xf32> to = memref.subview ... : ... to memref<?xf32, strided<[1], offset: ?>> memref.store cst, from[c0] : memref<?xf32>

In the above example, all uses of from are replaced with to. This can be done directly for ops such as memref.store. For ops that have memref results (e.g., memref.subview), the result type may depend on the operand type, so we cannot just replace all uses. There is special handling for common memref ops. For all other ops, unrealized_conversion_cast is inserted.

Definition at line 99 of file IndependenceTransforms.cpp.

References mlir::OpBuilder::create(), mlir::detail::enumerate(), mlir::Operation::getLoc(), mlir::Operation::getNumResults(), mlir::Operation::getResult(), mlir::Operation::getResults(), propagateSubViewOp(), mlir::RewriterBase::replaceAllUsesWith(), and mlir::OpBuilder::setInsertionPointAfter().

Referenced by mlir::memref::replaceWithIndependentOp().