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

Panagiotis Karouzakis via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 24 23:59:01 PDT 2025


================
@@ -76,6 +76,15 @@ void DemandedBits::determineLiveOperandBits(
           computeKnownBits(V2, Known2, DL, &AC, UserI, &DT);
         }
       };
+  auto GetShiftedRange = [&](unsigned Min, unsigned Max, bool ShiftLeft) {
+    using ShiftFn = APInt (APInt::*)(unsigned) const;
+    auto Shift = ShiftLeft ? static_cast<ShiftFn>(&APInt::shl)
+                           : static_cast<ShiftFn>(&APInt::lshr);
+    AB = APInt::getZero(BitWidth);
+    for (unsigned ShiftAmount = Min; ShiftAmount <= Max; ++ShiftAmount) {
----------------
karouzakisp wrote:

What is L? the i128? 128 + 128 < 128 * log(128) = 896

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


More information about the llvm-commits mailing list