[Mlir-commits] [mlir] [mlir][arith] Canonicalize sitofp(truncf) -> sitofp, and uitofp. (PR #139925)

Krzysztof Drewniak llvmlistbot at llvm.org
Wed May 14 23:35:56 PDT 2025


krzysz00 wrote:

`EmilateUnsupportedFloats` is, from where I'm standing, part of the late pre-export blob that doesn't have clear phase ordering (other residents of that blob would be stuff like flowering vector.transfer_read to vector.load but also, say, integer range optimizations or stuff like one last poke with the loop invariant code motion. Different projects might order everything slightly differently, and it's reasonable for there to be a canonicalization between unsupported float emulation and ConvertTo{LLVM,SPIR-V,...} 

Maybe this canonicalization is fine, but if we're in a contest where 

```
%y = aritf.sitofp %x : i32 to bf16
```
doesn't exist but 
```
‰y0 = arith.sitofp %x ; i32 up f32
%y = arith.truncf %y0 : f32 to bf16
```
, undoing the transformation of the former to the latter would make things more annoying in lowering.

Maybe we want to use a fastmath flag on the sitofp to indicate when this transformation is allowed?

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


More information about the Mlir-commits mailing list