Differential Revision: https://reviews.llvm.org/D97939
LogicalResult matchAndRewrite(Operation *op,
PatternRewriter &rewriter) const override {
+ if (auto copyOp = dyn_cast<CopyOp>(op)) {
+ assert(copyOp.hasBufferSemantics());
+ if (copyOp.input() == copyOp.output() &&
+ copyOp.inputPermutation() == copyOp.outputPermutation()) {
+ rewriter.eraseOp(op);
+ return success();
+ }
+ }
+
if (!isa<GenericOp, IndexedGenericOp>(op))
return failure();
LinalgOp genericOp = cast<LinalgOp>(op);
// CHECK: %[[INSERTED:.+]] = subtensor_insert %{{.+}} into %[[FILL]]
// CHECK: %[[RESULT:.+]] = tensor.cast %[[INSERTED]]
// CHECK: return %[[RESULT]]
+
+// -----
+
+// CHECK-LABEL: @self_copy
+func @self_copy(%arg0 : memref<2x3x?x4xf32>) {
+
+// CHECK-NOT: linalg.copy
+ linalg.copy(%arg0, %arg0): memref<2x3x?x4xf32>, memref<2x3x?x4xf32>
+
+// CHECK: return
+ return
+}