[PATCH] D34029: Infer lowest bits of an integer Multiply when the low bits of the operands are known

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 9 12:28:09 PDT 2017


craig.topper added inline comments.


================
Comment at: lib/Analysis/ValueTracking.cpp:382
+                        bottom1.getLoBits(trailBitsKnown);
+    unsigned trailKnown = bottomKnown.getBitWidth() - bottomKnown.countLeadingZeros();
+    trailKnown = std::min(trailKnown, Known.getBitWidth());
----------------
I think this line is equivalent to bottomKnown.getActiveBits().

Also please capitalize all variable names per coding standards.


================
Comment at: lib/Analysis/ValueTracking.cpp:384
+    trailKnown = std::min(trailKnown, Known.getBitWidth());
+    for (unsigned bit = TrailZ; bit < trailKnown; ++bit) {
+      if ((bottomKnown & (1<<bit)) == 0) {
----------------
Shouldn't we be able to do something like this instead of a loop

BottomKnownOne = bottomKnown.getLoBits(trailKnown);
BottomKnownZero = (~bottomKnown).getLoBits(trailKnown);

Known.Zero |= BottomKnownZero;
Known.One |= BottomKnownOne;


================
Comment at: lib/Analysis/ValueTracking.cpp:385
+    for (unsigned bit = TrailZ; bit < trailKnown; ++bit) {
+      if ((bottomKnown & (1<<bit)) == 0) {
+        Known.Zero.setBit(bit);
----------------
Use bottomKnown[bit]


Repository:
  rL LLVM

https://reviews.llvm.org/D34029





More information about the llvm-commits mailing list