[Mlir-commits] [mlir] [MLIR] Fixes arith.sub folder crash on dynamically shaped tensors (PR #118908)

Ivan Butygin llvmlistbot at llvm.org
Thu Dec 5 16:59:47 PST 2024


================
@@ -393,8 +393,12 @@ void arith::AddUIExtendedOp::getCanonicalizationPatterns(
 
 OpFoldResult arith::SubIOp::fold(FoldAdaptor adaptor) {
   // subi(x,x) -> 0
-  if (getOperand(0) == getOperand(1))
-    return Builder(getContext()).getZeroAttr(getType());
+  if (getOperand(0) == getOperand(1)) {
+    auto tensorType = dyn_cast<TensorType>(getType());
----------------
Hardcode84 wrote:

Maybe check for `ShapedType` instead? In case we decide to introduce dynamically-sized vectors one day.

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


More information about the Mlir-commits mailing list