[llvm] [InstCombine] Canonicalize `(uitofp x)` -> `(sitofp x)` if `x >= 0` (PR #82404)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 20 11:50:46 PST 2024


goldsteinn wrote:

> > Edit: The little test I added is an example.
> 
> Is there some inherent reason why that transform can only work with sitofp, rather than also uitofp with an s/signed/unsigned replacement everywhere? If there isn't, we should extend that transform instead.
I think it works for both.

One more thing, some backend (x86 for example) have better codegen with `si` than `ui` (not sure of any counter cases).
https://godbolt.org/z/f5joos63o

and its not too uncommon for info from middle-end to be lost on the way to backend.

Can be fixed up elsewhere (i.e during lowering) but think generally its indicative of the somewhat builtin "signedness" of floats and thus how `si` is a better match.

If youre not convinced lmk and ill swap this patch around and start work on the regressions.

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


More information about the llvm-commits mailing list