[llvm] [KnownBits] Implement knownbits lshr/ashr with exact flag (PR #84254)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 7 01:27:09 PST 2024
================
@@ -367,6 +367,18 @@ KnownBits KnownBits::lshr(const KnownBits &LHS, const KnownBits &RHS,
// Find the common bits from all possible shifts.
APInt MaxValue = RHS.getMaxValue();
unsigned MaxShiftAmount = getMaxShiftAmount(MaxValue, BitWidth);
+
+ // If exact, bound MaxShiftAmount to first known 1 in LHS.
+ if (Exact) {
+ unsigned FirstOne = LHS.countMaxTrailingZeros();
+ if (FirstOne < MinShiftAmount) {
+ // Always poison. Return zero because we don't like returning conflict.
----------------
jayfoad wrote:
Not your fault, but I really don't like that we work so hard everywhere to avoid returning conflict. We should embrace conflict!
https://github.com/llvm/llvm-project/pull/84254
More information about the llvm-commits
mailing list