diff options
author | Craig Topper <craig.topper@gmail.com> | 2017-04-14 06:43:34 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2017-04-14 06:43:34 +0000 |
commit | 66df10ff63de98eb6a5a325dd98f45cfb5ccbb5b (patch) | |
tree | 89c4fdc0db4025657528c8213d212df2985cfb66 /llvm | |
parent | 1281deaa00cb47caebb454f72a89763b0e3b9119 (diff) | |
download | bcm5719-llvm-66df10ff63de98eb6a5a325dd98f45cfb5ccbb5b.tar.gz bcm5719-llvm-66df10ff63de98eb6a5a325dd98f45cfb5ccbb5b.zip |
[ValueTracking] Calculate the KnownZeros for Intrinsic::ctpop without using a temporary APInt to count leading zeros on.
The APInt was created from an 'unsigned' and we just wanted to know how many bits the value needed to represent it. We can just use Log2_32 from MathExtras.h to get the info.
llvm-svn: 300309
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 8479bc76c59..d871e83f222 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -1428,11 +1428,8 @@ static void computeKnownBitsFromOperator(const Operator *I, APInt &KnownZero, // We can bound the space the count needs. Also, bits known to be zero // can't contribute to the population. unsigned BitsPossiblySet = BitWidth - KnownZero2.countPopulation(); - unsigned LeadingZeros = - APInt(BitWidth, BitsPossiblySet).countLeadingZeros(); - assert(LeadingZeros <= BitWidth); - KnownZero.setHighBits(LeadingZeros); - KnownOne &= ~KnownZero; + unsigned LowBits = Log2_32(BitsPossiblySet)+1; + KnownZero.setBitsFrom(LowBits); // TODO: we could bound KnownOne using the lower bound on the number // of bits which might be set provided by popcnt KnownOne2. break; |