[PATCH] D138814: [InstCombine] Combine a/lshr of add -> uadd.with.overflow
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 30 05:00:12 PST 2022
lebedev.ri added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp:917-918
+ // Replace the use of `Op0` by `I` with `Overflow`.
+ if (IsAShr)
+ return new SExtInst(Overflow, Ty);
+ return new ZExtInst(Overflow, Ty);
----------------
Pierre-vh wrote:
> lebedev.ri wrote:
> > `mul i16 255, 2` is `i16 510`, which is non-negative,
> > so the signbit of the original result is never set.
> > IOW, just zero-extend.
> Is it normal that Alive2 reports the transformation as incorrect for i2 then (see @foad's comment above) ?
> Maybe we just need to SExt if it's i2 + ashr?
Ok, good point, please add that as a comment.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138814/new/
https://reviews.llvm.org/D138814
More information about the llvm-commits
mailing list