[Mlir-commits] [mlir] [mlir][vector] Fold transpose(broadcast(shape_cast)) to broadcast (PR #215940)

Adam Siemieniuk llvmlistbot at llvm.org
Thu Aug 20 03:49:05 PDT 2026


https://github.com/adam-smnk commented:

The folding use case is sounds and helpful; +1 for the rewrite itself.

>From high-level, the new folder performs similar job to existing `FoldTransposeBroadcast` but it essentially just swaps source from `broadcast` to the producer's `shape_cast` value (with extra preconditions) and then performs general validation whether `transpose(broadcast)` can be applied.

It looks to me that `FoldTransposeBroadcast` already contains exhaustive validation and rewrite logic. I wonder if the two patterns could be refactored to use the same core folder logic with the delta being using mostly different source values?
If possible, it'd reduce maintenance and ensure the two rewrites don't diverge.

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


More information about the Mlir-commits mailing list