[clang] [llvm] [IR] Add fast-math support to {u,s}itofp (PR #198470)

Jay Foad via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 4 03:34:48 PDT 2026


jayfoad wrote:

> > > > * CodeGen part needs `nsz` to fold pattern (uitofp (fptoui x)).
> > > 
> > > 
> > > Does it? There's no integer value that would result in a signed zero being the results of uitofp (or sitofp), so I would expect nsz to not add any extra information.
> > 
> > 
> > DAGCombiner tries to fold this pattern to trunc, which may not preserves the sign of zero, e.g. when x is -0.5.
> 
> Ah, looking at foldFPToIntToFP the transform currently depends on the function-level no-signed-zeros-fp-math attribute, and this would allow the instruction to be checked instead. It would be good to have this explained in the PR (and commit) description.

I still don't get it. Surely if you want to fold `(uitofp (fptoui x)) --> (trunc x)` then it's the `fptoui` that needs to have the `nsz` flag, to say that the input can be assumed not -0.0? What would `uitofp nsz` mean??

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


More information about the cfe-commits mailing list