[Mlir-commits] [mlir] 68f91cd - [mlir][bufferization] Fix invalid IR in `SimplifyClones` canonicalization (#74417)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Dec 5 16:42:02 PST 2023
Author: Matthias Springer
Date: 2023-12-06T09:41:57+09:00
New Revision: 68f91cd257807ae8aad842d3cdc221415effbb93
URL: https://github.com/llvm/llvm-project/commit/68f91cd257807ae8aad842d3cdc221415effbb93
DIFF: https://github.com/llvm/llvm-project/commit/68f91cd257807ae8aad842d3cdc221415effbb93.diff
LOG: [mlir][bufferization] Fix invalid IR in `SimplifyClones` canonicalization (#74417)
`SimplifyClones` used to generate an invalid op:
```
error: 'memref.cast' op operand type 'memref<*xf32>' and result type 'memref<*xf32>' are cast incompatible
%2 = bufferization.clone %1 : memref<*xf32> to memref<*xf32
```
This commit fixes tests such as
`mlir/test/Dialect/Bufferization/canonicalize.mlir` when verifying the
IR after each pattern (#74270).
Added:
Modified:
mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp b/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
index ec5feab1ed0d8..ca0d2f407c2d8 100644
--- a/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
+++ b/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
@@ -507,8 +507,10 @@ struct SimplifyClones : public OpRewritePattern<CloneOp> {
return failure();
}
- rewriter.replaceOpWithNewOp<memref::CastOp>(cloneOp, cloneOp.getType(),
- source);
+ if (source.getType() != cloneOp.getType())
+ source = rewriter.create<memref::CastOp>(cloneOp.getLoc(),
+ cloneOp.getType(), source);
+ rewriter.replaceOp(cloneOp, source);
rewriter.eraseOp(redundantDealloc);
return success();
}
More information about the Mlir-commits
mailing list