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

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 15 17:54:46 PDT 2025


https://github.com/dtcxzyw requested changes to this pull request.

Miscompilation reproducer: https://alive2.llvm.org/ce/z/NiRcHk
```
; bin/opt -passes=bdce reduced.ll -S
define i8 @src(i8 %x) {
  %ext = sext i8 %x to i32
  %rem = srem i32 %ext, 2
  %trunc = trunc i32 %rem to i8
  ret i8 %trunc
}
```
Output:
```
define i8 @src(i8 %x) {
  %ext1 = zext i8 %x to i32
  %rem = srem i32 %ext1, 2
  %trunc = trunc i32 %rem to i8
  ret i8 %trunc
}
```

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


More information about the llvm-commits mailing list