mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-02 10:49:22 +00:00
[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).
This commit is contained in:
parent
dbb782dffd
commit
68f91cd257
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user