[llvm] [InstCombine] Canonicalize `(sitofp x)` -> `(uitofp x)` if `x >= 0` (PR #82404)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 7 09:26:26 PST 2024
goldsteinn wrote:
> > > Regression:
> > > ```
> > > define float @src(i32 %shr.i) {
> > > %and.i = and i32 %shr.i, 32767
> > > %sub = uitofp i32 %and.i to float
> > > %add = fadd float %sub, -16383.0
> > > ret float %add
> > > }
> > >
> > > define float @tgt(i32 %shr.i) {
> > > %and.i = and i32 %shr.i, 32767
> > > %addconv = add nsw i32 %and.i, -16383
> > > %sub = sitofp i32 %addconv to float
> > > ret float %sub
> > > }
> > > ```
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Alive2: https://alive2.llvm.org/ce/z/W6Ik5C
> >
> >
> > Is that a regression? Seems like the `fadd` -> `add` is desirable. Likewise we don't really know return op sign in either.
>
> [dtcxzyw/llvm-opt-benchmark#248 (comment)](https://github.com/dtcxzyw/llvm-opt-benchmark/pull/248#discussion_r1515850373) But this patch transforms `add + sitofp` into `uitofp + fadd` :(
Ah I see, thought you meant the other way around.
Okay, think what needs to change is need to be able to handle `uitofp` as `sitofp`
in `foldFBinOpOfIntCasts`. Ill make a patch.
https://github.com/llvm/llvm-project/pull/82404
More information about the llvm-commits
mailing list