[PATCH] D142271: [ValueTracking] Add KnownBits patterns `xor(x, x - 1)` and `and(x, -x)` for knowing upper bits to be zero

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 20 21:18:17 PST 2023


craig.topper added inline comments.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:1129
 
-    Known ^= Known2;
+    // Common idiom is blsmsk: xor(x, x + -1). This will clear all but lowest
+    // set bit. We can safely say any bit past the lowest known one must be
----------------
The description of blsmsk says "Sets all the lower bits of the destination operand to “1” up to and including lowest set bit (=1) in the source operand".


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142271/new/

https://reviews.llvm.org/D142271



More information about the llvm-commits mailing list