@@ -132,3 +132,290 @@ define <16 x i8> @knownbits_shuffle_add_shift_v32i8(<16 x i8> %arg1, <8 x i16> %
132132declare <2 x i64 > @llvm.ctpop.v2i64 (<2 x i64 >)
133133
134134declare { i32 , i1 } @llvm.uadd.with.overflow.i32 (i32 , i32 )
135+
136+ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
137+ ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
138+
139+ ; PR125228
140+
141+ define <16 x i8 > @knownbits_bitcast_masked_shift (<16 x i8 > %arg ) {
142+ ; CHECK-LABEL: define <16 x i8> @knownbits_bitcast_masked_shift(
143+ ; CHECK-SAME: <16 x i8> [[ARG:%.*]]) {
144+ ; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <16 x i8> [[ARG]] to <8 x i16>
145+ ; CHECK-NEXT: [[LSHR:%.*]] = lshr <8 x i16> [[BITCAST]], splat (i16 4)
146+ ; CHECK-NEXT: [[BITCAST1:%.*]] = bitcast <8 x i16> [[LSHR]] to <16 x i8>
147+ ; CHECK-NEXT: [[AND:%.*]] = and <16 x i8> [[BITCAST1]], splat (i8 3)
148+ ; CHECK-NEXT: [[SHL:%.*]] = shl <8 x i16> [[BITCAST]], splat (i16 4)
149+ ; CHECK-NEXT: [[BITCAST2:%.*]] = bitcast <8 x i16> [[SHL]] to <16 x i8>
150+ ; CHECK-NEXT: [[AND3:%.*]] = and <16 x i8> [[BITCAST2]], splat (i8 48)
151+ ; CHECK-NEXT: [[OR:%.*]] = or disjoint <16 x i8> [[AND]], [[AND3]]
152+ ; CHECK-NEXT: [[BITCAST4:%.*]] = bitcast <16 x i8> [[OR]] to <8 x i16>
153+ ; CHECK-NEXT: [[SHL5:%.*]] = shl nuw <8 x i16> [[BITCAST4]], splat (i16 2)
154+ ; CHECK-NEXT: [[BITCAST6:%.*]] = bitcast <8 x i16> [[SHL5]] to <16 x i8>
155+ ; CHECK-NEXT: ret <16 x i8> [[BITCAST6]]
156+ ;
157+ %bitcast = bitcast <16 x i8 > %arg to <8 x i16 >
158+ %lshr = lshr <8 x i16 > %bitcast , splat (i16 4 )
159+ %bitcast1 = bitcast <8 x i16 > %lshr to <16 x i8 >
160+ %and = and <16 x i8 > %bitcast1 , splat (i8 3 )
161+ %shl = shl <8 x i16 > %bitcast , splat (i16 4 )
162+ %bitcast2 = bitcast <8 x i16 > %shl to <16 x i8 >
163+ %and3 = and <16 x i8 > %bitcast2 , splat (i8 48 )
164+ %or = or disjoint <16 x i8 > %and , %and3
165+ %bitcast4 = bitcast <16 x i8 > %or to <8 x i16 >
166+ %shl5 = shl nuw <8 x i16 > %bitcast4 , splat (i16 2 )
167+ %bitcast6 = bitcast <8 x i16 > %shl5 to <16 x i8 >
168+ %and7 = and <16 x i8 > %bitcast6 , splat (i8 -4 )
169+ ret <16 x i8 > %and7
170+ }
171+
172+ define <16 x i8 > @knownbits_shuffle_bitcast_masked_shift (<8 x i16 > %arg ) {
173+ ; CHECK-LABEL: define <16 x i8> @knownbits_shuffle_bitcast_masked_shift(
174+ ; CHECK-SAME: <8 x i16> [[ARG:%.*]]) {
175+ ; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <8 x i16> [[ARG]] to <16 x i8>
176+ ; CHECK-NEXT: [[SHUFFLEVECTOR:%.*]] = shufflevector <16 x i8> [[BITCAST]], <16 x i8> poison, <16 x i32> <i32 1, i32 0, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6, i32 9, i32 8, i32 11, i32 10, i32 13, i32 12, i32 15, i32 14>
177+ ; CHECK-NEXT: [[BITCAST1:%.*]] = bitcast <16 x i8> [[SHUFFLEVECTOR]] to <8 x i16>
178+ ; CHECK-NEXT: [[LSHR:%.*]] = lshr <8 x i16> [[BITCAST1]], splat (i16 4)
179+ ; CHECK-NEXT: [[BITCAST2:%.*]] = bitcast <8 x i16> [[LSHR]] to <16 x i8>
180+ ; CHECK-NEXT: [[AND:%.*]] = and <16 x i8> [[BITCAST2]], splat (i8 3)
181+ ; CHECK-NEXT: [[SHL:%.*]] = shl <8 x i16> [[BITCAST1]], splat (i16 4)
182+ ; CHECK-NEXT: [[BITCAST3:%.*]] = bitcast <8 x i16> [[SHL]] to <16 x i8>
183+ ; CHECK-NEXT: [[AND4:%.*]] = and <16 x i8> [[BITCAST3]], splat (i8 48)
184+ ; CHECK-NEXT: [[OR:%.*]] = or disjoint <16 x i8> [[AND]], [[AND4]]
185+ ; CHECK-NEXT: [[BITCAST5:%.*]] = bitcast <16 x i8> [[OR]] to <8 x i16>
186+ ; CHECK-NEXT: [[SHL6:%.*]] = shl nuw <8 x i16> [[BITCAST5]], splat (i16 2)
187+ ; CHECK-NEXT: [[BITCAST7:%.*]] = bitcast <8 x i16> [[SHL6]] to <16 x i8>
188+ ; CHECK-NEXT: ret <16 x i8> [[BITCAST7]]
189+ ;
190+ %bitcast = bitcast <8 x i16 > %arg to <16 x i8 >
191+ %shufflevector = shufflevector <16 x i8 > %bitcast , <16 x i8 > poison, <16 x i32 > <i32 1 , i32 0 , i32 3 , i32 2 , i32 5 , i32 4 , i32 7 , i32 6 , i32 9 , i32 8 , i32 11 , i32 10 , i32 13 , i32 12 , i32 15 , i32 14 >
192+ %bitcast1 = bitcast <16 x i8 > %shufflevector to <8 x i16 >
193+ %lshr = lshr <8 x i16 > %bitcast1 , splat (i16 4 )
194+ %bitcast2 = bitcast <8 x i16 > %lshr to <16 x i8 >
195+ %and = and <16 x i8 > %bitcast2 , splat (i8 3 )
196+ %shl = shl <8 x i16 > %bitcast1 , splat (i16 4 )
197+ %bitcast3 = bitcast <8 x i16 > %shl to <16 x i8 >
198+ %and4 = and <16 x i8 > %bitcast3 , splat (i8 48 )
199+ %or = or disjoint <16 x i8 > %and , %and4
200+ %bitcast5 = bitcast <16 x i8 > %or to <8 x i16 >
201+ %shl6 = shl nuw <8 x i16 > %bitcast5 , splat (i16 2 )
202+ %bitcast7 = bitcast <8 x i16 > %shl6 to <16 x i8 >
203+ %and8 = and <16 x i8 > %bitcast7 , splat (i8 -4 )
204+ ret <16 x i8 > %and8
205+ }
206+
207+ define <16 x i8 > @knownbits_shuffle_masked_nibble_shift (<8 x i16 > %arg ) {
208+ ; CHECK-LABEL: define <16 x i8> @knownbits_shuffle_masked_nibble_shift(
209+ ; CHECK-SAME: <8 x i16> [[ARG:%.*]]) {
210+ ; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <8 x i16> [[ARG]] to <16 x i8>
211+ ; CHECK-NEXT: [[AND:%.*]] = and <16 x i8> [[BITCAST]], splat (i8 15)
212+ ; CHECK-NEXT: [[SHUFFLEVECTOR:%.*]] = shufflevector <16 x i8> [[AND]], <16 x i8> poison, <16 x i32> <i32 1, i32 0, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6, i32 9, i32 8, i32 11, i32 10, i32 13, i32 12, i32 15, i32 14>
213+ ; CHECK-NEXT: [[BITCAST1:%.*]] = bitcast <16 x i8> [[SHUFFLEVECTOR]] to <8 x i16>
214+ ; CHECK-NEXT: [[SHL:%.*]] = shl nuw <8 x i16> [[BITCAST1]], splat (i16 4)
215+ ; CHECK-NEXT: [[BITCAST2:%.*]] = bitcast <8 x i16> [[SHL]] to <16 x i8>
216+ ; CHECK-NEXT: ret <16 x i8> [[BITCAST2]]
217+ ;
218+ %bitcast = bitcast <8 x i16 > %arg to <16 x i8 >
219+ %and = and <16 x i8 > %bitcast , splat (i8 15 )
220+ %shufflevector = shufflevector <16 x i8 > %and , <16 x i8 > poison, <16 x i32 > <i32 1 , i32 0 , i32 3 , i32 2 , i32 5 , i32 4 , i32 7 , i32 6 , i32 9 , i32 8 , i32 11 , i32 10 , i32 13 , i32 12 , i32 15 , i32 14 >
221+ %bitcast1 = bitcast <16 x i8 > %shufflevector to <8 x i16 >
222+ %shl = shl nuw <8 x i16 > %bitcast1 , splat (i16 4 )
223+ %bitcast2 = bitcast <8 x i16 > %shl to <16 x i8 >
224+ %and3 = and <16 x i8 > %bitcast2 , splat (i8 -16 )
225+ ret <16 x i8 > %and3
226+ }
227+
228+ define <16 x i8 > @knownbits_reverse_shuffle_masked_shift (<8 x i16 > %arg ) {
229+ ; CHECK-LABEL: define <16 x i8> @knownbits_reverse_shuffle_masked_shift(
230+ ; CHECK-SAME: <8 x i16> [[ARG:%.*]]) {
231+ ; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <8 x i16> [[ARG]] to <16 x i8>
232+ ; CHECK-NEXT: [[AND:%.*]] = and <16 x i8> [[BITCAST]], splat (i8 15)
233+ ; CHECK-NEXT: [[SHUFFLEVECTOR:%.*]] = shufflevector <16 x i8> [[AND]], <16 x i8> poison, <16 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4, i32 11, i32 10, i32 9, i32 8, i32 15, i32 14, i32 13, i32 12>
234+ ; CHECK-NEXT: [[BITCAST1:%.*]] = bitcast <16 x i8> [[SHUFFLEVECTOR]] to <8 x i16>
235+ ; CHECK-NEXT: [[SHL:%.*]] = shl nuw <8 x i16> [[BITCAST1]], splat (i16 4)
236+ ; CHECK-NEXT: [[BITCAST2:%.*]] = bitcast <8 x i16> [[SHL]] to <16 x i8>
237+ ; CHECK-NEXT: ret <16 x i8> [[BITCAST2]]
238+ ;
239+ %bitcast = bitcast <8 x i16 > %arg to <16 x i8 >
240+ %and = and <16 x i8 > %bitcast , splat (i8 15 )
241+ %shufflevector = shufflevector <16 x i8 > %and , <16 x i8 > poison, <16 x i32 > <i32 3 , i32 2 , i32 1 , i32 0 , i32 7 , i32 6 , i32 5 , i32 4 , i32 11 , i32 10 , i32 9 , i32 8 , i32 15 , i32 14 , i32 13 , i32 12 >
242+ %bitcast1 = bitcast <16 x i8 > %shufflevector to <8 x i16 >
243+ %shl = shl nuw <8 x i16 > %bitcast1 , splat (i16 4 )
244+ %bitcast2 = bitcast <8 x i16 > %shl to <16 x i8 >
245+ %and3 = and <16 x i8 > %bitcast2 , splat (i8 -16 )
246+ ret <16 x i8 > %and3
247+ }
248+
249+ define <16 x i8 > @knownbits_interleave_mul_extract_bit (<16 x i8 > %arg ) {
250+ ; CHECK-LABEL: define <16 x i8> @knownbits_interleave_mul_extract_bit(
251+ ; CHECK-SAME: <16 x i8> [[ARG:%.*]]) {
252+ ; CHECK-NEXT: [[SHUFFLEVECTOR:%.*]] = shufflevector <16 x i8> [[ARG]], <16 x i8> <i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison>, <16 x i32> <i32 0, i32 16, i32 1, i32 17, i32 2, i32 18, i32 3, i32 19, i32 4, i32 20, i32 5, i32 21, i32 6, i32 22, i32 7, i32 23>
253+ ; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <16 x i8> [[SHUFFLEVECTOR]] to <8 x i16>
254+ ; CHECK-NEXT: [[MUL:%.*]] = mul nuw <8 x i16> [[BITCAST]], <i16 171, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>
255+ ; CHECK-NEXT: [[LSHR:%.*]] = lshr <8 x i16> [[MUL]], splat (i16 15)
256+ ; CHECK-NEXT: [[BITCAST1:%.*]] = bitcast <8 x i16> [[LSHR]] to <16 x i8>
257+ ; CHECK-NEXT: ret <16 x i8> [[BITCAST1]]
258+ ;
259+ %shufflevector = shufflevector <16 x i8 > %arg , <16 x i8 > <i8 0 , i8 0 , i8 0 , i8 0 , i8 0 , i8 0 , i8 0 , i8 0 , i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison>, <16 x i32 > <i32 0 , i32 16 , i32 1 , i32 17 , i32 2 , i32 18 , i32 3 , i32 19 , i32 4 , i32 20 , i32 5 , i32 21 , i32 6 , i32 22 , i32 7 , i32 23 >
260+ %bitcast = bitcast <16 x i8 > %shufflevector to <8 x i16 >
261+ %mul = mul nuw <8 x i16 > %bitcast , <i16 171 , i16 0 , i16 0 , i16 0 , i16 0 , i16 0 , i16 0 , i16 0 >
262+ %lshr = lshr <8 x i16 > %mul , splat (i16 15 )
263+ %bitcast1 = bitcast <8 x i16 > %lshr to <16 x i8 >
264+ %and = and <16 x i8 > %bitcast1 , splat (i8 1 )
265+ ret <16 x i8 > %and
266+ }
267+
268+ define <16 x i8 > @knownbits_reverse_shuffle_masked_ops (<8 x i16 > %arg ) {
269+ ; CHECK-LABEL: define <16 x i8> @knownbits_reverse_shuffle_masked_ops(
270+ ; CHECK-SAME: <8 x i16> [[ARG:%.*]]) {
271+ ; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <8 x i16> [[ARG]] to <16 x i8>
272+ ; CHECK-NEXT: [[SHUFFLEVECTOR:%.*]] = shufflevector <16 x i8> [[BITCAST]], <16 x i8> poison, <16 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4, i32 11, i32 10, i32 9, i32 8, i32 15, i32 14, i32 13, i32 12>
273+ ; CHECK-NEXT: [[BITCAST1:%.*]] = bitcast <16 x i8> [[SHUFFLEVECTOR]] to <8 x i16>
274+ ; CHECK-NEXT: [[LSHR:%.*]] = lshr <8 x i16> [[BITCAST1]], splat (i16 4)
275+ ; CHECK-NEXT: [[BITCAST2:%.*]] = bitcast <8 x i16> [[LSHR]] to <16 x i8>
276+ ; CHECK-NEXT: [[AND:%.*]] = and <16 x i8> [[BITCAST2]], splat (i8 3)
277+ ; CHECK-NEXT: [[SHL:%.*]] = shl <8 x i16> [[BITCAST1]], splat (i16 4)
278+ ; CHECK-NEXT: [[BITCAST3:%.*]] = bitcast <8 x i16> [[SHL]] to <16 x i8>
279+ ; CHECK-NEXT: [[AND4:%.*]] = and <16 x i8> [[BITCAST3]], splat (i8 48)
280+ ; CHECK-NEXT: [[OR:%.*]] = or disjoint <16 x i8> [[AND]], [[AND4]]
281+ ; CHECK-NEXT: [[BITCAST5:%.*]] = bitcast <16 x i8> [[OR]] to <8 x i16>
282+ ; CHECK-NEXT: [[SHL6:%.*]] = shl nuw <8 x i16> [[BITCAST5]], splat (i16 2)
283+ ; CHECK-NEXT: [[BITCAST7:%.*]] = bitcast <8 x i16> [[SHL6]] to <16 x i8>
284+ ; CHECK-NEXT: ret <16 x i8> [[BITCAST7]]
285+ ;
286+ %bitcast = bitcast <8 x i16 > %arg to <16 x i8 >
287+ %shufflevector = shufflevector <16 x i8 > %bitcast , <16 x i8 > poison, <16 x i32 > <i32 3 , i32 2 , i32 1 , i32 0 , i32 7 , i32 6 , i32 5 , i32 4 , i32 11 , i32 10 , i32 9 , i32 8 , i32 15 , i32 14 , i32 13 , i32 12 >
288+ %bitcast1 = bitcast <16 x i8 > %shufflevector to <8 x i16 >
289+ %lshr = lshr <8 x i16 > %bitcast1 , splat (i16 4 )
290+ %bitcast2 = bitcast <8 x i16 > %lshr to <16 x i8 >
291+ %and = and <16 x i8 > %bitcast2 , splat (i8 3 )
292+ %shl = shl <8 x i16 > %bitcast1 , splat (i16 4 )
293+ %bitcast3 = bitcast <8 x i16 > %shl to <16 x i8 >
294+ %and4 = and <16 x i8 > %bitcast3 , splat (i8 48 )
295+ %or = or disjoint <16 x i8 > %and , %and4
296+ %bitcast5 = bitcast <16 x i8 > %or to <8 x i16 >
297+ %shl6 = shl nuw <8 x i16 > %bitcast5 , splat (i16 2 )
298+ %bitcast7 = bitcast <8 x i16 > %shl6 to <16 x i8 >
299+ %and8 = and <16 x i8 > %bitcast7 , splat (i8 -4 )
300+ ret <16 x i8 > %and8
301+ }
302+
303+ define <16 x i8 > @knownbits_v4i32_to_v16i8_shuffle_masked_pipeline (<4 x i32 > %arg ) {
304+ ; CHECK-LABEL: define <16 x i8> @knownbits_v4i32_to_v16i8_shuffle_masked_pipeline(
305+ ; CHECK-SAME: <4 x i32> [[ARG:%.*]]) {
306+ ; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <4 x i32> [[ARG]] to <16 x i8>
307+ ; CHECK-NEXT: [[SHUFFLEVECTOR:%.*]] = shufflevector <16 x i8> [[BITCAST]], <16 x i8> poison, <16 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4, i32 11, i32 10, i32 9, i32 8, i32 15, i32 14, i32 13, i32 12>
308+ ; CHECK-NEXT: [[BITCAST1:%.*]] = bitcast <16 x i8> [[SHUFFLEVECTOR]] to <8 x i16>
309+ ; CHECK-NEXT: [[SHL:%.*]] = shl <8 x i16> [[BITCAST1]], splat (i16 4)
310+ ; CHECK-NEXT: [[BITCAST2:%.*]] = bitcast <8 x i16> [[SHL]] to <16 x i8>
311+ ; CHECK-NEXT: [[AND:%.*]] = and <16 x i8> [[BITCAST2]], splat (i8 48)
312+ ; CHECK-NEXT: [[LSHR:%.*]] = lshr <8 x i16> [[BITCAST1]], splat (i16 4)
313+ ; CHECK-NEXT: [[BITCAST3:%.*]] = bitcast <8 x i16> [[LSHR]] to <16 x i8>
314+ ; CHECK-NEXT: [[AND4:%.*]] = and <16 x i8> [[BITCAST3]], splat (i8 3)
315+ ; CHECK-NEXT: [[OR:%.*]] = or disjoint <16 x i8> [[AND4]], [[AND]]
316+ ; CHECK-NEXT: [[BITCAST5:%.*]] = bitcast <16 x i8> [[OR]] to <8 x i16>
317+ ; CHECK-NEXT: [[SHL6:%.*]] = shl nuw <8 x i16> [[BITCAST5]], splat (i16 2)
318+ ; CHECK-NEXT: [[BITCAST7:%.*]] = bitcast <8 x i16> [[SHL6]] to <16 x i8>
319+ ; CHECK-NEXT: ret <16 x i8> [[BITCAST7]]
320+ ;
321+ %bitcast = bitcast <4 x i32 > %arg to <16 x i8 >
322+ %shufflevector = shufflevector <16 x i8 > %bitcast , <16 x i8 > poison, <16 x i32 > <i32 3 , i32 2 , i32 1 , i32 0 , i32 7 , i32 6 , i32 5 , i32 4 , i32 11 , i32 10 , i32 9 , i32 8 , i32 15 , i32 14 , i32 13 , i32 12 >
323+ %bitcast1 = bitcast <16 x i8 > %shufflevector to <8 x i16 >
324+ %shl = shl <8 x i16 > %bitcast1 , splat (i16 4 )
325+ %bitcast2 = bitcast <8 x i16 > %shl to <16 x i8 >
326+ %and = and <16 x i8 > %bitcast2 , splat (i8 48 )
327+ %lshr = lshr <8 x i16 > %bitcast1 , splat (i16 4 )
328+ %bitcast3 = bitcast <8 x i16 > %lshr to <16 x i8 >
329+ %and4 = and <16 x i8 > %bitcast3 , splat (i8 3 )
330+ %or = or disjoint <16 x i8 > %and4 , %and
331+ %bitcast5 = bitcast <16 x i8 > %or to <8 x i16 >
332+ %shl6 = shl nuw <8 x i16 > %bitcast5 , splat (i16 2 )
333+ %bitcast7 = bitcast <8 x i16 > %shl6 to <16 x i8 >
334+ %and8 = and <16 x i8 > %bitcast7 , splat (i8 -4 )
335+ ret <16 x i8 > %and8
336+ }
337+
338+ define { i32 , i1 } @knownbits_popcount_add_with_overflow (i32 %arg , i32 %arg1 , i32 %arg2 , i32 %arg3 ) {
339+ ; CHECK-LABEL: define { i32, i1 } @knownbits_popcount_add_with_overflow(
340+ ; CHECK-SAME: i32 [[ARG:%.*]], i32 [[ARG1:%.*]], i32 [[ARG2:%.*]], i32 [[ARG3:%.*]]) {
341+ ; CHECK-NEXT: [[INSERTELEMENT:%.*]] = insertelement <4 x i32> poison, i32 [[ARG2]], i64 0
342+ ; CHECK-NEXT: [[INSERTELEMENT4:%.*]] = insertelement <4 x i32> [[INSERTELEMENT]], i32 [[ARG3]], i64 1
343+ ; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <4 x i32> [[INSERTELEMENT4]] to <2 x i64>
344+ ; CHECK-NEXT: [[CALL:%.*]] = tail call range(i64 0, 65) <2 x i64> @llvm.ctpop.v2i64(<2 x i64> [[BITCAST]])
345+ ; CHECK-NEXT: [[BITCAST5:%.*]] = bitcast <2 x i64> [[CALL]] to <4 x i32>
346+ ; CHECK-NEXT: [[EXTRACTELEMENT:%.*]] = extractelement <4 x i32> [[BITCAST5]], i64 0
347+ ; CHECK-NEXT: [[INSERTELEMENT6:%.*]] = insertelement <4 x i32> poison, i32 [[ARG]], i64 0
348+ ; CHECK-NEXT: [[INSERTELEMENT7:%.*]] = insertelement <4 x i32> [[INSERTELEMENT6]], i32 [[ARG1]], i64 1
349+ ; CHECK-NEXT: [[BITCAST8:%.*]] = bitcast <4 x i32> [[INSERTELEMENT7]] to <2 x i64>
350+ ; CHECK-NEXT: [[CALL9:%.*]] = tail call range(i64 0, 65) <2 x i64> @llvm.ctpop.v2i64(<2 x i64> [[BITCAST8]])
351+ ; CHECK-NEXT: [[BITCAST10:%.*]] = bitcast <2 x i64> [[CALL9]] to <4 x i32>
352+ ; CHECK-NEXT: [[EXTRACTELEMENT11:%.*]] = extractelement <4 x i32> [[BITCAST10]], i64 0
353+ ; CHECK-NEXT: [[CALL12:%.*]] = add nuw nsw i32 [[EXTRACTELEMENT]], [[EXTRACTELEMENT11]]
354+ ; CHECK-NEXT: [[TMP1:%.*]] = insertvalue { i32, i1 } { i32 poison, i1 false }, i32 [[CALL12]], 0
355+ ; CHECK-NEXT: ret { i32, i1 } [[TMP1]]
356+ ;
357+ %insertelement = insertelement <4 x i32 > poison, i32 %arg2 , i64 0
358+ %insertelement4 = insertelement <4 x i32 > %insertelement , i32 %arg3 , i64 1
359+ %bitcast = bitcast <4 x i32 > %insertelement4 to <2 x i64 >
360+ %call = tail call <2 x i64 > @llvm.ctpop.v2i64 (<2 x i64 > %bitcast )
361+ %bitcast5 = bitcast <2 x i64 > %call to <4 x i32 >
362+ %extractelement = extractelement <4 x i32 > %bitcast5 , i64 0
363+ %insertelement6 = insertelement <4 x i32 > poison, i32 %arg , i64 0
364+ %insertelement7 = insertelement <4 x i32 > %insertelement6 , i32 %arg1 , i64 1
365+ %bitcast8 = bitcast <4 x i32 > %insertelement7 to <2 x i64 >
366+ %call9 = tail call <2 x i64 > @llvm.ctpop.v2i64 (<2 x i64 > %bitcast8 )
367+ %bitcast10 = bitcast <2 x i64 > %call9 to <4 x i32 >
368+ %extractelement11 = extractelement <4 x i32 > %bitcast10 , i64 0
369+ %call12 = tail call { i32 , i1 } @llvm.uadd.with.overflow.i32 (i32 %extractelement , i32 %extractelement11 )
370+ ret { i32 , i1 } %call12
371+ }
372+
373+ define <16 x i8 > @knownbits_shuffle_add_shift_v32i8 (<32 x i8 > %arg , <32 x i8 > %arg1 ) local_unnamed_addr #0 {
374+ ; CHECK-LABEL: define <16 x i8> @knownbits_shuffle_add_shift_v32i8(
375+ ; CHECK-SAME: <32 x i8> [[ARG:%.*]], <32 x i8> [[ARG1:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
376+ ; CHECK-NEXT: [[SHUFFLEVECTOR:%.*]] = shufflevector <32 x i8> [[ARG]], <32 x i8> poison, <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>
377+ ; CHECK-NEXT: [[SHUFFLEVECTOR2:%.*]] = shufflevector <32 x i8> [[ARG]], <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
378+ ; CHECK-NEXT: [[ADD:%.*]] = add <16 x i8> [[SHUFFLEVECTOR]], [[SHUFFLEVECTOR2]]
379+ ; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <16 x i8> [[ADD]] to <8 x i16>
380+ ; CHECK-NEXT: [[SHL:%.*]] = shl <8 x i16> [[BITCAST]], splat (i16 8)
381+ ; CHECK-NEXT: [[BITCAST3:%.*]] = bitcast <8 x i16> [[SHL]] to <16 x i8>
382+ ; CHECK-NEXT: [[BITCAST4:%.*]] = bitcast <32 x i8> [[ARG1]] to <16 x i16>
383+ ; CHECK-NEXT: [[SHUFFLEVECTOR5:%.*]] = shufflevector <16 x i16> [[BITCAST4]], <16 x i16> poison, <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
384+ ; CHECK-NEXT: [[SHL6:%.*]] = shl <8 x i16> [[SHUFFLEVECTOR5]], splat (i16 8)
385+ ; CHECK-NEXT: [[BITCAST7:%.*]] = bitcast <8 x i16> [[SHL6]] to <16 x i8>
386+ ; CHECK-NEXT: [[BITCAST8:%.*]] = bitcast <32 x i8> [[ARG1]] to <16 x i16>
387+ ; CHECK-NEXT: [[SHUFFLEVECTOR9:%.*]] = shufflevector <16 x i16> [[BITCAST8]], <16 x i16> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
388+ ; CHECK-NEXT: [[SHL10:%.*]] = shl <8 x i16> [[SHUFFLEVECTOR9]], splat (i16 8)
389+ ; CHECK-NEXT: [[BITCAST11:%.*]] = bitcast <8 x i16> [[SHL10]] to <16 x i8>
390+ ; CHECK-NEXT: [[ADD12:%.*]] = add <16 x i8> [[BITCAST11]], [[BITCAST7]]
391+ ; CHECK-NEXT: [[ADD17:%.*]] = add <16 x i8> [[ADD12]], [[BITCAST3]]
392+ ; CHECK-NEXT: ret <16 x i8> [[ADD17]]
393+ ;
394+ %shufflevector = shufflevector <32 x i8 > %arg , <32 x i8 > poison, <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 >
395+ %shufflevector2 = shufflevector <32 x i8 > %arg , <32 x i8 > poison, <16 x i32 > <i32 16 , i32 17 , i32 18 , i32 19 , i32 20 , i32 21 , i32 22 , i32 23 , i32 24 , i32 25 , i32 26 , i32 27 , i32 28 , i32 29 , i32 30 , i32 31 >
396+ %add = add <16 x i8 > %shufflevector , %shufflevector2
397+ %bitcast = bitcast <16 x i8 > %add to <8 x i16 >
398+ %shl = shl <8 x i16 > %bitcast , splat (i16 8 )
399+ %bitcast3 = bitcast <8 x i16 > %shl to <16 x i8 >
400+ %bitcast4 = bitcast <32 x i8 > %arg1 to <16 x i16 >
401+ %shufflevector5 = shufflevector <16 x i16 > %bitcast4 , <16 x i16 > poison, <8 x i32 > <i32 8 , i32 9 , i32 10 , i32 11 , i32 12 , i32 13 , i32 14 , i32 15 >
402+ %shl6 = shl <8 x i16 > %shufflevector5 , splat (i16 8 )
403+ %bitcast7 = bitcast <8 x i16 > %shl6 to <16 x i8 >
404+ %bitcast8 = bitcast <32 x i8 > %arg1 to <16 x i16 >
405+ %shufflevector9 = shufflevector <16 x i16 > %bitcast8 , <16 x i16 > poison, <8 x i32 > <i32 0 , i32 1 , i32 2 , i32 3 , i32 4 , i32 5 , i32 6 , i32 7 >
406+ %shl10 = shl <8 x i16 > %shufflevector9 , splat (i16 8 )
407+ %bitcast11 = bitcast <8 x i16 > %shl10 to <16 x i8 >
408+ %add12 = add <16 x i8 > %bitcast11 , %bitcast7
409+ %add13 = add <16 x i8 > %add12 , %bitcast3
410+ %bitcast14 = bitcast <16 x i8 > %add12 to <8 x i16 >
411+ %shl15 = shl <8 x i16 > %bitcast14 , splat (i16 8 )
412+ %bitcast16 = bitcast <8 x i16 > %shl15 to <16 x i8 >
413+ %add17 = add <16 x i8 > %add13 , %bitcast16
414+ ret <16 x i8 > %add17
415+ }
416+
417+ declare <2 x i64 > @llvm.ctpop.v2i64 (<2 x i64 >) #0
418+
419+ declare { i32 , i1 } @llvm.uadd.with.overflow.i32 (i32 , i32 ) #0
420+
421+ attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
0 commit comments