[Mlir-commits] [mlir] [MLIR][Vector] Enhance shape_cast unrolling support in case the target shape is [1, 1, ..1] (PR #183436)

Artem Kroviakov llvmlistbot at llvm.org
Thu Feb 26 04:40:51 PST 2026


================
@@ -1196,12 +1196,11 @@ struct UnrollConstantMaskPattern
 static bool isContiguous(ArrayRef<int64_t> extractShape,
                          ArrayRef<int64_t> shape) {
 
-  if (extractShape.size() > shape.size())
+  if (extractShape.empty() || extractShape.size() > shape.size())
     return false;
 
-  while (!extractShape.empty() && extractShape.front() == 1) {
+  while (extractShape.size() > 1 && extractShape.front() == 1)
     extractShape = extractShape.drop_front();
-  }
 
   while (!shape.empty() && shape.front() == 1) {
----------------
akroviakov wrote:

Why do we allow `shape` to become empty if `extractShape`  is now not allowed to be empty? Wouldn't that create issues for `size_t rankDiff` (e.g., `0 - 1`)?

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


More information about the Mlir-commits mailing list