summaryrefslogtreecommitdiff
path: root/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2011-10-27 15:47:25 +0000
committerBob Wilson <bob.wilson@apple.com>2011-10-27 15:47:25 +0000
commit090697321b32fe010db07eb03b6a7af94d8caebd (patch)
treee0ec48141a1a3c8fd176de93cc5c8c13ed6b2289 /lib/Analysis/ValueTracking.cpp
parentc45fe4c1dc9fb7cc3a1d58c7b022832eeb478abb (diff)
downloadllvm-090697321b32fe010db07eb03b6a7af94d8caebd.tar.gz
llvm-090697321b32fe010db07eb03b6a7af94d8caebd.tar.bz2
llvm-090697321b32fe010db07eb03b6a7af94d8caebd.tar.xz
Revert Duncan's r143028 expression folding which appears to be the culprit
behind a compile failure on 483.xalancbmk. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143102 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ValueTracking.cpp')
-rw-r--r--lib/Analysis/ValueTracking.cpp50
1 files changed, 4 insertions, 46 deletions
diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp
index 9ea27036c8..9a234c068b 100644
--- a/lib/Analysis/ValueTracking.cpp
+++ b/lib/Analysis/ValueTracking.cpp
@@ -201,36 +201,9 @@ void llvm::ComputeMaskedBits(Value *V, const APInt &Mask,
ComputeMaskedBits(I->getOperand(1), Mask2, KnownZero, KnownOne, TD,Depth+1);
ComputeMaskedBits(I->getOperand(0), Mask2, KnownZero2, KnownOne2, TD,
Depth+1);
- assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?");
- assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?");
-
- bool isKnownNegative = false;
- bool isKnownNonNegative = false;
- // If the multiplication is known not to overflow, compute the sign bit.
- if (Mask.isNegative() && cast<BinaryOperator>(I)->hasNoSignedWrap()) {
- Value *Op1 = I->getOperand(1), *Op2 = I->getOperand(0);
- if (Op1 == Op2) {
- // The product of a number with itself is non-negative.
- isKnownNonNegative = true;
- } else {
- bool isKnownNonNegative1 = KnownZero.isNegative();
- bool isKnownNonNegative2 = KnownZero2.isNegative();
- bool isKnownNegative1 = KnownOne.isNegative();
- bool isKnownNegative2 = KnownOne2.isNegative();
- // The product of two numbers with the same sign is non-negative.
- isKnownNonNegative = (isKnownNegative1 && isKnownNegative2) ||
- (isKnownNonNegative1 && isKnownNonNegative2);
- // The product of a negative number and a non-negative number is either
- // negative or zero.
- isKnownNegative = (isKnownNegative1 && isKnownNonNegative2 &&
- isKnownNonZero(Op2, TD, Depth)) ||
- (isKnownNegative2 && isKnownNonNegative1 &&
- isKnownNonZero(Op1, TD, Depth));
- assert(!(isKnownNegative && isKnownNonNegative) &&
- "Sign bit both zero and one?");
- }
- }
-
+ assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?");
+ assert((KnownZero2 & KnownOne2) == 0 && "Bits known to be one AND zero?");
+
// If low bits are zero in either operand, output low known-0 bits.
// Also compute a conserative estimate for high known-0 bits.
// More trickiness is possible, but this is sufficient for the
@@ -247,12 +220,6 @@ void llvm::ComputeMaskedBits(Value *V, const APInt &Mask,
KnownZero = APInt::getLowBitsSet(BitWidth, TrailZ) |
APInt::getHighBitsSet(BitWidth, LeadZ);
KnownZero &= Mask;
-
- if (isKnownNonNegative)
- KnownZero.setBit(BitWidth - 1);
- else if (isKnownNegative)
- KnownOne.setBit(BitWidth - 1);
-
return;
}
case Instruction::UDiv: {
@@ -817,7 +784,7 @@ bool llvm::isKnownNonZero(Value *V, const TargetData *TD, unsigned Depth) {
}
// The remaining tests are all recursive, so bail out if we hit the limit.
- if (Depth++ >= MaxDepth)
+ if (Depth++ == MaxDepth)
return false;
unsigned BitWidth = getBitWidth(V->getType(), TD);
@@ -901,15 +868,6 @@ bool llvm::isKnownNonZero(Value *V, const TargetData *TD, unsigned Depth) {
if (YKnownNonNegative && isPowerOfTwo(X, TD, /*OrZero*/false, Depth))
return true;
}
- // X * Y.
- else if (match(V, m_Mul(m_Value(X), m_Value(Y)))) {
- BinaryOperator *BO = cast<BinaryOperator>(V);
- // If X and Y are non-zero then so is X * Y as long as the multiplication
- // does not overflow.
- if ((BO->hasNoSignedWrap() || BO->hasNoUnsignedWrap()) &&
- isKnownNonZero(X, TD, Depth) && isKnownNonZero(Y, TD, Depth))
- return true;
- }
// (C ? X : Y) != 0 if X != 0 and Y != 0.
else if (SelectInst *SI = dyn_cast<SelectInst>(V)) {
if (isKnownNonZero(SI->getTrueValue(), TD, Depth) &&