[PATCH] D149419: [ValueTracking] Slight refactor to avoid unnecessary work; NFC
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 27 23:22:03 PDT 2023
goldstein.w.n created this revision.
goldstein.w.n added reviewers: StephenFan, nikic, spatel.
Herald added a subscriber: hiraditya.
Herald added a project: All.
goldstein.w.n requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Two changes:
1. Make some cases that conditionally returned unconditional.
2. In cases of `Op0 != 0 || Op1 != 0` its better check `Op1` first as its more likely to be a constant due to canonicalization (so faster to get knownbits of).
Repository:
rG LLVM Github Monorepo
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
@@ -2767,8 +2767,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.
@@ -2833,8 +2833,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);
if (isNonZeroAdd(DemandedElts, Depth, Q, BitWidth, I->getOperand(0),
I->getOperand(1)))
@@ -2935,10 +2935,8 @@
break;
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.517803.patch
Type: text/x-patch
Size: 1804 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230428/3439cd75/attachment.bin>
More information about the llvm-commits
mailing list