[PATCH] D12706: Handle non-constant shifts in computeKnownBits, and use computeKnownBits for constant folding in InstCombine/Simplify
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 23 09:53:24 PDT 2015
majnemer accepted this revision.
majnemer added a comment.
LGTM
================
Comment at: lib/Analysis/ValueTracking.cpp:981
@@ +980,3 @@
+
+ if (ConstantInt *SA = dyn_cast<ConstantInt>(I->getOperand(1))) {
+ unsigned ShiftAmt = SA->getLimitedValue(BitWidth-1);
----------------
Could you make this `auto *SA` ?
================
Comment at: lib/Analysis/ValueTracking.cpp:1015-1021
@@ +1014,9 @@
+
+ // If there are no compatible shift amounts, then we've proven that the shift
+ // amount must be >= the BitWidth, and the result is undefined. We could
+ // return anything we'd like, but we need to make sure the sets of known bits
+ // stay disjoint (it should be better for some other code to actually
+ // propagate the undef than to pick a value here using known bits).
+ if ((KnownZero & KnownOne) != 0)
+ KnownZero.clearAllBits(), KnownOne.clearAllBits();
+}
----------------
InstSimplify already has logic to handle shift amounts `>= bitwidth`. Should we care whether or not `computeKnownBits` gives the same result?
http://reviews.llvm.org/D12706
More information about the llvm-commits
mailing list