[Mlir-commits] [mlir] [mlir] Add Memref Normalization support for reinterpret_cast op (PR #133417)
Uday Bondhugula
llvmlistbot at llvm.org
Fri Apr 4 07:59:09 PDT 2025
================
@@ -1216,53 +1138,57 @@ LogicalResult mlir::affine::replaceAllMemRefUsesWith(
if (usePositions.empty())
return success();
- if (usePositions.size() > 1) {
- // TODO: extend it for this case when needed (rare).
- assert(false && "multiple dereferencing uses in a single op not supported");
- return failure();
- }
-
unsigned memRefOperandPos = usePositions.front();
OpBuilder builder(op);
// The following checks if op is dereferencing memref and performs the access
// index rewrites.
auto affMapAccInterface = dyn_cast<AffineMapAccessInterface>(op);
- if (!affMapAccInterface) {
+ if (!isDereferencingOp(op)) {
if (!allowNonDereferencingOps) {
// Failure: memref used in a non-dereferencing context (potentially
// escapes); no replacement in these cases unless allowNonDereferencingOps
// is set.
return failure();
}
+ for (unsigned pos : usePositions)
+ op->setOperand(pos, newMemRef);
+ return success();
+ }
- // Check if it is a memref.load
- auto memrefLoad = dyn_cast<memref::LoadOp>(op);
- bool isReductionLike =
- indexRemap.getNumResults() < indexRemap.getNumInputs();
- if (!memrefLoad || !isReductionLike) {
- op->setOperand(memRefOperandPos, newMemRef);
- return success();
- }
+ if (usePositions.size() > 1) {
+ // TODO: extend it for this case when needed (rare).
+ assert(false && "multiple dereferencing uses in a single op not supported");
----------------
bondhugula wrote:
We shouldn't be asserting and then returning failure. Use LLVM_DEBUG and return failure?
https://github.com/llvm/llvm-project/pull/133417
More information about the Mlir-commits
mailing list