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

Panagiotis K via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 15 20:14:12 PDT 2025


karouzakisp wrote:

> 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
> }
> ```

@dtcxzyw Can you share the non-reduced src?
I ran the transformation locally, and it doesn't get fired up, ie, 
The sext doesn't get converted to zext. 
So, I don't observe any errors. 

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


More information about the llvm-commits mailing list