[llvm] r300239 - [ValueTracking] Prevent a call to computeKnownBits if we already know the state of the bit we would calculate. Also reuse a temporary APInt instead of creating a new one.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 13 12:04:45 PDT 2017
Author: ctopper
Date: Thu Apr 13 14:04:45 2017
New Revision: 300239
URL: http://llvm.org/viewvc/llvm-project?rev=300239&view=rev
Log:
[ValueTracking] Prevent a call to computeKnownBits if we already know the state of the bit we would calculate. Also reuse a temporary APInt instead of creating a new one.
Modified:
llvm/trunk/lib/Analysis/ValueTracking.cpp
Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=300239&r1=300238&r2=300239&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Thu Apr 13 14:04:45 2017
@@ -918,13 +918,14 @@ static void computeKnownBitsFromOperator
// TODO: This could be generalized to clearing any bit set in y where the
// following bit is known to be unset in y.
Value *Y = nullptr;
- if (match(I->getOperand(0), m_Add(m_Specific(I->getOperand(1)),
- m_Value(Y))) ||
- match(I->getOperand(1), m_Add(m_Specific(I->getOperand(0)),
- m_Value(Y)))) {
- APInt KnownZero3(BitWidth, 0), KnownOne3(BitWidth, 0);
- computeKnownBits(Y, KnownZero3, KnownOne3, Depth + 1, Q);
- if (KnownOne3.countTrailingOnes() > 0)
+ if (!KnownZero[0] && !KnownOne[0] &&
+ (match(I->getOperand(0), m_Add(m_Specific(I->getOperand(1)),
+ m_Value(Y))) ||
+ match(I->getOperand(1), m_Add(m_Specific(I->getOperand(0)),
+ m_Value(Y))))) {
+ KnownZero2.clearAllBits(); KnownOne2.clearAllBits();
+ computeKnownBits(Y, KnownZero2, KnownOne2, Depth + 1, Q);
+ if (KnownOne2.countTrailingOnes() > 0)
KnownZero.setBit(0);
}
break;
More information about the llvm-commits
mailing list