[Mlir-commits] [mlir] [mlir][vector] Constrain broadcast->shape_cast folding (PR #190230)
Benoit Jacob
llvmlistbot at llvm.org
Mon Apr 6 08:44:09 PDT 2026
================
@@ -0,0 +1,14 @@
+// RUN: mlir-opt %s --split-input-file --canonicalize | FileCheck %s
+
+// Dropping only trailing unit dims from a broadcast result preserves linear
+// element order but must not fold to a lower-rank broadcast: rank is
+// significant for users such as vector.transpose (e.g. 2x2x1 vs 2x2).
+
+// CHECK-LABEL: @negative_shape_cast_broadcast_fold_trailing_unit
+// CHECK: vector.broadcast %{{.*}} : vector<2x1xf32> to vector<2x2x1xf32>
+// CHECK-NEXT: vector.shape_cast %{{.*}} : vector<2x2x1xf32> to vector<2x2xf32>
----------------
bjacob wrote:
Thanks for pushing me to further clarify this. Answering this, I realized that the issue was even more basic than I thought: it's not specific to consumer transpose at all. Filed https://github.com/llvm/llvm-project/issues/190614 to explain what the issue is with a minimal example. Updated this PR, simplified logic and testcase.
https://github.com/llvm/llvm-project/pull/190230
More information about the Mlir-commits
mailing list