MLIR 22.0.0git
IndependenceTransforms.cpp File Reference

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.
static UnrealizedConversionCastOp propagateSubViewOp (RewriterBase &rewriter, UnrealizedConversionCastOp conversionOp, SubViewOp op)
 Push down an UnrealizedConversionCastOp past a SubViewOp.
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.

Function Documentation

◆ makeIndependent()

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

◆ propagateSubViewOp()

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

Push down an UnrealizedConversionCastOp past a SubViewOp.

Definition at line 66 of file IndependenceTransforms.cpp.

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

Referenced by replaceAndPropagateMemRefType().

◆ replaceAndPropagateMemRefType()

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 96 of file IndependenceTransforms.cpp.

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

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