From: David Greene Date: Mon, 27 Oct 2008 23:24:03 +0000 (+0000) Subject: Re-apply 55137 with fixes. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=c714f1309049b2fd9e4ab68c8a7b480c63a4be0c;p=oota-llvm.git Re-apply 55137 with fixes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58296 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 3a04f5eb869..c51a719313f 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -509,12 +509,15 @@ void llvm::ComputeMaskedBits(Value *V, const APInt &Mask, ComputeMaskedBits(R, Mask2, KnownZero2, KnownOne2, TD, Depth+1); Mask2 = APInt::getLowBitsSet(BitWidth, KnownZero2.countTrailingOnes()); - KnownOne2.clear(); - KnownZero2.clear(); - ComputeMaskedBits(L, Mask2, KnownZero2, KnownOne2, TD, Depth+1); + + // We need to take the minimum number of known bits + APInt KnownZero3(KnownZero), KnownOne3(KnownOne); + ComputeMaskedBits(L, Mask2, KnownZero3, KnownOne3, TD, Depth+1); + KnownZero = Mask & APInt::getLowBitsSet(BitWidth, - KnownZero2.countTrailingOnes()); + std::min(KnownZero2.countTrailingOnes(), + KnownZero3.countTrailingOnes())); break; } }