[PATCH] D14315: [ValueTracking] Recognize that and(x, add (x, -1)) clears the low bit
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 6 12:10:57 PST 2015
sanjoy accepted this revision.
sanjoy added a comment.
This revision is now accepted and ready to land.
Minor optional to fix nit inline
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)
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.
More information about the llvm-commits