1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=slp-vectorizer -S -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
4 ; See https://reviews.llvm.org/D70068 and https://reviews.llvm.org/D70587 for context
6 ; Checks that vector insertvalues into the struct become SLP seeds.
7 define { <2 x float>, <2 x float> } @StructOfVectors(ptr %Ptr) {
8 ; CHECK-LABEL: @StructOfVectors(
9 ; CHECK-NEXT: [[TMP2:%.*]] = load <4 x float>, ptr [[PTR:%.*]], align 4
10 ; CHECK-NEXT: [[TMP3:%.*]] = fadd fast <4 x float> [[TMP2]], <float 1.100000e+01, float 1.200000e+01, float 1.300000e+01, float 1.400000e+01>
11 ; CHECK-NEXT: [[TMP4:%.*]] = shufflevector <4 x float> [[TMP3]], <4 x float> poison, <2 x i32> <i32 0, i32 1>
12 ; CHECK-NEXT: [[TMP5:%.*]] = shufflevector <4 x float> [[TMP3]], <4 x float> poison, <2 x i32> <i32 2, i32 3>
13 ; CHECK-NEXT: [[RET0:%.*]] = insertvalue { <2 x float>, <2 x float> } undef, <2 x float> [[TMP4]], 0
14 ; CHECK-NEXT: [[RET1:%.*]] = insertvalue { <2 x float>, <2 x float> } [[RET0]], <2 x float> [[TMP5]], 1
15 ; CHECK-NEXT: ret { <2 x float>, <2 x float> } [[RET1]]
17 %L0 = load float, ptr %Ptr
18 %GEP1 = getelementptr inbounds float, ptr %Ptr, i64 1
19 %L1 = load float, ptr %GEP1
20 %GEP2 = getelementptr inbounds float, ptr %Ptr, i64 2
21 %L2 = load float, ptr %GEP2
22 %GEP3 = getelementptr inbounds float, ptr %Ptr, i64 3
23 %L3 = load float, ptr %GEP3
25 %Fadd0 = fadd fast float %L0, 1.1e+01
26 %Fadd1 = fadd fast float %L1, 1.2e+01
27 %Fadd2 = fadd fast float %L2, 1.3e+01
28 %Fadd3 = fadd fast float %L3, 1.4e+01
30 %VecIn0 = insertelement <2 x float> poison, float %Fadd0, i64 0
31 %VecIn1 = insertelement <2 x float> %VecIn0, float %Fadd1, i64 1
33 %VecIn2 = insertelement <2 x float> poison, float %Fadd2, i64 0
34 %VecIn3 = insertelement <2 x float> %VecIn2, float %Fadd3, i64 1
36 %Ret0 = insertvalue {<2 x float>, <2 x float>} undef, <2 x float> %VecIn1, 0
37 %Ret1 = insertvalue {<2 x float>, <2 x float>} %Ret0, <2 x float> %VecIn3, 1
38 ret {<2 x float>, <2 x float>} %Ret1
41 %StructTy = type { float, float}
43 define [2 x %StructTy] @ArrayOfStruct(ptr %Ptr) {
44 ; CHECK-LABEL: @ArrayOfStruct(
45 ; CHECK-NEXT: [[TMP2:%.*]] = load <4 x float>, ptr [[PTR:%.*]], align 4
46 ; CHECK-NEXT: [[TMP3:%.*]] = fadd fast <4 x float> [[TMP2]], <float 1.100000e+01, float 1.200000e+01, float 1.300000e+01, float 1.400000e+01>
47 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <4 x float> [[TMP3]], i32 0
48 ; CHECK-NEXT: [[STRUCTIN0:%.*]] = insertvalue [[STRUCTTY:%.*]] undef, float [[TMP4]], 0
49 ; CHECK-NEXT: [[TMP5:%.*]] = extractelement <4 x float> [[TMP3]], i32 1
50 ; CHECK-NEXT: [[STRUCTIN1:%.*]] = insertvalue [[STRUCTTY]] [[STRUCTIN0]], float [[TMP5]], 1
51 ; CHECK-NEXT: [[TMP6:%.*]] = extractelement <4 x float> [[TMP3]], i32 2
52 ; CHECK-NEXT: [[STRUCTIN2:%.*]] = insertvalue [[STRUCTTY]] undef, float [[TMP6]], 0
53 ; CHECK-NEXT: [[TMP7:%.*]] = extractelement <4 x float> [[TMP3]], i32 3
54 ; CHECK-NEXT: [[STRUCTIN3:%.*]] = insertvalue [[STRUCTTY]] [[STRUCTIN2]], float [[TMP7]], 1
55 ; CHECK-NEXT: [[RET0:%.*]] = insertvalue [2 x %StructTy] undef, [[STRUCTTY]] [[STRUCTIN1]], 0
56 ; CHECK-NEXT: [[RET1:%.*]] = insertvalue [2 x %StructTy] [[RET0]], [[STRUCTTY]] [[STRUCTIN3]], 1
57 ; CHECK-NEXT: ret [2 x %StructTy] [[RET1]]
59 %L0 = load float, ptr %Ptr
60 %GEP1 = getelementptr inbounds float, ptr %Ptr, i64 1
61 %L1 = load float, ptr %GEP1
62 %GEP2 = getelementptr inbounds float, ptr %Ptr, i64 2
63 %L2 = load float, ptr %GEP2
64 %GEP3 = getelementptr inbounds float, ptr %Ptr, i64 3
65 %L3 = load float, ptr %GEP3
67 %Fadd0 = fadd fast float %L0, 1.1e+01
68 %Fadd1 = fadd fast float %L1, 1.2e+01
69 %Fadd2 = fadd fast float %L2, 1.3e+01
70 %Fadd3 = fadd fast float %L3, 1.4e+01
72 %StructIn0 = insertvalue %StructTy undef, float %Fadd0, 0
73 %StructIn1 = insertvalue %StructTy %StructIn0, float %Fadd1, 1
75 %StructIn2 = insertvalue %StructTy undef, float %Fadd2, 0
76 %StructIn3 = insertvalue %StructTy %StructIn2, float %Fadd3, 1
78 %Ret0 = insertvalue [2 x %StructTy] undef, %StructTy %StructIn1, 0
79 %Ret1 = insertvalue [2 x %StructTy] %Ret0, %StructTy %StructIn3, 1
80 ret [2 x %StructTy] %Ret1
83 define {%StructTy, %StructTy} @StructOfStruct(ptr %Ptr) {
84 ; CHECK-LABEL: @StructOfStruct(
85 ; CHECK-NEXT: [[TMP2:%.*]] = load <4 x float>, ptr [[PTR:%.*]], align 4
86 ; CHECK-NEXT: [[TMP3:%.*]] = fadd fast <4 x float> [[TMP2]], <float 1.100000e+01, float 1.200000e+01, float 1.300000e+01, float 1.400000e+01>
87 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <4 x float> [[TMP3]], i32 0
88 ; CHECK-NEXT: [[STRUCTIN0:%.*]] = insertvalue [[STRUCTTY:%.*]] undef, float [[TMP4]], 0
89 ; CHECK-NEXT: [[TMP5:%.*]] = extractelement <4 x float> [[TMP3]], i32 1
90 ; CHECK-NEXT: [[STRUCTIN1:%.*]] = insertvalue [[STRUCTTY]] [[STRUCTIN0]], float [[TMP5]], 1
91 ; CHECK-NEXT: [[TMP6:%.*]] = extractelement <4 x float> [[TMP3]], i32 2
92 ; CHECK-NEXT: [[STRUCTIN2:%.*]] = insertvalue [[STRUCTTY]] undef, float [[TMP6]], 0
93 ; CHECK-NEXT: [[TMP7:%.*]] = extractelement <4 x float> [[TMP3]], i32 3
94 ; CHECK-NEXT: [[STRUCTIN3:%.*]] = insertvalue [[STRUCTTY]] [[STRUCTIN2]], float [[TMP7]], 1
95 ; CHECK-NEXT: [[RET0:%.*]] = insertvalue { [[STRUCTTY]], [[STRUCTTY]] } undef, [[STRUCTTY]] [[STRUCTIN1]], 0
96 ; CHECK-NEXT: [[RET1:%.*]] = insertvalue { [[STRUCTTY]], [[STRUCTTY]] } [[RET0]], [[STRUCTTY]] [[STRUCTIN3]], 1
97 ; CHECK-NEXT: ret { [[STRUCTTY]], [[STRUCTTY]] } [[RET1]]
99 %L0 = load float, ptr %Ptr
100 %GEP1 = getelementptr inbounds float, ptr %Ptr, i64 1
101 %L1 = load float, ptr %GEP1
102 %GEP2 = getelementptr inbounds float, ptr %Ptr, i64 2
103 %L2 = load float, ptr %GEP2
104 %GEP3 = getelementptr inbounds float, ptr %Ptr, i64 3
105 %L3 = load float, ptr %GEP3
107 %Fadd0 = fadd fast float %L0, 1.1e+01
108 %Fadd1 = fadd fast float %L1, 1.2e+01
109 %Fadd2 = fadd fast float %L2, 1.3e+01
110 %Fadd3 = fadd fast float %L3, 1.4e+01
112 %StructIn0 = insertvalue %StructTy undef, float %Fadd0, 0
113 %StructIn1 = insertvalue %StructTy %StructIn0, float %Fadd1, 1
115 %StructIn2 = insertvalue %StructTy undef, float %Fadd2, 0
116 %StructIn3 = insertvalue %StructTy %StructIn2, float %Fadd3, 1
118 %Ret0 = insertvalue {%StructTy, %StructTy} undef, %StructTy %StructIn1, 0
119 %Ret1 = insertvalue {%StructTy, %StructTy} %Ret0, %StructTy %StructIn3, 1
120 ret {%StructTy, %StructTy} %Ret1
123 define {%StructTy, float, float} @NonHomogeneousStruct(ptr %Ptr) {
124 ; CHECK-LABEL: @NonHomogeneousStruct(
125 ; CHECK-NEXT: [[L0:%.*]] = load float, ptr [[PTR:%.*]], align 4
126 ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds float, ptr [[PTR]], i64 1
127 ; CHECK-NEXT: [[L1:%.*]] = load float, ptr [[GEP1]], align 4
128 ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds float, ptr [[PTR]], i64 2
129 ; CHECK-NEXT: [[L2:%.*]] = load float, ptr [[GEP2]], align 4
130 ; CHECK-NEXT: [[GEP3:%.*]] = getelementptr inbounds float, ptr [[PTR]], i64 3
131 ; CHECK-NEXT: [[L3:%.*]] = load float, ptr [[GEP3]], align 4
132 ; CHECK-NEXT: [[FADD0:%.*]] = fadd fast float [[L0]], 1.100000e+01
133 ; CHECK-NEXT: [[FADD1:%.*]] = fadd fast float [[L1]], 1.200000e+01
134 ; CHECK-NEXT: [[FADD2:%.*]] = fadd fast float [[L2]], 1.300000e+01
135 ; CHECK-NEXT: [[FADD3:%.*]] = fadd fast float [[L3]], 1.400000e+01
136 ; CHECK-NEXT: [[STRUCTIN0:%.*]] = insertvalue [[STRUCTTY:%.*]] undef, float [[FADD0]], 0
137 ; CHECK-NEXT: [[STRUCTIN1:%.*]] = insertvalue [[STRUCTTY]] [[STRUCTIN0]], float [[FADD1]], 1
138 ; CHECK-NEXT: [[RET0:%.*]] = insertvalue { [[STRUCTTY]], float, float } undef, [[STRUCTTY]] [[STRUCTIN1]], 0
139 ; CHECK-NEXT: [[RET1:%.*]] = insertvalue { [[STRUCTTY]], float, float } [[RET0]], float [[FADD2]], 1
140 ; CHECK-NEXT: [[RET2:%.*]] = insertvalue { [[STRUCTTY]], float, float } [[RET1]], float [[FADD3]], 2
141 ; CHECK-NEXT: ret { [[STRUCTTY]], float, float } [[RET2]]
143 %L0 = load float, ptr %Ptr
144 %GEP1 = getelementptr inbounds float, ptr %Ptr, i64 1
145 %L1 = load float, ptr %GEP1
146 %GEP2 = getelementptr inbounds float, ptr %Ptr, i64 2
147 %L2 = load float, ptr %GEP2
148 %GEP3 = getelementptr inbounds float, ptr %Ptr, i64 3
149 %L3 = load float, ptr %GEP3
151 %Fadd0 = fadd fast float %L0, 1.1e+01
152 %Fadd1 = fadd fast float %L1, 1.2e+01
153 %Fadd2 = fadd fast float %L2, 1.3e+01
154 %Fadd3 = fadd fast float %L3, 1.4e+01
156 %StructIn0 = insertvalue %StructTy undef, float %Fadd0, 0
157 %StructIn1 = insertvalue %StructTy %StructIn0, float %Fadd1, 1
159 %Ret0 = insertvalue {%StructTy, float, float} undef, %StructTy %StructIn1, 0
160 %Ret1 = insertvalue {%StructTy, float, float} %Ret0, float %Fadd2, 1
161 %Ret2 = insertvalue {%StructTy, float, float} %Ret1, float %Fadd3, 2
162 ret {%StructTy, float, float} %Ret2
165 %Struct1Ty = type { i16, i16 }
166 %Struct2Ty = type { %Struct1Ty, %Struct1Ty}
168 define {%Struct2Ty, %Struct2Ty} @StructOfStructOfStruct(ptr %Ptr) {
169 ; CHECK-LABEL: @StructOfStructOfStruct(
170 ; CHECK-NEXT: [[TMP2:%.*]] = load <8 x i16>, ptr [[PTR:%.*]], align 2
171 ; CHECK-NEXT: [[TMP3:%.*]] = add <8 x i16> [[TMP2]], <i16 1, i16 2, i16 3, i16 4, i16 5, i16 6, i16 7, i16 8>
172 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <8 x i16> [[TMP3]], i32 0
173 ; CHECK-NEXT: [[STRUCTIN0:%.*]] = insertvalue [[STRUCT1TY:%.*]] undef, i16 [[TMP4]], 0
174 ; CHECK-NEXT: [[TMP5:%.*]] = extractelement <8 x i16> [[TMP3]], i32 1
175 ; CHECK-NEXT: [[STRUCTIN1:%.*]] = insertvalue [[STRUCT1TY]] [[STRUCTIN0]], i16 [[TMP5]], 1
176 ; CHECK-NEXT: [[TMP6:%.*]] = extractelement <8 x i16> [[TMP3]], i32 2
177 ; CHECK-NEXT: [[STRUCTIN2:%.*]] = insertvalue [[STRUCT1TY]] undef, i16 [[TMP6]], 0
178 ; CHECK-NEXT: [[TMP7:%.*]] = extractelement <8 x i16> [[TMP3]], i32 3
179 ; CHECK-NEXT: [[STRUCTIN3:%.*]] = insertvalue [[STRUCT1TY]] [[STRUCTIN2]], i16 [[TMP7]], 1
180 ; CHECK-NEXT: [[TMP8:%.*]] = extractelement <8 x i16> [[TMP3]], i32 4
181 ; CHECK-NEXT: [[STRUCTIN4:%.*]] = insertvalue [[STRUCT1TY]] undef, i16 [[TMP8]], 0
182 ; CHECK-NEXT: [[TMP9:%.*]] = extractelement <8 x i16> [[TMP3]], i32 5
183 ; CHECK-NEXT: [[STRUCTIN5:%.*]] = insertvalue [[STRUCT1TY]] [[STRUCTIN4]], i16 [[TMP9]], 1
184 ; CHECK-NEXT: [[TMP10:%.*]] = extractelement <8 x i16> [[TMP3]], i32 6
185 ; CHECK-NEXT: [[STRUCTIN6:%.*]] = insertvalue [[STRUCT1TY]] undef, i16 [[TMP10]], 0
186 ; CHECK-NEXT: [[TMP11:%.*]] = extractelement <8 x i16> [[TMP3]], i32 7
187 ; CHECK-NEXT: [[STRUCTIN7:%.*]] = insertvalue [[STRUCT1TY]] [[STRUCTIN6]], i16 [[TMP11]], 1
188 ; CHECK-NEXT: [[STRUCT2IN0:%.*]] = insertvalue [[STRUCT2TY:%.*]] undef, [[STRUCT1TY]] [[STRUCTIN1]], 0
189 ; CHECK-NEXT: [[STRUCT2IN1:%.*]] = insertvalue [[STRUCT2TY]] [[STRUCT2IN0]], [[STRUCT1TY]] [[STRUCTIN3]], 1
190 ; CHECK-NEXT: [[STRUCT2IN2:%.*]] = insertvalue [[STRUCT2TY]] undef, [[STRUCT1TY]] [[STRUCTIN5]], 0
191 ; CHECK-NEXT: [[STRUCT2IN3:%.*]] = insertvalue [[STRUCT2TY]] [[STRUCT2IN2]], [[STRUCT1TY]] [[STRUCTIN7]], 1
192 ; CHECK-NEXT: [[RET0:%.*]] = insertvalue { [[STRUCT2TY]], [[STRUCT2TY]] } undef, [[STRUCT2TY]] [[STRUCT2IN1]], 0
193 ; CHECK-NEXT: [[RET1:%.*]] = insertvalue { [[STRUCT2TY]], [[STRUCT2TY]] } [[RET0]], [[STRUCT2TY]] [[STRUCT2IN3]], 1
194 ; CHECK-NEXT: ret { [[STRUCT2TY]], [[STRUCT2TY]] } [[RET1]]
196 %L0 = load i16, ptr %Ptr
197 %GEP1 = getelementptr inbounds i16, ptr %Ptr, i64 1
198 %L1 = load i16, ptr %GEP1
199 %GEP2 = getelementptr inbounds i16, ptr %Ptr, i64 2
200 %L2 = load i16, ptr %GEP2
201 %GEP3 = getelementptr inbounds i16, ptr %Ptr, i64 3
202 %L3 = load i16, ptr %GEP3
203 %GEP4 = getelementptr inbounds i16, ptr %Ptr, i64 4
204 %L4 = load i16, ptr %GEP4
205 %GEP5 = getelementptr inbounds i16, ptr %Ptr, i64 5
206 %L5 = load i16, ptr %GEP5
207 %GEP6 = getelementptr inbounds i16, ptr %Ptr, i64 6
208 %L6 = load i16, ptr %GEP6
209 %GEP7 = getelementptr inbounds i16, ptr %Ptr, i64 7
210 %L7 = load i16, ptr %GEP7
212 %Fadd0 = add i16 %L0, 1
213 %Fadd1 = add i16 %L1, 2
214 %Fadd2 = add i16 %L2, 3
215 %Fadd3 = add i16 %L3, 4
216 %Fadd4 = add i16 %L4, 5
217 %Fadd5 = add i16 %L5, 6
218 %Fadd6 = add i16 %L6, 7
219 %Fadd7 = add i16 %L7, 8
221 %StructIn0 = insertvalue %Struct1Ty undef, i16 %Fadd0, 0
222 %StructIn1 = insertvalue %Struct1Ty %StructIn0, i16 %Fadd1, 1
224 %StructIn2 = insertvalue %Struct1Ty undef, i16 %Fadd2, 0
225 %StructIn3 = insertvalue %Struct1Ty %StructIn2, i16 %Fadd3, 1
227 %StructIn4 = insertvalue %Struct1Ty undef, i16 %Fadd4, 0
228 %StructIn5 = insertvalue %Struct1Ty %StructIn4, i16 %Fadd5, 1
230 %StructIn6 = insertvalue %Struct1Ty undef, i16 %Fadd6, 0
231 %StructIn7 = insertvalue %Struct1Ty %StructIn6, i16 %Fadd7, 1
233 %Struct2In0 = insertvalue %Struct2Ty undef, %Struct1Ty %StructIn1, 0
234 %Struct2In1 = insertvalue %Struct2Ty %Struct2In0, %Struct1Ty %StructIn3, 1
236 %Struct2In2 = insertvalue %Struct2Ty undef, %Struct1Ty %StructIn5, 0
237 %Struct2In3 = insertvalue %Struct2Ty %Struct2In2, %Struct1Ty %StructIn7, 1
239 %Ret0 = insertvalue {%Struct2Ty, %Struct2Ty} undef, %Struct2Ty %Struct2In1, 0
240 %Ret1 = insertvalue {%Struct2Ty, %Struct2Ty} %Ret0, %Struct2Ty %Struct2In3, 1
241 ret {%Struct2Ty, %Struct2Ty} %Ret1