summaryrefslogtreecommitdiff
path: root/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2012-12-12 16:52:40 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2012-12-12 16:52:40 +0000
commitb09c146b116359616f6cbd4c8b3328607e00ff42 (patch)
treec81ad3f2747332bbf1dae618dec28a25004746d5 /lib/Analysis/ValueTracking.cpp
parent1afbb517965e29b07cb42e2335d5eadd87de6535 (diff)
downloadllvm-b09c146b116359616f6cbd4c8b3328607e00ff42.tar.gz
llvm-b09c146b116359616f6cbd4c8b3328607e00ff42.tar.bz2
llvm-b09c146b116359616f6cbd4c8b3328607e00ff42.tar.xz
The TargetData is not used for the isPowerOfTwo determination. It has never
been used in the first place. It simply was passed to the function and to the recursive invocations. Simply drop the parameter and update the callers for the new signature. Patch by Saleem Abdulrasool! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169988 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ValueTracking.cpp')
-rw-r--r--lib/Analysis/ValueTracking.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp
index 13313e753b..5a48c3d841 100644
--- a/lib/Analysis/ValueTracking.cpp
+++ b/lib/Analysis/ValueTracking.cpp
@@ -803,8 +803,7 @@ void llvm::ComputeSignBit(Value *V, bool &KnownZero, bool &KnownOne,
/// bit set when defined. For vectors return true if every element is known to
/// be a power of two when defined. Supports values with integer or pointer
/// types and vectors of integers.
-bool llvm::isPowerOfTwo(Value *V, const DataLayout *TD, bool OrZero,
- unsigned Depth) {
+bool llvm::isPowerOfTwo(Value *V, bool OrZero, unsigned Depth) {
if (Constant *C = dyn_cast<Constant>(V)) {
if (C->isNullValue())
return OrZero;
@@ -831,19 +830,19 @@ bool llvm::isPowerOfTwo(Value *V, const DataLayout *TD, bool OrZero,
// A shift of a power of two is a power of two or zero.
if (OrZero && (match(V, m_Shl(m_Value(X), m_Value())) ||
match(V, m_Shr(m_Value(X), m_Value()))))
- return isPowerOfTwo(X, TD, /*OrZero*/true, Depth);
+ return isPowerOfTwo(X, /*OrZero*/true, Depth);
if (ZExtInst *ZI = dyn_cast<ZExtInst>(V))
- return isPowerOfTwo(ZI->getOperand(0), TD, OrZero, Depth);
+ return isPowerOfTwo(ZI->getOperand(0), OrZero, Depth);
if (SelectInst *SI = dyn_cast<SelectInst>(V))
- return isPowerOfTwo(SI->getTrueValue(), TD, OrZero, Depth) &&
- isPowerOfTwo(SI->getFalseValue(), TD, OrZero, Depth);
+ return isPowerOfTwo(SI->getTrueValue(), OrZero, Depth) &&
+ isPowerOfTwo(SI->getFalseValue(), OrZero, Depth);
if (OrZero && match(V, m_And(m_Value(X), m_Value(Y)))) {
// A power of two and'd with anything is a power of two or zero.
- if (isPowerOfTwo(X, TD, /*OrZero*/true, Depth) ||
- isPowerOfTwo(Y, TD, /*OrZero*/true, Depth))
+ if (isPowerOfTwo(X, /*OrZero*/true, Depth) ||
+ isPowerOfTwo(Y, /*OrZero*/true, Depth))
return true;
// X & (-X) is always a power of two or zero.
if (match(X, m_Neg(m_Specific(Y))) || match(Y, m_Neg(m_Specific(X))))
@@ -856,7 +855,7 @@ bool llvm::isPowerOfTwo(Value *V, const DataLayout *TD, bool OrZero,
// copying a sign bit (sdiv int_min, 2).
if (match(V, m_Exact(m_LShr(m_Value(), m_Value()))) ||
match(V, m_Exact(m_UDiv(m_Value(), m_Value())))) {
- return isPowerOfTwo(cast<Operator>(V)->getOperand(0), TD, OrZero, Depth);
+ return isPowerOfTwo(cast<Operator>(V)->getOperand(0), OrZero, Depth);
}
return false;
@@ -1028,9 +1027,9 @@ bool llvm::isKnownNonZero(Value *V, const DataLayout *TD, unsigned Depth) {
}
// The sum of a non-negative number and a power of two is not zero.
- if (XKnownNonNegative && isPowerOfTwo(Y, TD, /*OrZero*/false, Depth))
+ if (XKnownNonNegative && isPowerOfTwo(Y, /*OrZero*/false, Depth))
return true;
- if (YKnownNonNegative && isPowerOfTwo(X, TD, /*OrZero*/false, Depth))
+ if (YKnownNonNegative && isPowerOfTwo(X, /*OrZero*/false, Depth))
return true;
}
// X * Y.