[PATCH] D157187: [InstCombine] Propagate the nsw for instruction neg-sub
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 17 11:13:44 PDT 2023
arsenm 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 =
----------------
I think checking hasOneUse twice here is somewhat confusing
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157187/new/
https://reviews.llvm.org/D157187
More information about the llvm-commits
mailing list