[llvm] [SLP]Improve minbitwidth analysis for shifts. (PR #84356)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 26 10:27:43 PDT 2024


alexey-bataev wrote:

> Hi @alexey-bataev ,
> 
> I think we get a miscompile with this patch Reproduce with:
> 
> ```
> opt bbi-93743_2.ll -mtriple=aarch64 -passes=slp-vectorizer -S -o - -slp-threshold=-100
> ```
> 
> The problem occurs if both inputs to foo are 0xffffffffffffffff.
> 
> Then the
> 
> ```
>   %5 = shufflevector <2 x i128> %3, <2 x i128> %4, <2 x i32> <i32 0, i32 3>
> ```
> 
> in the slp-vectorizer output will result in
> 
> ```
> <0x10000000000000000,poison>
> ```
> 
> due to the "nsw" on the "shl", and that poison then turns the return value from the function to be poison as well.
> 
> [bbi-93743_2.ll.gz](https://github.com/llvm/llvm-project/files/14756140/bbi-93743_2.ll.gz)



> Hi @alexey-bataev ,
> 
> I think we get a miscompile with this patch Reproduce with:
> 
> ```
> opt bbi-93743_2.ll -mtriple=aarch64 -passes=slp-vectorizer -S -o - -slp-threshold=-100
> ```
> 
> The problem occurs if both inputs to foo are 0xffffffffffffffff.
> 
> Then the
> 
> ```
>   %5 = shufflevector <2 x i128> %3, <2 x i128> %4, <2 x i32> <i32 0, i32 3>
> ```
> 
> in the slp-vectorizer output will result in
> 
> ```
> <0x10000000000000000,poison>
> ```
> 
> due to the "nsw" on the "shl", and that poison then turns the return value from the function to be poison as well.
> 
> [bbi-93743_2.ll.gz](https://github.com/llvm/llvm-project/files/14756140/bbi-93743_2.ll.gz)

Fixed in 26dd12871ca8a3dcc5e6920add231af354310088

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


More information about the llvm-commits mailing list