[llvm] [DemandedBits] Support non-constant shift amounts (PR #148880)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 19 23:30:53 PDT 2025
================
@@ -197,6 +218,20 @@ void DemandedBits::determineLiveOperandBits(
// (they must be zero).
if (cast<LShrOperator>(UserI)->isExact())
AB |= APInt::getLowBitsSet(BitWidth, ShiftAmt);
+ } else {
+ ComputeKnownBits(BitWidth, UserI->getOperand(1), nullptr);
+ unsigned Min = Known.getMinValue().getLimitedValue(BitWidth - 1);
+ unsigned Max = Known.getMaxValue().getLimitedValue(BitWidth - 1);
+ // Suppose AOut == 0b0000 1001
+ // [min, max] = [1, 3]
+ // shift by 1 we get 0b0001 00100
----------------
dtcxzyw wrote:
```suggestion
// shift by 1 we get 0b0001 0010
```
https://github.com/llvm/llvm-project/pull/148880
More information about the llvm-commits
mailing list