[PATCH] D149419: [ValueTracking] Slight refactor to avoid unnecessary work; NFC
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 29 11:43:46 PDT 2023
goldstein.w.n updated this revision to Diff 518214.
goldstein.w.n added a comment.
Rebase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149419/new/
https://reviews.llvm.org/D149419
Files:
llvm/lib/Analysis/ValueTracking.cpp
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -2808,8 +2808,8 @@
I->getOperand(1));
case Instruction::Or:
// X | Y != 0 if X != 0 or Y != 0.
- return isKnownNonZero(I->getOperand(0), DemandedElts, Depth, Q) ||
- isKnownNonZero(I->getOperand(1), DemandedElts, Depth, Q);
+ return isKnownNonZero(I->getOperand(1), DemandedElts, Depth, Q) ||
+ isKnownNonZero(I->getOperand(0), DemandedElts, Depth, Q);
case Instruction::SExt:
case Instruction::ZExt:
// ext X != 0 if X != 0.
@@ -2874,8 +2874,8 @@
// non-zero.
auto *BO = cast<OverflowingBinaryOperator>(V);
if (Q.IIQ.hasNoUnsignedWrap(BO))
- return isKnownNonZero(I->getOperand(0), DemandedElts, Depth, Q) ||
- isKnownNonZero(I->getOperand(1), DemandedElts, Depth, Q);
+ return isKnownNonZero(I->getOperand(1), DemandedElts, Depth, Q) ||
+ isKnownNonZero(I->getOperand(0), DemandedElts, Depth, Q);
return isNonZeroAdd(DemandedElts, Depth, Q, BitWidth, I->getOperand(0),
I->getOperand(1), Q.IIQ.hasNoSignedWrap(BO));
@@ -2954,9 +2954,7 @@
case Intrinsic::bitreverse:
case Intrinsic::bswap:
case Intrinsic::ctpop:
- if (isKnownNonZero(II->getArgOperand(0), DemandedElts, Depth, Q))
- return true;
- break;
+ return isKnownNonZero(II->getArgOperand(0), DemandedElts, Depth, Q);
case Intrinsic::ssub_sat:
return isNonZeroSub(DemandedElts, Depth, Q, BitWidth,
II->getArgOperand(0), II->getArgOperand(1));
@@ -2976,10 +2974,8 @@
/*NSW*/ false);
case Intrinsic::umax:
case Intrinsic::uadd_sat:
- if (isKnownNonZero(II->getArgOperand(0), DemandedElts, Depth, Q) ||
- isKnownNonZero(II->getArgOperand(1), DemandedElts, Depth, Q))
- return true;
- break;
+ return isKnownNonZero(II->getArgOperand(1), DemandedElts, Depth, Q) ||
+ isKnownNonZero(II->getArgOperand(0), DemandedElts, Depth, Q);
case Intrinsic::smin:
case Intrinsic::smax: {
auto KnownOpImpliesNonZero = [&](const KnownBits &K) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149419.518214.patch
Type: text/x-patch
Size: 2346 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230429/7668354c/attachment.bin>
More information about the llvm-commits
mailing list