[Mlir-commits] [mlir] [mlir] only fold llvm.mlir.constant when types match (PR #70318)

Mehdi Amini llvmlistbot at llvm.org
Thu Oct 26 12:59:18 PDT 2023


================
@@ -87,9 +87,8 @@ struct constant_op_binder {
 
     // Fold the constant to an attribute.
     SmallVector<OpFoldResult, 1> foldedOp;
-    LogicalResult result = op->fold(/*operands=*/std::nullopt, foldedOp);
-    (void)result;
-    assert(succeeded(result) && "expected ConstantLike op to be foldable");
+    if (failed(op->fold(/*operands=*/std::nullopt, foldedOp)))
+      return false;
----------------
joker-eph wrote:

That seems a bit scary to me: why are we even allowing `ConstantLike` to do things like `  %0 = llvm.mlir.constant(42 : index) : i64`?

I don't grasp the use-case right now, but we should iterate in the issue maybe.

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


More information about the Mlir-commits mailing list