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

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 29 09:31:58 PDT 2025


================
@@ -76,6 +76,19 @@ 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);
+    uint8_t LoopRange = Max - Min;
----------------
artagnon wrote:

Why is this uint8_t? I don't think the difference between two unsigned quantities fits in a uint8_t in general?

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


More information about the llvm-commits mailing list