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

Matthias Springer llvmlistbot at llvm.org
Mon Mar 23 07:24:18 PDT 2026


matthias-springer wrote:

`arith.extf` / `arith.truncf` are so widely used, I'm not sure if they should be removed or deprecated. For cleanup purposes, I'd say "yes", but I'm not sure if it's worth the churn. I'm going to ask on Discourse.

> upd: actually, the legalization pass can generate f32 roundtrip for f16<->bf16 too so you won't need any changes in lowering at all.

The way to legalize a certain FP<->FP conversion is quite target-specific. Some architectures may support f16<->bf16 directly. Similarly, some other backends may not be able to do certain conversions between two element types of different bitwidth in one go; there are some such cases in PTX.

So I think this f16 -> f32 -> bf16 legalization pass would have to be in the LLVM dialect. However, for LLVM that would be the only kind of conversion to be legalized. I updated the LLVM lowering pattern to create `arith.truncf` / `extf` for now, and legalize these recursively. That simplifies the code a bit.



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


More information about the Mlir-commits mailing list