[llvm] [Reland][ValueTracking] Improve Bitcast handling to match SDAG (PR #145223)

Abhishek Kaushik via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 14 02:17:21 PDT 2025


abhishek-kaushik22 wrote:

> shouldn't you be folding this? the zeroinitializer looks like an excess reduction that may be screwing things up
> 
> ```
> define fastcc <2 x i64> @_mm_srai_epi16(<2 x i64> %0) #0 {
>   %2 = bitcast <2 x i64> %0 to <8 x i16>
>   %3 = ashr <8 x i16> %2, splat (i16 1)
>   ret <2 x i64> %3
> }
> ```

The `ashr` instruction remains with instcombine/instsimplify with the previous bad patch
```
bash$ opt -p=instsimplify -S test.ll
; ModuleID = 'test.ll'
source_filename = "test.ll"

define fastcc <2 x i64> @_mm_srai_epi16(<2 x i64> %0) {
  %2 = bitcast <2 x i64> %0 to <8 x i16>
  %3 = ashr <8 x i16> %2, splat (i16 1)
  %4 = bitcast <8 x i16> %3 to <2 x i64>
  ret <2 x i64> %4
}
```

```
bash$ opt -p=instcombine -S test.ll
; ModuleID = 'test.ll'
source_filename = "test.ll"

define fastcc <2 x i64> @_mm_srai_epi16(<2 x i64> %0) {
  %2 = bitcast <2 x i64> %0 to <8 x i16>
  %3 = ashr <8 x i16> %2, splat (i16 1)
  %4 = bitcast <8 x i16> %3 to <2 x i64>
  ret <2 x i64> %4
}
```

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


More information about the llvm-commits mailing list