[llvm] [DemandedBits] Support non-constant shift amounts (PR #148880)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 25 04:36:46 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) {
----------------
dtcxzyw wrote:
L is the length of integer types. A shift or an OR operation in APInt's slow path takes about k*(L/64) instructions. So the current implementation is O(L^2).
https://github.com/llvm/llvm-project/pull/148880
More information about the llvm-commits
mailing list