[Mlir-commits] [mlir] [mlir][vector] Folder: shape_cast(extract) -> extract (PR #146368)

James Newling llvmlistbot at llvm.org
Mon Jul 21 09:57:26 PDT 2025


================
@@ -890,6 +929,19 @@ func.func @fold_extract_broadcast_to_equal_rank(%a : vector<1xf32>, %idx0 : inde
 
 // -----
 
+// CHECK-LABEL: fold_extract_broadcastlike_shape_cast
+//  CHECK-SAME:   %[[A:.*]]: vector<1xf32>
+//       CHECK:   %[[R:.*]] = vector.broadcast %[[A]] : vector<1xf32> to vector<1x1xf32>
----------------
newling wrote:

shape_cast is the canonical form is definitely the end goal, your compass is still reading correctly! Getting there with small steps requires taking this little diversion though. 

Basically, this PR is ensuring that using shape_cast instead of broadcast/extract never results in missed folds. 

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


More information about the Mlir-commits mailing list