1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=vector-combine -S %s | FileCheck %s
4 target triple = "aarch64"
6 define i32 @reducebase_v4i32(<4 x i32> %a, <4 x i32> %b) {
7 ; CHECK-LABEL: @reducebase_v4i32(
8 ; CHECK-NEXT: [[X:%.*]] = xor <4 x i32> [[A:%.*]], [[B:%.*]]
9 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[X]])
10 ; CHECK-NEXT: ret i32 [[R]]
12 %x = xor <4 x i32> %a, %b
13 %r = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %x)
17 define i32 @reduceshuffle_onein_v4i32(<4 x i32> %a) {
18 ; CHECK-LABEL: @reduceshuffle_onein_v4i32(
19 ; CHECK-NEXT: [[X:%.*]] = shufflevector <4 x i32> [[A:%.*]], <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
20 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[X]])
21 ; CHECK-NEXT: ret i32 [[R]]
23 %x = shufflevector <4 x i32> %a, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
24 %r = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %x)
28 define i32 @reduceshuffle_onein_const_v4i32(<4 x i32> %a) {
29 ; CHECK-LABEL: @reduceshuffle_onein_const_v4i32(
30 ; CHECK-NEXT: [[S:%.*]] = shufflevector <4 x i32> [[A:%.*]], <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
31 ; CHECK-NEXT: [[X:%.*]] = xor <4 x i32> [[S]], splat (i32 -1)
32 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[X]])
33 ; CHECK-NEXT: ret i32 [[R]]
35 %s = shufflevector <4 x i32> %a, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
36 %x = xor <4 x i32> %s, <i32 -1, i32 -1, i32 -1, i32 -1>
37 %r = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %x)
41 define i32 @reduceshuffle_onein_argin_v4i32(<4 x i32> %a, <4 x i32> %b) {
42 ; CHECK-LABEL: @reduceshuffle_onein_argin_v4i32(
43 ; CHECK-NEXT: [[S:%.*]] = shufflevector <4 x i32> [[A:%.*]], <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
44 ; CHECK-NEXT: [[X:%.*]] = xor <4 x i32> [[S]], [[B:%.*]]
45 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[X]])
46 ; CHECK-NEXT: ret i32 [[R]]
48 %s = shufflevector <4 x i32> %a, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
49 %x = xor <4 x i32> %s, %b
50 %r = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %x)
54 define i32 @reduceshuffle_onein_constnonsplat_v4i32(<4 x i32> %a) {
55 ; CHECK-LABEL: @reduceshuffle_onein_constnonsplat_v4i32(
56 ; CHECK-NEXT: [[S:%.*]] = shufflevector <4 x i32> [[A:%.*]], <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
57 ; CHECK-NEXT: [[X:%.*]] = xor <4 x i32> [[S]], <i32 -1, i32 1, i32 2, i32 3>
58 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[X]])
59 ; CHECK-NEXT: ret i32 [[R]]
61 %s = shufflevector <4 x i32> %a, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
62 %x = xor <4 x i32> %s, <i32 -1, i32 1, i32 2, i32 3>
63 %r = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %x)
67 define i32 @reduceshuffle_twoin_OK_v4i32(<4 x i32> %a, <4 x i32> %b) {
68 ; CHECK-LABEL: @reduceshuffle_twoin_OK_v4i32(
69 ; CHECK-NEXT: [[X:%.*]] = shufflevector <4 x i32> [[A:%.*]], <4 x i32> [[B:%.*]], <4 x i32> <i32 0, i32 1, i32 4, i32 5>
70 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[X]])
71 ; CHECK-NEXT: ret i32 [[R]]
73 %x = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
74 %r = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %x)
78 define i32 @reduceshuffle_twoin_concat_v4i32(<2 x i32> %a, <2 x i32> %b) {
79 ; CHECK-LABEL: @reduceshuffle_twoin_concat_v4i32(
80 ; CHECK-NEXT: [[X:%.*]] = shufflevector <2 x i32> [[A:%.*]], <2 x i32> [[B:%.*]], <4 x i32> <i32 0, i32 1, i32 2, i32 3>
81 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[X]])
82 ; CHECK-NEXT: ret i32 [[R]]
84 %x = shufflevector <2 x i32> %a, <2 x i32> %b, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
85 %r = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %x)
89 define i32 @reduceshuffle_twoin_lowelts_v4i32(<4 x i32> %a, <4 x i32> %b) {
90 ; CHECK-LABEL: @reduceshuffle_twoin_lowelts_v4i32(
91 ; CHECK-NEXT: [[X:%.*]] = shufflevector <4 x i32> [[A:%.*]], <4 x i32> [[B:%.*]], <4 x i32> <i32 0, i32 1, i32 4, i32 5>
92 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[X]])
93 ; CHECK-NEXT: ret i32 [[R]]
95 %x = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 5, i32 1, i32 4>
96 %r = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %x)
100 define i32 @reduceshuffle_twoin_notlowelts_v4i32(<4 x i32> %a, <4 x i32> %b) {
101 ; CHECK-LABEL: @reduceshuffle_twoin_notlowelts_v4i32(
102 ; CHECK-NEXT: [[X:%.*]] = shufflevector <4 x i32> [[A:%.*]], <4 x i32> [[B:%.*]], <4 x i32> <i32 0, i32 1, i32 4, i32 6>
103 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[X]])
104 ; CHECK-NEXT: ret i32 [[R]]
106 %x = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 6, i32 1, i32 4>
107 %r = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %x)
111 define i32 @reduceshuffle_twoin_repeat_v4i32(<4 x i32> %a, <4 x i32> %b) {
112 ; CHECK-LABEL: @reduceshuffle_twoin_repeat_v4i32(
113 ; CHECK-NEXT: [[X:%.*]] = shufflevector <4 x i32> [[A:%.*]], <4 x i32> [[B:%.*]], <4 x i32> <i32 0, i32 4, i32 1, i32 4>
114 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[X]])
115 ; CHECK-NEXT: ret i32 [[R]]
117 %x = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 4, i32 1, i32 4>
118 %r = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %x)
122 define i32 @reduceshuffle_twoin_uneven_v4i32(<4 x i32> %a, <4 x i32> %b) {
123 ; CHECK-LABEL: @reduceshuffle_twoin_uneven_v4i32(
124 ; CHECK-NEXT: [[X:%.*]] = shufflevector <4 x i32> [[A:%.*]], <4 x i32> [[B:%.*]], <4 x i32> <i32 0, i32 1, i32 2, i32 4>
125 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[X]])
126 ; CHECK-NEXT: ret i32 [[R]]
128 %x = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 2, i32 1, i32 4>
129 %r = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %x)
133 define i32 @reduceshuffle_twoin_undef_v4i32(<4 x i32> %a, <4 x i32> %b) {
134 ; CHECK-LABEL: @reduceshuffle_twoin_undef_v4i32(
135 ; CHECK-NEXT: [[X:%.*]] = shufflevector <4 x i32> [[A:%.*]], <4 x i32> [[B:%.*]], <4 x i32> <i32 0, i32 poison, i32 1, i32 5>
136 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[X]])
137 ; CHECK-NEXT: ret i32 [[R]]
139 %x = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 undef, i32 1, i32 5>
140 %r = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %x)
144 define i32 @reduceshuffle_twoin_undef2_v4i32(<4 x i32> %a, <4 x i32> %b) {
145 ; CHECK-LABEL: @reduceshuffle_twoin_undef2_v4i32(
146 ; CHECK-NEXT: [[X:%.*]] = shufflevector <4 x i32> [[A:%.*]], <4 x i32> [[B:%.*]], <4 x i32> <i32 0, i32 1, i32 4, i32 poison>
147 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[X]])
148 ; CHECK-NEXT: ret i32 [[R]]
150 %x = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 4, i32 undef, i32 1, i32 0>
151 %r = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %x)
155 define i32 @reduceshuffle_twoin_multiundef_v4i32(<4 x i32> %a, <4 x i32> %b) {
156 ; CHECK-LABEL: @reduceshuffle_twoin_multiundef_v4i32(
157 ; CHECK-NEXT: [[X:%.*]] = shufflevector <4 x i32> [[A:%.*]], <4 x i32> [[B:%.*]], <4 x i32> <i32 0, i32 1, i32 poison, i32 poison>
158 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[X]])
159 ; CHECK-NEXT: ret i32 [[R]]
161 %x = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 undef, i32 undef, i32 1>
162 %r = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %x)
166 define i32 @reduceshuffle_twoin_extrashuffleuse_v4i32(<4 x i32> %a, <4 x i32> %b) {
167 ; CHECK-LABEL: @reduceshuffle_twoin_extrashuffleuse_v4i32(
168 ; CHECK-NEXT: [[X:%.*]] = shufflevector <4 x i32> [[A:%.*]], <4 x i32> [[B:%.*]], <4 x i32> <i32 0, i32 5, i32 1, i32 4>
169 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[X]])
170 ; CHECK-NEXT: call void @use(<4 x i32> [[X]])
171 ; CHECK-NEXT: ret i32 [[R]]
173 %x = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 5, i32 1, i32 4>
174 %r = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %x)
175 call void @use(<4 x i32> %x)
179 define i32 @reduceshuffle_twoin_extraotheruse_v4i32(<4 x i32> %a, <4 x i32> %b) {
180 ; CHECK-LABEL: @reduceshuffle_twoin_extraotheruse_v4i32(
181 ; CHECK-NEXT: [[S:%.*]] = shufflevector <4 x i32> [[A:%.*]], <4 x i32> [[B:%.*]], <4 x i32> <i32 0, i32 5, i32 1, i32 4>
182 ; CHECK-NEXT: [[X:%.*]] = xor <4 x i32> [[S]], splat (i32 -1)
183 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[X]])
184 ; CHECK-NEXT: call void @use(<4 x i32> [[X]])
185 ; CHECK-NEXT: ret i32 [[R]]
187 %s = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 5, i32 1, i32 4>
188 %x = xor <4 x i32> %s, <i32 -1, i32 -1, i32 -1, i32 -1>
189 %r = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %x)
190 call void @use(<4 x i32> %x)
194 define i32 @reduceshuffle_twoin_splat_v4i32(<4 x i32> %a, <4 x i32> %b, i32 %c) {
195 ; CHECK-LABEL: @reduceshuffle_twoin_splat_v4i32(
196 ; CHECK-NEXT: [[S:%.*]] = shufflevector <4 x i32> [[A:%.*]], <4 x i32> [[B:%.*]], <4 x i32> <i32 0, i32 1, i32 4, i32 5>
197 ; CHECK-NEXT: [[INSERT:%.*]] = insertelement <4 x i32> poison, i32 [[C:%.*]], i32 0
198 ; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <4 x i32> [[INSERT]], <4 x i32> poison, <4 x i32> zeroinitializer
199 ; CHECK-NEXT: [[X:%.*]] = xor <4 x i32> [[S]], [[SPLAT]]
200 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[X]])
201 ; CHECK-NEXT: ret i32 [[R]]
203 %s = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 5, i32 1, i32 4>
204 %insert = insertelement <4 x i32> poison, i32 %c, i32 0
205 %splat = shufflevector <4 x i32> %insert, <4 x i32> poison, <4 x i32> zeroinitializer
206 %x = xor <4 x i32> %s, %splat
207 %r = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %x)
212 define i32 @reducebase_v16i32(<16 x i32> %a, <16 x i32> %b) {
213 ; CHECK-LABEL: @reducebase_v16i32(
214 ; CHECK-NEXT: [[X:%.*]] = xor <16 x i32> [[A:%.*]], [[B:%.*]]
215 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> [[X]])
216 ; CHECK-NEXT: ret i32 [[R]]
218 %x = xor <16 x i32> %a, %b
219 %r = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %x)
223 define i32 @reduceshuffle_onein_v16i32(<16 x i32> %a) {
224 ; CHECK-LABEL: @reduceshuffle_onein_v16i32(
225 ; CHECK-NEXT: [[X:%.*]] = shufflevector <16 x i32> [[A:%.*]], <16 x i32> undef, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
226 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> [[X]])
227 ; CHECK-NEXT: ret i32 [[R]]
229 %x = shufflevector <16 x i32> %a, <16 x i32> undef, <16 x i32> <i32 0, i32 2, i32 4, i32 6, i32 8, i32 10, i32 12, i32 14, i32 1, i32 3, i32 5, i32 7, i32 9, i32 11, i32 13, i32 15>
230 %r = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %x)
234 define i32 @reduceshuffle_onein_ext_v16i32(<16 x i32> %a) {
235 ; CHECK-LABEL: @reduceshuffle_onein_ext_v16i32(
236 ; CHECK-NEXT: [[S:%.*]] = shufflevector <16 x i32> [[A:%.*]], <16 x i32> undef, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
237 ; CHECK-NEXT: [[X:%.*]] = xor <16 x i32> [[S]], splat (i32 -1)
238 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> [[X]])
239 ; CHECK-NEXT: ret i32 [[R]]
241 %s = shufflevector <16 x i32> %a, <16 x i32> undef, <16 x i32> <i32 0, i32 2, i32 4, i32 6, i32 8, i32 10, i32 12, i32 14, i32 1, i32 3, i32 5, i32 7, i32 9, i32 11, i32 13, i32 15>
242 %x = xor <16 x i32> %s, <i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1>
243 %r = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %x)
247 define i32 @reduceshuffle_twoin_concat_v16i32(<8 x i32> %a, <8 x i32> %b) {
248 ; CHECK-LABEL: @reduceshuffle_twoin_concat_v16i32(
249 ; CHECK-NEXT: [[S:%.*]] = shufflevector <8 x i32> [[A:%.*]], <8 x i32> [[B:%.*]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
250 ; CHECK-NEXT: [[X:%.*]] = xor <16 x i32> [[S]], splat (i32 -1)
251 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> [[X]])
252 ; CHECK-NEXT: ret i32 [[R]]
254 %s = shufflevector <8 x i32> %a, <8 x i32> %b, <16 x i32> <i32 0, i32 2, i32 4, i32 6, i32 8, i32 10, i32 12, i32 14, i32 1, i32 3, i32 5, i32 7, i32 9, i32 11, i32 13, i32 15>
255 %x = xor <16 x i32> %s, <i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1>
256 %r = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %x)
260 define i32 @reduceshuffle_twoin_lowelt_v16i32(<16 x i32> %a, <16 x i32> %b) {
261 ; CHECK-LABEL: @reduceshuffle_twoin_lowelt_v16i32(
262 ; CHECK-NEXT: [[S:%.*]] = shufflevector <16 x i32> [[A:%.*]], <16 x i32> [[B:%.*]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23>
263 ; CHECK-NEXT: [[X:%.*]] = xor <16 x i32> [[S]], splat (i32 -1)
264 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> [[X]])
265 ; CHECK-NEXT: ret i32 [[R]]
267 %s = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 0, i32 2, i32 4, i32 6, i32 16, i32 18, i32 20, i32 22, i32 1, i32 3, i32 5, i32 7, i32 17, i32 19, i32 21, i32 23>
268 %x = xor <16 x i32> %s, <i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1>
269 %r = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %x)
273 define i32 @reduceshuffle_twoin_notlowelt_v16i32(<16 x i32> %a, <16 x i32> %b) {
274 ; CHECK-LABEL: @reduceshuffle_twoin_notlowelt_v16i32(
275 ; CHECK-NEXT: [[S:%.*]] = shufflevector <16 x i32> [[A:%.*]], <16 x i32> [[B:%.*]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 21, i32 22, i32 7, i32 24, i32 25, i32 10, i32 27, i32 28, i32 13, i32 30, i32 31>
276 ; CHECK-NEXT: [[X:%.*]] = xor <16 x i32> [[S]], splat (i32 -1)
277 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> [[X]])
278 ; CHECK-NEXT: ret i32 [[R]]
280 %s = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 21, i32 22, i32 7, i32 24, i32 25, i32 10, i32 27, i32 28, i32 13, i32 30, i32 31>
281 %x = xor <16 x i32> %s, <i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1>
282 %r = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %x)
286 define i32 @reduceshuffle_twoin_uneven_v16i32(<16 x i32> %a, <16 x i32> %b) {
287 ; CHECK-LABEL: @reduceshuffle_twoin_uneven_v16i32(
288 ; CHECK-NEXT: [[S:%.*]] = shufflevector <16 x i32> [[A:%.*]], <16 x i32> [[B:%.*]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22>
289 ; CHECK-NEXT: [[X:%.*]] = xor <16 x i32> [[S]], splat (i32 -1)
290 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> [[X]])
291 ; CHECK-NEXT: ret i32 [[R]]
293 %s = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 0, i32 2, i32 4, i32 6, i32 16, i32 18, i32 20, i32 22, i32 1, i32 3, i32 5, i32 7, i32 17, i32 19, i32 21, i32 8>
294 %x = xor <16 x i32> %s, <i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1>
295 %r = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %x)
299 define i32 @reduceshuffle_twoin_shr1_v16i32(<16 x i32> %a, <16 x i32> %b) {
300 ; CHECK-LABEL: @reduceshuffle_twoin_shr1_v16i32(
301 ; CHECK-NEXT: [[S:%.*]] = shufflevector <16 x i32> [[A:%.*]], <16 x i32> [[B:%.*]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23>
302 ; CHECK-NEXT: [[A1:%.*]] = lshr <16 x i32> [[S]], splat (i32 15)
303 ; CHECK-NEXT: [[A2:%.*]] = and <16 x i32> [[A1]], splat (i32 65537)
304 ; CHECK-NEXT: [[A3:%.*]] = mul nuw <16 x i32> [[A2]], splat (i32 65535)
305 ; CHECK-NEXT: [[A4:%.*]] = add <16 x i32> [[A3]], [[S]]
306 ; CHECK-NEXT: [[A5:%.*]] = xor <16 x i32> [[A4]], [[A3]]
307 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> [[A5]])
308 ; CHECK-NEXT: ret i32 [[R]]
310 %s = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 16, i32 17, i32 5, i32 18, i32 19, i32 6, i32 20, i32 21, i32 7, i32 22, i32 23>
311 %a1 = lshr <16 x i32> %s, <i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15>
312 %a2 = and <16 x i32> %a1, <i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537>
313 %a3 = mul nuw <16 x i32> %a2, <i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535>
314 %a4 = add <16 x i32> %a3, %s
315 %a5 = xor <16 x i32> %a4, %a3
316 %r = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %a5)
320 define i32 @reduceshuffle_twoin_shr2_v16i32(<16 x i32> %a, <16 x i32> %b) {
321 ; CHECK-LABEL: @reduceshuffle_twoin_shr2_v16i32(
322 ; CHECK-NEXT: [[S:%.*]] = shufflevector <16 x i32> [[A:%.*]], <16 x i32> [[B:%.*]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23>
323 ; CHECK-NEXT: [[A1:%.*]] = lshr <16 x i32> splat (i32 15), [[S]]
324 ; CHECK-NEXT: [[A2:%.*]] = and <16 x i32> [[A1]], splat (i32 65537)
325 ; CHECK-NEXT: [[A3:%.*]] = mul nuw <16 x i32> [[A2]], splat (i32 65535)
326 ; CHECK-NEXT: [[A4:%.*]] = add <16 x i32> [[A3]], [[S]]
327 ; CHECK-NEXT: [[A5:%.*]] = xor <16 x i32> [[A4]], [[A3]]
328 ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> [[A5]])
329 ; CHECK-NEXT: ret i32 [[R]]
331 %s = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 16, i32 17, i32 5, i32 18, i32 19, i32 6, i32 20, i32 21, i32 7, i32 22, i32 23>
332 %a1 = lshr <16 x i32> <i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15, i32 15>, %s
333 %a2 = and <16 x i32> %a1, <i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537, i32 65537>
334 %a3 = mul nuw <16 x i32> %a2, <i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535, i32 65535>
335 %a4 = add <16 x i32> %a3, %s
336 %a5 = xor <16 x i32> %a4, %a3
337 %r = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %a5)
343 define i16 @reducebase_v16i16(<16 x i16> %a, <16 x i16> %b) {
344 ; CHECK-LABEL: @reducebase_v16i16(
345 ; CHECK-NEXT: [[X:%.*]] = xor <16 x i16> [[A:%.*]], [[B:%.*]]
346 ; CHECK-NEXT: [[R:%.*]] = call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> [[X]])
347 ; CHECK-NEXT: ret i16 [[R]]
349 %x = xor <16 x i16> %a, %b
350 %r = call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> %x)
354 define i16 @reduceshuffle_onein_v16i16(<16 x i16> %a) {
355 ; CHECK-LABEL: @reduceshuffle_onein_v16i16(
356 ; CHECK-NEXT: [[X:%.*]] = shufflevector <16 x i16> [[A:%.*]], <16 x i16> undef, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
357 ; CHECK-NEXT: [[R:%.*]] = call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> [[X]])
358 ; CHECK-NEXT: ret i16 [[R]]
360 %x = shufflevector <16 x i16> %a, <16 x i16> undef, <16 x i32> <i32 0, i32 2, i32 4, i32 6, i32 8, i32 10, i32 12, i32 14, i32 1, i32 3, i32 5, i32 7, i32 9, i32 11, i32 13, i32 15>
361 %r = call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> %x)
365 define i16 @reduceshuffle_onein_ext_v16i16(<16 x i16> %a) {
366 ; CHECK-LABEL: @reduceshuffle_onein_ext_v16i16(
367 ; CHECK-NEXT: [[S:%.*]] = shufflevector <16 x i16> [[A:%.*]], <16 x i16> undef, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
368 ; CHECK-NEXT: [[X:%.*]] = xor <16 x i16> [[S]], splat (i16 -1)
369 ; CHECK-NEXT: [[R:%.*]] = call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> [[X]])
370 ; CHECK-NEXT: ret i16 [[R]]
372 %s = shufflevector <16 x i16> %a, <16 x i16> undef, <16 x i32> <i32 0, i32 2, i32 4, i32 6, i32 8, i32 10, i32 12, i32 14, i32 1, i32 3, i32 5, i32 7, i32 9, i32 11, i32 13, i32 15>
373 %x = xor <16 x i16> %s, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
374 %r = call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> %x)
378 define i16 @reduceshuffle_twoin_concat_v16i16(<8 x i16> %a, <8 x i16> %b) {
379 ; CHECK-LABEL: @reduceshuffle_twoin_concat_v16i16(
380 ; CHECK-NEXT: [[S:%.*]] = shufflevector <8 x i16> [[A:%.*]], <8 x i16> [[B:%.*]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
381 ; CHECK-NEXT: [[X:%.*]] = xor <16 x i16> [[S]], splat (i16 -1)
382 ; CHECK-NEXT: [[R:%.*]] = call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> [[X]])
383 ; CHECK-NEXT: ret i16 [[R]]
385 %s = shufflevector <8 x i16> %a, <8 x i16> %b, <16 x i32> <i32 0, i32 2, i32 4, i32 6, i32 8, i32 10, i32 12, i32 14, i32 1, i32 3, i32 5, i32 7, i32 9, i32 11, i32 13, i32 15>
386 %x = xor <16 x i16> %s, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
387 %r = call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> %x)
391 define i16 @reduceshuffle_twoin_lowelt_v16i16(<16 x i16> %a, <16 x i16> %b) {
392 ; CHECK-LABEL: @reduceshuffle_twoin_lowelt_v16i16(
393 ; CHECK-NEXT: [[S:%.*]] = shufflevector <16 x i16> [[A:%.*]], <16 x i16> [[B:%.*]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23>
394 ; CHECK-NEXT: [[X:%.*]] = xor <16 x i16> [[S]], splat (i16 -1)
395 ; CHECK-NEXT: [[R:%.*]] = call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> [[X]])
396 ; CHECK-NEXT: ret i16 [[R]]
398 %s = shufflevector <16 x i16> %a, <16 x i16> %b, <16 x i32> <i32 0, i32 2, i32 4, i32 6, i32 16, i32 18, i32 20, i32 22, i32 1, i32 3, i32 5, i32 7, i32 17, i32 19, i32 21, i32 23>
399 %x = xor <16 x i16> %s, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
400 %r = call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> %x)
404 define i16 @reduceshuffle_twoin_notlowelt_v16i16(<16 x i16> %a, <16 x i16> %b) {
405 ; CHECK-LABEL: @reduceshuffle_twoin_notlowelt_v16i16(
406 ; CHECK-NEXT: [[S:%.*]] = shufflevector <16 x i16> [[A:%.*]], <16 x i16> [[B:%.*]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 21, i32 22, i32 7, i32 24, i32 25, i32 10, i32 27, i32 28, i32 13, i32 30, i32 31>
407 ; CHECK-NEXT: [[X:%.*]] = xor <16 x i16> [[S]], splat (i16 -1)
408 ; CHECK-NEXT: [[R:%.*]] = call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> [[X]])
409 ; CHECK-NEXT: ret i16 [[R]]
411 %s = shufflevector <16 x i16> %a, <16 x i16> %b, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 21, i32 22, i32 7, i32 24, i32 25, i32 10, i32 27, i32 28, i32 13, i32 30, i32 31>
412 %x = xor <16 x i16> %s, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
413 %r = call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> %x)
417 define i16 @reduceshuffle_twoin_uneven_v16i16(<16 x i16> %a, <16 x i16> %b) {
418 ; CHECK-LABEL: @reduceshuffle_twoin_uneven_v16i16(
419 ; CHECK-NEXT: [[S:%.*]] = shufflevector <16 x i16> [[A:%.*]], <16 x i16> [[B:%.*]], <16 x i32> <i32 0, i32 2, i32 4, i32 6, i32 16, i32 18, i32 20, i32 22, i32 1, i32 3, i32 5, i32 7, i32 17, i32 19, i32 21, i32 8>
420 ; CHECK-NEXT: [[X:%.*]] = xor <16 x i16> [[S]], splat (i16 -1)
421 ; CHECK-NEXT: [[R:%.*]] = call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> [[X]])
422 ; CHECK-NEXT: ret i16 [[R]]
424 %s = shufflevector <16 x i16> %a, <16 x i16> %b, <16 x i32> <i32 0, i32 2, i32 4, i32 6, i32 16, i32 18, i32 20, i32 22, i32 1, i32 3, i32 5, i32 7, i32 17, i32 19, i32 21, i32 8>
425 %x = xor <16 x i16> %s, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
426 %r = call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> %x)
430 define i16 @reduceshuffle_twoin_ext_v16i16(<16 x i16> %a, <16 x i16> %b) {
431 ; CHECK-LABEL: @reduceshuffle_twoin_ext_v16i16(
432 ; CHECK-NEXT: [[S:%.*]] = shufflevector <16 x i16> [[A:%.*]], <16 x i16> [[B:%.*]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23>
433 ; CHECK-NEXT: [[A1:%.*]] = lshr <16 x i16> [[S]], splat (i16 7)
434 ; CHECK-NEXT: [[A2:%.*]] = and <16 x i16> [[A1]], splat (i16 257)
435 ; CHECK-NEXT: [[A3:%.*]] = mul nuw <16 x i16> [[A2]], splat (i16 255)
436 ; CHECK-NEXT: [[A4:%.*]] = add <16 x i16> [[A3]], [[S]]
437 ; CHECK-NEXT: [[A5:%.*]] = xor <16 x i16> [[A4]], [[A3]]
438 ; CHECK-NEXT: [[R:%.*]] = call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> [[A5]])
439 ; CHECK-NEXT: ret i16 [[R]]
441 %s = shufflevector <16 x i16> %a, <16 x i16> %b, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 16, i32 17, i32 5, i32 18, i32 19, i32 6, i32 20, i32 21, i32 7, i32 22, i32 23>
442 %a1 = lshr <16 x i16> %s, <i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7>
443 %a2 = and <16 x i16> %a1, <i16 257, i16 257, i16 257, i16 257, i16 257, i16 257, i16 257, i16 257, i16 257, i16 257, i16 257, i16 257, i16 257, i16 257, i16 257, i16 257>
444 %a3 = mul nuw <16 x i16> %a2, <i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255, i16 255>
445 %a4 = add <16 x i16> %a3, %s
446 %a5 = xor <16 x i16> %a4, %a3
447 %r = call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> %a5)
451 declare void @use(<4 x i32>)
452 declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>)
453 declare i32 @llvm.vector.reduce.add.v16i32(<16 x i32>)
454 declare i16 @llvm.vector.reduce.add.v16i16(<16 x i16>)