[Mlir-commits] [mlir] [mlir][vector] Constrain broadcast->shape_cast folding (PR #190230)
Diego Caballero
llvmlistbot at llvm.org
Thu Apr 2 13:52:45 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>
----------------
dcaballe wrote:
Could you elaborate a bit more on this? I'm not sure I follow... Broadcasting 2x1 to 2x2x1 should produce the same element order than broadcasting 2 to 2x2?
Also, which dims are transposed by the problematic transpose?
https://github.com/llvm/llvm-project/pull/190230
More information about the Mlir-commits
mailing list