[Mlir-commits] [mlir] [mlir][vector] Improve shape_cast lowering (PR #140800)

Andrzej Warzyński llvmlistbot at llvm.org
Tue May 27 09:50:51 PDT 2025


================
@@ -157,41 +160,54 @@ class ShapeCastOpRewritePattern : public OpRewritePattern<vector::ShapeCastOp> {
   LogicalResult matchAndRewrite(vector::ShapeCastOp op,
                                 PatternRewriter &rewriter) const override {
     Location loc = op.getLoc();
-    auto sourceVectorType = op.getSourceVectorType();
-    auto resultVectorType = op.getResultVectorType();
+    VectorType sourceType = op.getSourceVectorType();
+    VectorType resultType = op.getResultVectorType();
 
-    if (sourceVectorType.isScalable() || resultVectorType.isScalable())
+    if (sourceType.isScalable() || resultType.isScalable())
       return failure();
 
-    // Special case for n-D / 1-D lowerings with better implementations.
-    int64_t srcRank = sourceVectorType.getRank();
-    int64_t resRank = resultVectorType.getRank();
-    if ((srcRank > 1 && resRank == 1) || (srcRank == 1 && resRank > 1))
+    // Special case for n-D / 1-D lowerings with implementations that use
+    // extract_strided_slice / insert_strided_slice.
----------------
banach-space wrote:

Could we clarify this comment? (the original part is quite confusing). Right now, combined with the code, it reads a bit like: 
> This is a special case, lets fail! 

😅  I assume that it was meant to be: 
> This special case is handled by other, more optimal patterns.

 Or something similar :)

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


More information about the Mlir-commits mailing list