[MLIR][LLVM] Avoid narrowing wide constant shift amounts (#220777)

LLVM::ShlOp::fold() used APInt::getZExtValue() to compare a constant
shift
amount against the operand bit width.

For wide integer constants whose active value exceeds 64 bits, such as
an i128
shift amount of 2^100, getZExtValue() asserts before the fold can
determine
that the shift is out of range.

Compare the APInt directly with the operand bit width using uge()
instead. This
preserves the existing behavior for out-of-range shifts, which are
currently
left unfolded, while avoiding the unsafe narrowing.

Add regression coverage for:
- a wide out-of-range shift amount
- the exact bit-width boundary
- the largest valid shift amount

Fixes #220610.

GitOrigin-RevId: 907dd67f959483a8b5dd12aa28dfc3bdb3469311
2 files changed
tree: c6ca73a1dd73f6274ec2f884f94745d281a883e5
  1. benchmark/
  2. cmake/
  3. docs/
  4. examples/
  5. include/
  6. lib/
  7. python/
  8. test/
  9. tools/
  10. unittests/
  11. utils/
  12. .clang-format
  13. .clang-tidy
  14. CMakeLists.txt
  15. LICENSE.TXT
  16. Maintainers.md
  17. README.md
README.md

Multi-Level Intermediate Representation

See https://mlir.llvm.org/ for more information.