[Mlir-commits] [mlir] [mlir][arith] Add `arith.fptofp` op (PR #188041)

Hocky Yudhiono llvmlistbot at llvm.org
Mon Mar 23 08:28:11 PDT 2026


hockyy wrote:

> > On the other hand, you may be able to get rid of these checks when coming from the frontend. E.g., PyTorch does not distinguish between FP extensions/truncations: x_f32.to(torch.float16).
> 
> So now when converting from torch to something arith-like your code becomes
> 
> ```
> if (width(src) < width(dst)) {
>   arith::ExtfOp::create(...);
> } else if (width(src) > width(dst)) {
>   arith::TruncfOp::create(...);
> } else {
>   arith::FptoFpOp::create(...);
> }
> ```
> 
> which gives each of these three options one legal representation.

Hmm.. would an interface that catch all this 3 operations work, here? or several utils can cut down this logic I think.

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


More information about the Mlir-commits mailing list