[llvm] [VectorCombine] foldBitcastShuffle - peek through any residual bitcasts before creating a new bitcast on top (PR #86119)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 26 03:17:03 PDT 2024


RKSimon wrote:

Its mainly a phaseordering problem for #67803 https://github.com/llvm/llvm-project/blob/main/llvm/test/Transforms/PhaseOrdering/X86/pr67803.ll

```
; CHECK-NEXT:    [[TMP2:%.*]] = icmp sgt <8 x i32> [[TMP0]], [[TMP1]]
; CHECK-NEXT:    [[CMP_I21:%.*]] = shufflevector <8 x i1> [[TMP2]], <8 x i1> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
; CHECK-NEXT:    [[SEXT_I22:%.*]] = sext <4 x i1> [[CMP_I21]] to <4 x i32>
; CHECK-NEXT:    [[CMP_I:%.*]] = shufflevector <8 x i1> [[TMP2]], <8 x i1> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
; CHECK-NEXT:    [[SEXT_I:%.*]] = sext <4 x i1> [[CMP_I]] to <4 x i32>
; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <4 x i32> [[SEXT_I22]], <4 x i32> [[SEXT_I]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
```
The aim is to merge all this into `[[TMP3:%.*]] sext <8 x i1> [[TMP2:%.*]] to <8 x i32>` - unfortunately vectorcombine still doesn't see the `[[TMP3]]` line, as its still wrapped in bitcasts, which doesn't get addressed until an InstCombine run after the last VectorCombine run.

Once the peek through bitcasts is working, my intention is to add a vectorcombine fold for `shuffle (ext x), (ext y) -> ext (shuffle x, y)` (we already do something similar for binops), and after all that I can then update #58895 to peek through extract_subvector shuffles to finally be able to convert blendv intrinsics to selects.

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


More information about the llvm-commits mailing list