[PATCH] D157187: [InstCombine] Propagate the nsw for instruction neg-sub
Allen zhong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 19 23:05:36 PDT 2023
Allen added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp:235-242
(I->hasOneUse() || match(I->getOperand(0), m_ImmConstant()))) {
// `sub` is always negatible.
// However, only do this either if the old `sub` doesn't stick around, or
// it was subtracting from a constant. Otherwise, this isn't profitable.
- return Builder.CreateSub(I->getOperand(1), I->getOperand(0),
- I->getName() + ".neg");
+ // Propagate flag nsw only when the single use of the I to avoid affecting
+ // other users.
+ bool Flag =
----------------
arsenm wrote:
> I think checking hasOneUse twice here is somewhat confusing
Thanks @arsenm for your idea.
I double check the hasOneUse because it may be also here when the **I->getOperand(0)** is a const value.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157187/new/
https://reviews.llvm.org/D157187
More information about the llvm-commits
mailing list