[PATCH] D14315: [ValueTracking] Recognize that and(x, add (x, -1)) clears the low bit

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 10 10:04:29 PST 2015


reames added inline comments.

================
Comment at: lib/Analysis/ValueTracking.cpp:1092
@@ +1091,3 @@
+      APInt KnownZero3(BitWidth, 0), KnownOne3(BitWidth, 0);
+      computeKnownBits(Y, KnownZero3, KnownOne3, DL, Depth + 1, Q);
+      if (KnownOne3.countTrailingOnes() > 0)
----------------
sanjoy wrote:
> This is minor:
> 
> I think (but perhaps @majnemer can confirm this) instcombine canonicalizes operands (for commutative operations) so that the LHS is more complex than the RHS, so maybe there is not much value in checking for both "x & (x - 1)" and "(x - 1) & x" -- instcombine will transform the former to the latter.
I don't think it will in this case.  I believe the definition of complexity is on the type of the operand (constant, non-constant, etc..), not the form of the operand.  


http://reviews.llvm.org/D14315





More information about the llvm-commits mailing list