[Mlir-commits] [mlir] [mlir][arith] Add constraints to the MulIOp for preventing type mismatch while folding (PR #136093)

Maksim Levental llvmlistbot at llvm.org
Thu Apr 17 15:21:29 PDT 2025


makslevental wrote:

> Because the underlying issue seems hard to fix fundamentally?

> `complex.constant` doesn't return a TypedAttribute

Just double checking my understanding: is the issue that there's no uniform/generic interface for getting the type of the `OpFoldResult`? If so, couldn't we just promote the `ConstantLike` trait to full-fledged interface with a required member called `getOpFoldResultType()`? Then e.g., this PR could be spelled 

```
(Constraint<CPred<"$0.getType() == cast<ConstantLike>($1).getType()">> $res, $c0),
(Constraint<CPred<"$0.getType() == cast<ConstantLike>($1).getType()">> $res, $c1)
```

or (preferrably) we could just bake this directly into the canonicalization/folding system.

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


More information about the Mlir-commits mailing list