[PATCH] D138814: [InstCombine] Combine a/lshr of add -> uadd.with.overflow
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 1 11:32:07 PST 2022
lebedev.ri added a comment.
Thanks.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp:847-848
+// - Only the K leading bits of X and Y can be non-zero.
+// - The add is only used by the shr, or by iK truncates.
+// - The lshr type has more than 2 bits.
+Instruction *InstCombinerImpl::foldLShrToOverflow(BinaryOperator &I) {
----------------
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp:880
+ TruncInst *Trunc = dyn_cast<TruncInst>(U);
+ if (!Trunc || Trunc->getType()->getScalarSizeInBits() > ShAmt)
+ return nullptr;
----------------
Is there test coverage when the shift amt isn't the half of the original width?
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp:902-905
+ // Replace the uses of the original add with a zext of the
+ // uaddo's result.
+ if (!Add->hasOneUse())
+ replaceInstUsesWith(*AddInst, Builder.CreateZExt(UAdd, Ty));
----------------
alive2 proof please?
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