[Mlir-commits] [mlir] [mlir][vector] Extend `combineContractAndBroadcast` to accept `vector.shape_cast` (PR #208752)

Andrzej WarzyƄski llvmlistbot at llvm.org
Tue Jul 14 02:09:05 PDT 2026


================
@@ -6787,6 +6759,15 @@ LogicalResult ShapeCastOp::verify() {
   return success();
 }
 
+bool ShapeCastOp::isBroadcastLike() {
+  auto srcType = getSourceVectorType();
+  auto resType = getResultVectorType();
+
+  std::pair<VectorDim, VectorDim> mismatchingDims;
+  return isBroadcastableTo(srcType, resType, &mismatchingDims) ==
----------------
banach-space wrote:

> Would it be possible that we return true for a case whose types look like a broadcast but it's actually representing something else under the shape cast semantics?

I don't think so and that's for two reasons:
* `ShapeCastOp` always preserves the number of elements.
* `BroadcastOp` will only preserve the number of elements if it is merely adding leading unit dims (i.e. it's quite an edge case).

Let me add more checks and comments to make it clearer. I don't that's going to make the method stricter, but definitely clearer.

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


More information about the Mlir-commits mailing list