[llvm] [DemandedBits] Support non-constant shift amounts (PR #148880)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 30 04:54:39 PDT 2025


================
@@ -183,6 +196,17 @@ void DemandedBits::determineLiveOperandBits(
           AB |= APInt::getHighBitsSet(BitWidth, ShiftAmt+1);
         else if (S->hasNoUnsignedWrap())
           AB |= APInt::getHighBitsSet(BitWidth, ShiftAmt);
+      } else {
+        ComputeKnownBits(BitWidth, UserI->getOperand(1), nullptr);
+        unsigned Min = Known.getMinValue().getLimitedValue(BitWidth - 1);
+        unsigned Max = Known.getMaxValue().getLimitedValue(BitWidth - 1);
----------------
artagnon wrote:

getLimitedValue returns uint64_t, and it would be best not to narrow its type unnecessarily?

https://github.com/llvm/llvm-project/pull/148880


More information about the llvm-commits mailing list