[llvm] [DemandedBits] Support non-constant shift amounts (PR #148880)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 16 08:59:29 PDT 2025


https://github.com/dtcxzyw commented:

Miscompilation reproducer: https://alive2.llvm.org/ce/z/bSBzWM
```
; bin/opt -passes=bdce test.ll -S
define i16 @src(i32 range(i32 0, 2) %x) {
entry:
  %or = or i32 0, 48
  %shl = shl i32 %or, %x
  %trunc = trunc i32 %shl to i16
  ret i16 %trunc
}
```
```
define i16 @tgt(i32 range(i32 0, 2) %x) {
entry:
  %shl = shl i32 0, %x
  %trunc = trunc i32 %shl to i16
  ret i16 %trunc
}
```

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


More information about the llvm-commits mailing list