[llvm] [KnownBits] Fix add() SelfAdd assertion for bitwidths >= 512 (PR #202769)
Paweł Bylica via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 10 08:22:56 PDT 2026
chfast wrote:
Good point, thanks. Moved the fix into `getMaxShiftAmount` as suggested:
```cpp
return MaxValue.extractBitsAsZExtValue(
std::min(Log2_32(BitWidth), MaxValue.getBitWidth()), 0);
```
When the shift amount is narrower than `Log2_32(BitWidth)` bits, its value is necessarily `< BitWidth`, so clamping the extraction width keeps it a valid upper bound. This protects all three shift callers, and `KnownBits::add`'s 8-bit self-add amount is reverted to its original form.
https://github.com/llvm/llvm-project/pull/202769
More information about the llvm-commits
mailing list