xref: /llvm-project/llvm/test/Transforms/SLPVectorizer/insert-element-build-vector-const.ll (revision ebfdd38228d4e21597642301fb75f5b02ff3ee06)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: %if x86-registered-target %{ opt -S -passes=slp-vectorizer -slp-threshold=0 -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s %}
3; RUN: %if aarch64-registered-target %{ opt -S -passes=slp-vectorizer -slp-threshold=0 -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s %}
4
5define <4 x float> @simple_select(<4 x float> %a, <4 x float> %b, <4 x i32> %c) {
6; CHECK-LABEL: @simple_select(
7; CHECK-NEXT:    [[TMP1:%.*]] = shufflevector <4 x i32> [[C:%.*]], <4 x i32> poison, <2 x i32> <i32 0, i32 1>
8; CHECK-NEXT:    [[TMP2:%.*]] = icmp ne <2 x i32> [[TMP1]], zeroinitializer
9; CHECK-NEXT:    [[TMP3:%.*]] = shufflevector <4 x float> [[A:%.*]], <4 x float> poison, <2 x i32> <i32 0, i32 1>
10; CHECK-NEXT:    [[TMP4:%.*]] = shufflevector <4 x float> [[B:%.*]], <4 x float> poison, <2 x i32> <i32 0, i32 1>
11; CHECK-NEXT:    [[TMP5:%.*]] = select <2 x i1> [[TMP2]], <2 x float> [[TMP3]], <2 x float> [[TMP4]]
12; CHECK-NEXT:    [[TMP7:%.*]] = shufflevector <2 x float> [[TMP5]], <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 poison, i32 poison>
13; CHECK-NEXT:    [[TMP6:%.*]] = shufflevector <4 x float> <float poison, float poison, float 0.000000e+00, float 0.000000e+00>, <4 x float> [[TMP7]], <4 x i32> <i32 4, i32 5, i32 2, i32 3>
14; CHECK-NEXT:    ret <4 x float> [[TMP6]]
15;
16  %c0 = extractelement <4 x i32> %c, i32 0
17  %c1 = extractelement <4 x i32> %c, i32 1
18  %a0 = extractelement <4 x float> %a, i32 0
19  %a1 = extractelement <4 x float> %a, i32 1
20  %b0 = extractelement <4 x float> %b, i32 0
21  %b1 = extractelement <4 x float> %b, i32 1
22  %cmp0 = icmp ne i32 %c0, 0
23  %cmp1 = icmp ne i32 %c1, 0
24  %s0 = select i1 %cmp0, float %a0, float %b0
25  %s1 = select i1 %cmp1, float %a1, float %b1
26  %ra = insertelement <4 x float> <float poison, float poison, float 0.0, float 0.0>, float %s0, i32 0
27  %rb = insertelement <4 x float> %ra, float %s1, i32 1
28  ret <4 x float> %rb
29}
30