[llvm] [SLP][REVEC] Fix ShuffleVector does not consider alternate instruction. (PR #134599)

Han-Kuan Chen via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 7 04:23:38 PDT 2025


================
@@ -1,14 +1,28 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -passes=slp-vectorizer,instcombine -S -slp-revec -slp-max-reg-size=1024 -slp-threshold=-100 %s | FileCheck %s
+; RUN: opt -passes=slp-vectorizer -S -slp-revec -slp-max-reg-size=1024 -slp-threshold=-100 %s | FileCheck %s
+; RUN: opt -passes=slp-vectorizer,instcombine -S -slp-revec -slp-max-reg-size=1024 -slp-threshold=-100 %s | FileCheck %s --check-prefix COMBINE
 
 define void @test1(ptr %in, ptr %out) {
 ; CHECK-LABEL: @test1(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[TMP0:%.*]] = load <8 x i32>, ptr [[IN:%.*]], align 1
-; CHECK-NEXT:    [[TMP1:%.*]] = zext <8 x i32> [[TMP0]] to <8 x i64>
-; CHECK-NEXT:    store <8 x i64> [[TMP1]], ptr [[OUT:%.*]], align 8
+; CHECK-NEXT:    [[OUT:%.*]] = getelementptr inbounds i64, ptr [[OUT1:%.*]], i64 0
+; CHECK-NEXT:    [[TMP2:%.*]] = call <16 x i32> @llvm.vector.insert.v16i32.v8i32(<16 x i32> poison, <8 x i32> [[TMP0]], i64 0)
+; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <16 x i32> [[TMP2]], <16 x i32> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
----------------
HanKuanChen wrote:

We need to gather %0 since %1 and %2 use it. It is <16 x i32> eventually.
```
3.
Operand 0:
    %0 = load <8 x i32>, ptr %in, align 1
    %0 = load <8 x i32>, ptr %in, align 1
Operand 1:
  <8 x i32> poison
  <8 x i32> poison
Scalars:
    %6 = shufflevector <8 x i32> %0, <8 x i32> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
    %5 = shufflevector <8 x i32> %0, <8 x i32> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
State: Vectorize
MainOp:   %6 = shufflevector <8 x i32> %0, <8 x i32> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
AltOp:   %6 = shufflevector <8 x i32> %0, <8 x i32> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
VectorizedValue: NULL
ReuseShuffleIndices: Empty
ReorderIndices:
UserTreeIndex: {User:2 EdgeIdx:0}

4.
Scalars:
    %0 = load <8 x i32>, ptr %in, align 1
    %0 = load <8 x i32>, ptr %in, align 1
State: NeedToGather
MainOp:   %0 = load <8 x i32>, ptr %in, align 1
AltOp:   %0 = load <8 x i32>, ptr %in, align 1
VectorizedValue: NULL
ReuseShuffleIndices: Empty
ReorderIndices:
UserTreeIndex: {User:3 EdgeIdx:0}
```

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


More information about the llvm-commits mailing list