[Mlir-commits] [mlir] [mlir][tensor][NFC] Remove dead code `tensor.extract_slice` canonicalization pattern (PR #131903)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Mar 18 12:53:08 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Matthias Springer (matthias-springer)

<details>
<summary>Changes</summary>

Folding a cast into an `extract_slice` does not change the result type.


---
Full diff: https://github.com/llvm/llvm-project/pull/131903.diff


1 Files Affected:

- (modified) mlir/lib/Dialect/Tensor/IR/TensorOps.cpp (-2) 


``````````diff
diff --git a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
index e5a32c0bbd4e0..2d5df07f8af4b 100644
--- a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
+++ b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
@@ -2476,8 +2476,6 @@ class ExtractSliceOpCastFolder final : public OpRewritePattern<ExtractSliceOp> {
         loc, sliceOp.getType(), castOp.getSource(), sliceOp.getOffsets(),
         sliceOp.getSizes(), sliceOp.getStrides(), sliceOp.getStaticOffsets(),
         sliceOp.getStaticSizes(), sliceOp.getStaticStrides());
-    if (newResult.getType() != sliceOp.getType())
-      newResult = rewriter.create<CastOp>(loc, sliceOp.getType(), newResult);
     rewriter.replaceOp(sliceOp, newResult);
     return success();
   }

``````````

</details>


https://github.com/llvm/llvm-project/pull/131903


More information about the Mlir-commits mailing list