[PATCH] D13253: Tighten known bits for ctpop based on zero input bits

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 12:26:03 PDT 2015


sanjoy added a subscriber: sanjoy.

================
Comment at: lib/Analysis/ValueTracking.cpp:1374
@@ +1373,3 @@
+        // bits known to be zero can't contribute to the population
+        unsigned BitsPossiblySet = BitWidth - KnownZero2.countPopulation();
+        if (BitsPossiblySet) {
----------------
I think you can also do (with better variable naming :) ):


```
X = CLZ(BitsPossiblySet);
KnownZero |= APInt::getHighBitsSet(BitWidth, X);
KnownOne &= ~KnownZero;
```

to avoid the branch, since this would work for `BitsPossiblySet == 0` as well.


http://reviews.llvm.org/D13253





More information about the llvm-commits mailing list