1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

[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
This commit is contained in:
Craig Topper 2017-04-14 06:43:34 +00:00
parent 638a04cde2
commit 52e32986b7

View File

@ -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;