[Mlir-commits] [mlir] [mlir][tosa] Fix unranked tosa canonicalizations crashes (PR #188188)

Luke Hutton llvmlistbot at llvm.org
Tue Mar 24 03:24:53 PDT 2026


================
@@ -1553,7 +1572,9 @@ OpFoldResult CastOp::fold(FoldAdaptor adaptor) {
     return {};
 
   auto inTy = llvm::cast<ShapedType>(getInput().getType());
-  auto outTy = llvm::cast<ShapedType>(getType());
+  auto outTy = getStaticResultShapeForDenseFold(*this);
+  if (!outTy)
+    return {};
----------------
lhutton1 wrote:

The function `getStaticResultShapeForDenseFold` seems a bit unnecessary when we could just write:
```
const auto outTy = llvm::cast<ShapedType>(getType());
if (!outTy.hasStaticShape())
   return {};
```

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


More information about the Mlir-commits mailing list