[llvm] [InstCombine] Canonicalize `(sitofp x)` -> `(uitofp x)` if `x >= 0` (PR #82404)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 7 09:03:45 PST 2024
dtcxzyw 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.
https://github.com/dtcxzyw/llvm-opt-benchmark/pull/248#discussion_r1515850373
But this patch transforms `add + sitofp` into `uitofp + fadd` :(
https://github.com/llvm/llvm-project/pull/82404
More information about the llvm-commits
mailing list