[llvm] [LLVM] Improve the DemandedBits Analysis (PR #148880)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 15 12:22:30 PDT 2025


================
@@ -183,6 +184,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);
----------------
topperc wrote:

I'm not sure the tests cover any case that wouldn't be covered by

```
unsigned ActiveBits = AOut.getActiveBits);
AB = APInt::getLowBitsSet(BitWidth, ActiveBits);
if (S->hasNoSignedWrap())
  AB |= APInt::getHighBitsSet(BitWidth, BitWidth);
else if (S->hasNoUnsignedWrap())
  AB |= APInt::getHighBitsSet(BitWidth, BitWidth-1);
```

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


More information about the llvm-commits mailing list