[Mlir-commits] [mlir] [mlir][arith] Canonicalize sitofp(truncf) -> sitofp, and uitofp. (PR #139925)
Mehdi Amini
llvmlistbot at llvm.org
Thu May 15 01:53:10 PDT 2025
joker-eph wrote:
> 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,...}
If the pass is a "codegen prepare" pass and is generating non-canonical IR intentional to make the lowering easier, then no it is not reasonable to expect that canonicalization can run there.
> , undoing the transformation of the former to the latter would make things more annoying in lowering.
That's not a good argument against the canonicalization to me: the lowering must support `%y = aritf.sitofp %x : i32 to bf16`, or it's the responsibility of the pipeline author to correctly set it up so that the passes necessary to the lowering are correctly ordered (same argument as above).
Something more fundamental to me is rather if we know numerically that `%y = aritf.sitofp %x : i32 to bf16` is equivalent to
```
‰y0 = arith.sitofp %x ; i32 up f32
%y = arith.truncf %y0 : f32 to bf16
```
or if the rounding can differ when removing the intermediate value? The intermediate is higher precision, but still can it always represent exactly all of the values of the smaller one in all cases?
https://github.com/llvm/llvm-project/pull/139925
More information about the Mlir-commits
mailing list