1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=SSE2 | FileCheck %s --check-prefixes=CHECK,SSE
3 ; RUN: opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=AVX2 | FileCheck %s --check-prefixes=CHECK,AVX
5 define <2 x i64> @add_constant(i64 %x) {
6 ; CHECK-LABEL: @add_constant(
7 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = add i64 [[X:%.*]], 42
8 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0
9 ; CHECK-NEXT: ret <2 x i64> [[BO]]
11 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
12 %bo = add <2 x i64> %ins, <i64 42, i64 undef>
16 define <2 x i64> @add_constant_not_undef_lane(i64 %x) {
17 ; CHECK-LABEL: @add_constant_not_undef_lane(
18 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = add i64 [[X:%.*]], 42
19 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0
20 ; CHECK-NEXT: ret <2 x i64> [[BO]]
22 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
23 %bo = add <2 x i64> %ins, <i64 42, i64 -42>
27 define <2 x i64> @add_constant_load(ptr %p) {
28 ; CHECK-LABEL: @add_constant_load(
29 ; CHECK-NEXT: [[LD:%.*]] = load i64, ptr [[P:%.*]], align 8
30 ; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[LD]], i32 0
31 ; CHECK-NEXT: [[BO:%.*]] = add <2 x i64> [[INS]], <i64 42, i64 -42>
32 ; CHECK-NEXT: ret <2 x i64> [[BO]]
34 %ld = load i64, ptr %p
35 %ins = insertelement <2 x i64> undef, i64 %ld, i32 0
36 %bo = add <2 x i64> %ins, <i64 42, i64 -42>
40 ; IR flags are not required, but they should propagate.
42 define <4 x i32> @sub_constant_op0(i32 %x) {
43 ; CHECK-LABEL: @sub_constant_op0(
44 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = sub nuw nsw i32 -42, [[X:%.*]]
45 ; CHECK-NEXT: [[BO:%.*]] = insertelement <4 x i32> undef, i32 [[BO_SCALAR]], i64 1
46 ; CHECK-NEXT: ret <4 x i32> [[BO]]
48 %ins = insertelement <4 x i32> undef, i32 %x, i32 1
49 %bo = sub nsw nuw <4 x i32> <i32 undef, i32 -42, i32 undef, i32 undef>, %ins
53 define <4 x i32> @sub_constant_op0_not_undef_lane(i32 %x) {
54 ; CHECK-LABEL: @sub_constant_op0_not_undef_lane(
55 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = sub nuw i32 42, [[X:%.*]]
56 ; CHECK-NEXT: [[BO:%.*]] = insertelement <4 x i32> undef, i32 [[BO_SCALAR]], i64 1
57 ; CHECK-NEXT: ret <4 x i32> [[BO]]
59 %ins = insertelement <4 x i32> undef, i32 %x, i32 1
60 %bo = sub nuw <4 x i32> <i32 1, i32 42, i32 42, i32 -42>, %ins
64 define <8 x i16> @sub_constant_op1(i16 %x) {
65 ; CHECK-LABEL: @sub_constant_op1(
66 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = sub nuw i16 [[X:%.*]], 42
67 ; CHECK-NEXT: [[BO:%.*]] = insertelement <8 x i16> undef, i16 [[BO_SCALAR]], i64 0
68 ; CHECK-NEXT: ret <8 x i16> [[BO]]
70 %ins = insertelement <8 x i16> undef, i16 %x, i32 0
71 %bo = sub nuw <8 x i16> %ins, <i16 42, i16 undef, i16 undef, i16 undef, i16 undef, i16 undef, i16 undef, i16 undef>
75 define <8 x i16> @sub_constant_op1_not_undef_lane(i16 %x) {
76 ; CHECK-LABEL: @sub_constant_op1_not_undef_lane(
77 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = sub nuw i16 [[X:%.*]], 42
78 ; CHECK-NEXT: [[BO:%.*]] = insertelement <8 x i16> undef, i16 [[BO_SCALAR]], i64 0
79 ; CHECK-NEXT: ret <8 x i16> [[BO]]
81 %ins = insertelement <8 x i16> undef, i16 %x, i32 0
82 %bo = sub nuw <8 x i16> %ins, <i16 42, i16 -42, i16 0, i16 1, i16 -2, i16 3, i16 -4, i16 5>
86 define <16 x i8> @mul_constant(i8 %x) {
87 ; CHECK-LABEL: @mul_constant(
88 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = mul i8 [[X:%.*]], -42
89 ; CHECK-NEXT: [[BO:%.*]] = insertelement <16 x i8> <i8 undef, i8 undef, i8 0, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef>, i8 [[BO_SCALAR]], i64 2
90 ; CHECK-NEXT: ret <16 x i8> [[BO]]
92 %ins = insertelement <16 x i8> undef, i8 %x, i32 2
93 %bo = mul <16 x i8> %ins, <i8 undef, i8 undef, i8 -42, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef, i8 undef>
97 define <3 x i64> @mul_constant_not_undef_lane(i64 %x) {
98 ; CHECK-LABEL: @mul_constant_not_undef_lane(
99 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = mul i64 [[X:%.*]], -42
100 ; CHECK-NEXT: [[BO:%.*]] = insertelement <3 x i64> <i64 0, i64 undef, i64 0>, i64 [[BO_SCALAR]], i64 2
101 ; CHECK-NEXT: ret <3 x i64> [[BO]]
103 %ins = insertelement <3 x i64> undef, i64 %x, i32 2
104 %bo = mul <3 x i64> %ins, <i64 42, i64 undef, i64 -42>
108 define <16 x i8> @mul_constant_multiuse(i8 %a0, <16 x i8> %a1) {
109 ; SSE-LABEL: @mul_constant_multiuse(
110 ; SSE-NEXT: [[INS:%.*]] = insertelement <16 x i8> <i8 undef, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, i8 [[A0:%.*]], i32 0
111 ; SSE-NEXT: [[MUL:%.*]] = mul <16 x i8> [[INS]], <i8 3, i8 7, i8 9, i8 11, i8 13, i8 15, i8 17, i8 19, i8 21, i8 23, i8 25, i8 27, i8 29, i8 31, i8 33, i8 35>
112 ; SSE-NEXT: [[AND:%.*]] = and <16 x i8> [[INS]], [[A1:%.*]]
113 ; SSE-NEXT: [[XOR:%.*]] = xor <16 x i8> [[AND]], [[MUL]]
114 ; SSE-NEXT: ret <16 x i8> [[XOR]]
116 ; AVX-LABEL: @mul_constant_multiuse(
117 ; AVX-NEXT: [[INS:%.*]] = insertelement <16 x i8> <i8 undef, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, i8 [[A0:%.*]], i32 0
118 ; AVX-NEXT: [[MUL_SCALAR:%.*]] = mul i8 [[A0]], 3
119 ; AVX-NEXT: [[MUL:%.*]] = insertelement <16 x i8> <i8 undef, i8 7, i8 18, i8 33, i8 52, i8 75, i8 102, i8 -123, i8 -88, i8 -49, i8 -6, i8 41, i8 92, i8 -109, i8 -50, i8 13>, i8 [[MUL_SCALAR]], i64 0
120 ; AVX-NEXT: [[AND:%.*]] = and <16 x i8> [[INS]], [[A1:%.*]]
121 ; AVX-NEXT: [[XOR:%.*]] = xor <16 x i8> [[AND]], [[MUL]]
122 ; AVX-NEXT: ret <16 x i8> [[XOR]]
124 %ins = insertelement <16 x i8> <i8 undef, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, i8 %a0, i32 0
125 %mul = mul <16 x i8> %ins, <i8 3, i8 7, i8 9, i8 11, i8 13, i8 15, i8 17, i8 19, i8 21, i8 23, i8 25, i8 27, i8 29, i8 31, i8 33, i8 35>
126 %and = and <16 x i8> %ins, %a1
127 %xor = xor <16 x i8> %and, %mul
131 define <2 x i64> @shl_constant_op0(i64 %x) {
132 ; CHECK-LABEL: @shl_constant_op0(
133 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = shl i64 2, [[X:%.*]]
134 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 1
135 ; CHECK-NEXT: ret <2 x i64> [[BO]]
137 %ins = insertelement <2 x i64> undef, i64 %x, i32 1
138 %bo = shl <2 x i64> <i64 undef, i64 2>, %ins
142 define <2 x i64> @shl_constant_op0_not_undef_lane(i64 %x) {
143 ; CHECK-LABEL: @shl_constant_op0_not_undef_lane(
144 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = shl i64 2, [[X:%.*]]
145 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 1
146 ; CHECK-NEXT: ret <2 x i64> [[BO]]
148 %ins = insertelement <2 x i64> undef, i64 %x, i32 1
149 %bo = shl <2 x i64> <i64 5, i64 2>, %ins
153 define <2 x i64> @shl_constant_op0_load(ptr %p) {
154 ; CHECK-LABEL: @shl_constant_op0_load(
155 ; CHECK-NEXT: [[LD:%.*]] = load i64, ptr [[P:%.*]], align 8
156 ; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[LD]], i32 1
157 ; CHECK-NEXT: [[BO:%.*]] = shl <2 x i64> <i64 undef, i64 2>, [[INS]]
158 ; CHECK-NEXT: ret <2 x i64> [[BO]]
160 %ld = load i64, ptr %p
161 %ins = insertelement <2 x i64> undef, i64 %ld, i32 1
162 %bo = shl <2 x i64> <i64 undef, i64 2>, %ins
166 define <4 x i32> @shl_constant_op0_multiuse(i32 %a0, <4 x i32> %a1) {
167 ; CHECK-LABEL: @shl_constant_op0_multiuse(
168 ; CHECK-NEXT: [[INS:%.*]] = insertelement <4 x i32> <i32 undef, i32 1, i32 2, i32 3>, i32 [[A0:%.*]], i32 0
169 ; CHECK-NEXT: [[MUL_SCALAR:%.*]] = shl i32 [[A0]], 3
170 ; CHECK-NEXT: [[MUL:%.*]] = insertelement <4 x i32> <i32 0, i32 16, i32 64, i32 192>, i32 [[MUL_SCALAR]], i64 0
171 ; CHECK-NEXT: [[AND:%.*]] = and <4 x i32> [[INS]], [[A1:%.*]]
172 ; CHECK-NEXT: [[XOR:%.*]] = xor <4 x i32> [[AND]], [[MUL]]
173 ; CHECK-NEXT: ret <4 x i32> [[XOR]]
175 %ins = insertelement <4 x i32> <i32 undef, i32 1, i32 2, i32 3>, i32 %a0, i32 0
176 %mul = shl <4 x i32> %ins, <i32 3, i32 4, i32 5, i32 6>
177 %and = and <4 x i32> %ins, %a1
178 %xor = xor <4 x i32> %and, %mul
182 define <2 x i64> @shl_constant_op1(i64 %x) {
183 ; CHECK-LABEL: @shl_constant_op1(
184 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = shl nuw i64 [[X:%.*]], 5
185 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> <i64 0, i64 poison>, i64 [[BO_SCALAR]], i64 0
186 ; CHECK-NEXT: ret <2 x i64> [[BO]]
188 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
189 %bo = shl nuw <2 x i64> %ins, <i64 5, i64 undef>
193 define <2 x i64> @shl_constant_op1_not_undef_lane(i64 %x) {
194 ; CHECK-LABEL: @shl_constant_op1_not_undef_lane(
195 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = shl nuw i64 [[X:%.*]], 5
196 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> zeroinitializer, i64 [[BO_SCALAR]], i64 0
197 ; CHECK-NEXT: ret <2 x i64> [[BO]]
199 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
200 %bo = shl nuw <2 x i64> %ins, <i64 5, i64 2>
204 define <2 x i64> @shl_constant_op1_load(ptr %p) {
205 ; CHECK-LABEL: @shl_constant_op1_load(
206 ; CHECK-NEXT: [[LD:%.*]] = load i64, ptr [[P:%.*]], align 8
207 ; CHECK-NEXT: [[INS:%.*]] = insertelement <2 x i64> undef, i64 [[LD]], i32 0
208 ; CHECK-NEXT: [[BO:%.*]] = shl nuw <2 x i64> [[INS]], <i64 5, i64 2>
209 ; CHECK-NEXT: ret <2 x i64> [[BO]]
211 %ld = load i64, ptr %p
212 %ins = insertelement <2 x i64> undef, i64 %ld, i32 0
213 %bo = shl nuw <2 x i64> %ins, <i64 5, i64 2>
217 define <2 x i64> @ashr_constant_op0(i64 %x) {
218 ; CHECK-LABEL: @ashr_constant_op0(
219 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = ashr exact i64 2, [[X:%.*]]
220 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 1
221 ; CHECK-NEXT: ret <2 x i64> [[BO]]
223 %ins = insertelement <2 x i64> undef, i64 %x, i32 1
224 %bo = ashr exact <2 x i64> <i64 undef, i64 2>, %ins
228 define <2 x i64> @ashr_constant_op0_not_undef_lane(i64 %x) {
229 ; CHECK-LABEL: @ashr_constant_op0_not_undef_lane(
230 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = ashr exact i64 2, [[X:%.*]]
231 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 1
232 ; CHECK-NEXT: ret <2 x i64> [[BO]]
234 %ins = insertelement <2 x i64> undef, i64 %x, i32 1
235 %bo = ashr exact <2 x i64> <i64 5, i64 2>, %ins
239 define <2 x i64> @ashr_constant_op1(i64 %x) {
240 ; CHECK-LABEL: @ashr_constant_op1(
241 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = ashr i64 [[X:%.*]], 5
242 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> <i64 0, i64 poison>, i64 [[BO_SCALAR]], i64 0
243 ; CHECK-NEXT: ret <2 x i64> [[BO]]
245 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
246 %bo = ashr <2 x i64> %ins, <i64 5, i64 undef>
250 define <2 x i64> @ashr_constant_op1_not_undef_lane(i64 %x) {
251 ; CHECK-LABEL: @ashr_constant_op1_not_undef_lane(
252 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = ashr i64 [[X:%.*]], 5
253 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> zeroinitializer, i64 [[BO_SCALAR]], i64 0
254 ; CHECK-NEXT: ret <2 x i64> [[BO]]
256 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
257 %bo = ashr <2 x i64> %ins, <i64 5, i64 2>
261 define <2 x i64> @lshr_constant_op0(i64 %x) {
262 ; CHECK-LABEL: @lshr_constant_op0(
263 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = lshr i64 5, [[X:%.*]]
264 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
265 ; CHECK-NEXT: ret <2 x i64> [[BO]]
267 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
268 %bo = lshr <2 x i64> <i64 5, i64 undef>, %ins
272 define <2 x i64> @lshr_constant_op0_not_undef_lane(i64 %x) {
273 ; CHECK-LABEL: @lshr_constant_op0_not_undef_lane(
274 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = lshr i64 5, [[X:%.*]]
275 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
276 ; CHECK-NEXT: ret <2 x i64> [[BO]]
278 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
279 %bo = lshr <2 x i64> <i64 5, i64 2>, %ins
283 define <2 x i64> @lshr_constant_op1(i64 %x) {
284 ; CHECK-LABEL: @lshr_constant_op1(
285 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = lshr exact i64 [[X:%.*]], 2
286 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> <i64 poison, i64 0>, i64 [[BO_SCALAR]], i64 1
287 ; CHECK-NEXT: ret <2 x i64> [[BO]]
289 %ins = insertelement <2 x i64> undef, i64 %x, i32 1
290 %bo = lshr exact <2 x i64> %ins, <i64 undef, i64 2>
294 define <2 x i64> @lshr_constant_op1_not_undef_lane(i64 %x) {
295 ; CHECK-LABEL: @lshr_constant_op1_not_undef_lane(
296 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = lshr exact i64 [[X:%.*]], 2
297 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> zeroinitializer, i64 [[BO_SCALAR]], i64 1
298 ; CHECK-NEXT: ret <2 x i64> [[BO]]
300 %ins = insertelement <2 x i64> undef, i64 %x, i32 1
301 %bo = lshr exact <2 x i64> %ins, <i64 5, i64 2>
305 define <2 x i64> @urem_constant_op0(i64 %x) {
306 ; CHECK-LABEL: @urem_constant_op0(
307 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = urem i64 5, [[X:%.*]]
308 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
309 ; CHECK-NEXT: ret <2 x i64> [[BO]]
311 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
312 %bo = urem <2 x i64> <i64 5, i64 undef>, %ins
316 define <2 x i64> @urem_constant_op0_not_undef_lane(i64 %x) {
317 ; CHECK-LABEL: @urem_constant_op0_not_undef_lane(
318 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = urem i64 5, [[X:%.*]]
319 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
320 ; CHECK-NEXT: ret <2 x i64> [[BO]]
322 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
323 %bo = urem <2 x i64> <i64 5, i64 2>, %ins
327 define <2 x i64> @urem_constant_op1(i64 %x) {
328 ; CHECK-LABEL: @urem_constant_op1(
329 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = urem i64 [[X:%.*]], 2
330 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> <i64 poison, i64 0>, i64 [[BO_SCALAR]], i64 1
331 ; CHECK-NEXT: ret <2 x i64> [[BO]]
333 %ins = insertelement <2 x i64> undef, i64 %x, i32 1
334 %bo = urem <2 x i64> %ins, <i64 undef, i64 2>
338 define <2 x i64> @urem_constant_op1_not_undef_lane(i64 %x) {
339 ; CHECK-LABEL: @urem_constant_op1_not_undef_lane(
340 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = urem i64 [[X:%.*]], 2
341 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> zeroinitializer, i64 [[BO_SCALAR]], i64 1
342 ; CHECK-NEXT: ret <2 x i64> [[BO]]
344 %ins = insertelement <2 x i64> undef, i64 %x, i32 1
345 %bo = urem <2 x i64> %ins, <i64 5, i64 2>
349 define <2 x i64> @srem_constant_op0(i64 %x) {
350 ; CHECK-LABEL: @srem_constant_op0(
351 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = srem i64 5, [[X:%.*]]
352 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
353 ; CHECK-NEXT: ret <2 x i64> [[BO]]
355 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
356 %bo = srem <2 x i64> <i64 5, i64 undef>, %ins
360 define <2 x i64> @srem_constant_op0_not_undef_lane(i64 %x) {
361 ; CHECK-LABEL: @srem_constant_op0_not_undef_lane(
362 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = srem i64 5, [[X:%.*]]
363 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
364 ; CHECK-NEXT: ret <2 x i64> [[BO]]
366 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
367 %bo = srem <2 x i64> <i64 5, i64 2>, %ins
371 define <2 x i64> @srem_constant_op1(i64 %x) {
372 ; CHECK-LABEL: @srem_constant_op1(
373 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = srem i64 [[X:%.*]], 2
374 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> <i64 poison, i64 0>, i64 [[BO_SCALAR]], i64 1
375 ; CHECK-NEXT: ret <2 x i64> [[BO]]
377 %ins = insertelement <2 x i64> undef, i64 %x, i32 1
378 %bo = srem <2 x i64> %ins, <i64 undef, i64 2>
382 define <2 x i64> @srem_constant_op1_not_undef_lane(i64 %x) {
383 ; CHECK-LABEL: @srem_constant_op1_not_undef_lane(
384 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = srem i64 [[X:%.*]], 2
385 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> zeroinitializer, i64 [[BO_SCALAR]], i64 1
386 ; CHECK-NEXT: ret <2 x i64> [[BO]]
388 %ins = insertelement <2 x i64> undef, i64 %x, i32 1
389 %bo = srem <2 x i64> %ins, <i64 5, i64 2>
393 define <2 x i64> @udiv_constant_op0(i64 %x) {
394 ; CHECK-LABEL: @udiv_constant_op0(
395 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = udiv exact i64 5, [[X:%.*]]
396 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
397 ; CHECK-NEXT: ret <2 x i64> [[BO]]
399 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
400 %bo = udiv exact <2 x i64> <i64 5, i64 undef>, %ins
404 define <2 x i64> @udiv_constant_op0_not_undef_lane(i64 %x) {
405 ; CHECK-LABEL: @udiv_constant_op0_not_undef_lane(
406 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = udiv exact i64 5, [[X:%.*]]
407 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
408 ; CHECK-NEXT: ret <2 x i64> [[BO]]
410 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
411 %bo = udiv exact <2 x i64> <i64 5, i64 2>, %ins
415 define <2 x i64> @udiv_constant_op1(i64 %x) {
416 ; CHECK-LABEL: @udiv_constant_op1(
417 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = udiv i64 [[X:%.*]], 2
418 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> <i64 poison, i64 0>, i64 [[BO_SCALAR]], i64 1
419 ; CHECK-NEXT: ret <2 x i64> [[BO]]
421 %ins = insertelement <2 x i64> undef, i64 %x, i32 1
422 %bo = udiv <2 x i64> %ins, <i64 undef, i64 2>
426 define <2 x i64> @udiv_constant_op1_not_undef_lane(i64 %x) {
427 ; CHECK-LABEL: @udiv_constant_op1_not_undef_lane(
428 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = udiv i64 [[X:%.*]], 2
429 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> zeroinitializer, i64 [[BO_SCALAR]], i64 1
430 ; CHECK-NEXT: ret <2 x i64> [[BO]]
432 %ins = insertelement <2 x i64> undef, i64 %x, i32 1
433 %bo = udiv <2 x i64> %ins, <i64 5, i64 2>
437 define <2 x i64> @sdiv_constant_op0(i64 %x) {
438 ; CHECK-LABEL: @sdiv_constant_op0(
439 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = sdiv i64 5, [[X:%.*]]
440 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
441 ; CHECK-NEXT: ret <2 x i64> [[BO]]
443 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
444 %bo = sdiv <2 x i64> <i64 5, i64 undef>, %ins
448 define <2 x i64> @sdiv_constant_op0_not_undef_lane(i64 %x) {
449 ; CHECK-LABEL: @sdiv_constant_op0_not_undef_lane(
450 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = sdiv i64 5, [[X:%.*]]
451 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> poison, i64 [[BO_SCALAR]], i64 0
452 ; CHECK-NEXT: ret <2 x i64> [[BO]]
454 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
455 %bo = sdiv <2 x i64> <i64 5, i64 2>, %ins
459 define <2 x i64> @sdiv_constant_op1(i64 %x) {
460 ; CHECK-LABEL: @sdiv_constant_op1(
461 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = sdiv exact i64 [[X:%.*]], 2
462 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> <i64 poison, i64 0>, i64 [[BO_SCALAR]], i64 1
463 ; CHECK-NEXT: ret <2 x i64> [[BO]]
465 %ins = insertelement <2 x i64> undef, i64 %x, i32 1
466 %bo = sdiv exact <2 x i64> %ins, <i64 undef, i64 2>
470 define <2 x i64> @sdiv_constant_op1_not_undef_lane(i64 %x) {
471 ; CHECK-LABEL: @sdiv_constant_op1_not_undef_lane(
472 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = sdiv exact i64 [[X:%.*]], 2
473 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> zeroinitializer, i64 [[BO_SCALAR]], i64 1
474 ; CHECK-NEXT: ret <2 x i64> [[BO]]
476 %ins = insertelement <2 x i64> undef, i64 %x, i32 1
477 %bo = sdiv exact <2 x i64> %ins, <i64 5, i64 2>
481 define <2 x i64> @and_constant(i64 %x) {
482 ; CHECK-LABEL: @and_constant(
483 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = and i64 [[X:%.*]], 42
484 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> <i64 0, i64 undef>, i64 [[BO_SCALAR]], i64 0
485 ; CHECK-NEXT: ret <2 x i64> [[BO]]
487 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
488 %bo = and <2 x i64> %ins, <i64 42, i64 undef>
492 define <2 x i64> @and_constant_not_undef_lane(i64 %x) {
493 ; CHECK-LABEL: @and_constant_not_undef_lane(
494 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = and i64 [[X:%.*]], 42
495 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> zeroinitializer, i64 [[BO_SCALAR]], i64 0
496 ; CHECK-NEXT: ret <2 x i64> [[BO]]
498 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
499 %bo = and <2 x i64> %ins, <i64 42, i64 -42>
503 define <2 x i64> @or_constant(i64 %x) {
504 ; CHECK-LABEL: @or_constant(
505 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = or i64 [[X:%.*]], -42
506 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> <i64 undef, i64 -1>, i64 [[BO_SCALAR]], i64 1
507 ; CHECK-NEXT: ret <2 x i64> [[BO]]
509 %ins = insertelement <2 x i64> undef, i64 %x, i32 1
510 %bo = or <2 x i64> %ins, <i64 undef, i64 -42>
514 define <2 x i64> @or_constant_not_undef_lane(i64 %x) {
515 ; CHECK-LABEL: @or_constant_not_undef_lane(
516 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = or i64 [[X:%.*]], -42
517 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> <i64 -1, i64 -1>, i64 [[BO_SCALAR]], i64 1
518 ; CHECK-NEXT: ret <2 x i64> [[BO]]
520 %ins = insertelement <2 x i64> undef, i64 %x, i32 1
521 %bo = or <2 x i64> %ins, <i64 42, i64 -42>
525 define <2 x i64> @xor_constant(i64 %x) {
526 ; CHECK-LABEL: @xor_constant(
527 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = xor i64 [[X:%.*]], 42
528 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> <i64 undef, i64 0>, i64 [[BO_SCALAR]], i64 0
529 ; CHECK-NEXT: ret <2 x i64> [[BO]]
531 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
532 %bo = xor <2 x i64> %ins, <i64 42, i64 undef>
536 define <2 x i64> @xor_constant_not_undef_lane(i64 %x) {
537 ; CHECK-LABEL: @xor_constant_not_undef_lane(
538 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = xor i64 [[X:%.*]], 42
539 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x i64> undef, i64 [[BO_SCALAR]], i64 0
540 ; CHECK-NEXT: ret <2 x i64> [[BO]]
542 %ins = insertelement <2 x i64> undef, i64 %x, i32 0
543 %bo = xor <2 x i64> %ins, <i64 42, i64 -42>
547 define <2 x double> @fadd_constant(double %x) {
548 ; CHECK-LABEL: @fadd_constant(
549 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = fadd double [[X:%.*]], 4.200000e+01
550 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> <double 0x7FF8000000000000, double undef>, double [[BO_SCALAR]], i64 0
551 ; CHECK-NEXT: ret <2 x double> [[BO]]
553 %ins = insertelement <2 x double> undef, double %x, i32 0
554 %bo = fadd <2 x double> %ins, <double 42.0, double undef>
558 define <2 x double> @fadd_constant_not_undef_lane(double %x) {
559 ; CHECK-LABEL: @fadd_constant_not_undef_lane(
560 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = fadd double [[X:%.*]], -4.200000e+01
561 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>, double [[BO_SCALAR]], i64 1
562 ; CHECK-NEXT: ret <2 x double> [[BO]]
564 %ins = insertelement <2 x double> undef, double %x, i32 1
565 %bo = fadd <2 x double> %ins, <double 42.0, double -42.0>
569 define <2 x double> @fsub_constant_op0(double %x) {
570 ; CHECK-LABEL: @fsub_constant_op0(
571 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = fsub fast double 4.200000e+01, [[X:%.*]]
572 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> <double 0x7FF8000000000000, double undef>, double [[BO_SCALAR]], i64 0
573 ; CHECK-NEXT: ret <2 x double> [[BO]]
575 %ins = insertelement <2 x double> undef, double %x, i32 0
576 %bo = fsub fast <2 x double> <double 42.0, double undef>, %ins
580 define <2 x double> @fsub_constant_op0_not_undef_lane(double %x) {
581 ; CHECK-LABEL: @fsub_constant_op0_not_undef_lane(
582 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = fsub nsz double -4.200000e+01, [[X:%.*]]
583 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>, double [[BO_SCALAR]], i64 1
584 ; CHECK-NEXT: ret <2 x double> [[BO]]
586 %ins = insertelement <2 x double> undef, double %x, i32 1
587 %bo = fsub nsz <2 x double> <double 42.0, double -42.0>, %ins
591 define <2 x double> @fsub_constant_op1(double %x) {
592 ; CHECK-LABEL: @fsub_constant_op1(
593 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = fsub double [[X:%.*]], 4.200000e+01
594 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> <double undef, double 0x7FF8000000000000>, double [[BO_SCALAR]], i64 1
595 ; CHECK-NEXT: ret <2 x double> [[BO]]
597 %ins = insertelement <2 x double> undef, double %x, i32 1
598 %bo = fsub <2 x double> %ins, <double undef, double 42.0>
602 define <2 x double> @fsub_constant_op1_not_undef_lane(double %x) {
603 ; CHECK-LABEL: @fsub_constant_op1_not_undef_lane(
604 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = fsub double [[X:%.*]], 4.200000e+01
605 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>, double [[BO_SCALAR]], i64 0
606 ; CHECK-NEXT: ret <2 x double> [[BO]]
608 %ins = insertelement <2 x double> undef, double %x, i32 0
609 %bo = fsub <2 x double> %ins, <double 42.0, double -42.0>
613 define <2 x double> @fmul_constant(double %x) {
614 ; CHECK-LABEL: @fmul_constant(
615 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = fmul reassoc double [[X:%.*]], 4.200000e+01
616 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> <double 0x7FF8000000000000, double undef>, double [[BO_SCALAR]], i64 0
617 ; CHECK-NEXT: ret <2 x double> [[BO]]
619 %ins = insertelement <2 x double> undef, double %x, i32 0
620 %bo = fmul reassoc <2 x double> %ins, <double 42.0, double undef>
624 define <2 x double> @fmul_constant_not_undef_lane(double %x) {
625 ; CHECK-LABEL: @fmul_constant_not_undef_lane(
626 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = fmul double [[X:%.*]], -4.200000e+01
627 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>, double [[BO_SCALAR]], i64 1
628 ; CHECK-NEXT: ret <2 x double> [[BO]]
630 %ins = insertelement <2 x double> undef, double %x, i32 1
631 %bo = fmul <2 x double> %ins, <double 42.0, double -42.0>
635 define <2 x double> @fdiv_constant_op0(double %x) {
636 ; CHECK-LABEL: @fdiv_constant_op0(
637 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = fdiv nnan double 4.200000e+01, [[X:%.*]]
638 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> <double undef, double 0x7FF8000000000000>, double [[BO_SCALAR]], i64 1
639 ; CHECK-NEXT: ret <2 x double> [[BO]]
641 %ins = insertelement <2 x double> undef, double %x, i32 1
642 %bo = fdiv nnan <2 x double> <double undef, double 42.0>, %ins
646 define <2 x double> @fdiv_constant_op0_not_undef_lane(double %x) {
647 ; CHECK-LABEL: @fdiv_constant_op0_not_undef_lane(
648 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = fdiv ninf double 4.200000e+01, [[X:%.*]]
649 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>, double [[BO_SCALAR]], i64 0
650 ; CHECK-NEXT: ret <2 x double> [[BO]]
652 %ins = insertelement <2 x double> undef, double %x, i32 0
653 %bo = fdiv ninf <2 x double> <double 42.0, double -42.0>, %ins
657 define <2 x double> @fdiv_constant_op1(double %x) {
658 ; CHECK-LABEL: @fdiv_constant_op1(
659 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = fdiv double [[X:%.*]], 4.200000e+01
660 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> <double 0x7FF8000000000000, double undef>, double [[BO_SCALAR]], i64 0
661 ; CHECK-NEXT: ret <2 x double> [[BO]]
663 %ins = insertelement <2 x double> undef, double %x, i32 0
664 %bo = fdiv <2 x double> %ins, <double 42.0, double undef>
668 define <2 x double> @fdiv_constant_op1_not_undef_lane(double %x) {
669 ; CHECK-LABEL: @fdiv_constant_op1_not_undef_lane(
670 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = fdiv double [[X:%.*]], 4.200000e+01
671 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>, double [[BO_SCALAR]], i64 0
672 ; CHECK-NEXT: ret <2 x double> [[BO]]
674 %ins = insertelement <2 x double> undef, double %x, i32 0
675 %bo = fdiv <2 x double> %ins, <double 42.0, double -42.0>
679 define <2 x double> @frem_constant_op0(double %x) {
680 ; CHECK-LABEL: @frem_constant_op0(
681 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = frem fast double 4.200000e+01, [[X:%.*]]
682 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> <double 0x7FF8000000000000, double undef>, double [[BO_SCALAR]], i64 0
683 ; CHECK-NEXT: ret <2 x double> [[BO]]
685 %ins = insertelement <2 x double> undef, double %x, i32 0
686 %bo = frem fast <2 x double> <double 42.0, double undef>, %ins
690 define <2 x double> @frem_constant_op0_not_undef_lane(double %x) {
691 ; CHECK-LABEL: @frem_constant_op0_not_undef_lane(
692 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = frem double -4.200000e+01, [[X:%.*]]
693 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>, double [[BO_SCALAR]], i64 1
694 ; CHECK-NEXT: ret <2 x double> [[BO]]
696 %ins = insertelement <2 x double> undef, double %x, i32 1
697 %bo = frem <2 x double> <double 42.0, double -42.0>, %ins
701 define <2 x double> @frem_constant_op1(double %x) {
702 ; CHECK-LABEL: @frem_constant_op1(
703 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = frem ninf double [[X:%.*]], 4.200000e+01
704 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> <double undef, double 0x7FF8000000000000>, double [[BO_SCALAR]], i64 1
705 ; CHECK-NEXT: ret <2 x double> [[BO]]
707 %ins = insertelement <2 x double> undef, double %x, i32 1
708 %bo = frem ninf <2 x double> %ins, <double undef, double 42.0>
712 define <2 x double> @frem_constant_op1_not_undef_lane(double %x) {
713 ; CHECK-LABEL: @frem_constant_op1_not_undef_lane(
714 ; CHECK-NEXT: [[BO_SCALAR:%.*]] = frem nnan double [[X:%.*]], 4.200000e+01
715 ; CHECK-NEXT: [[BO:%.*]] = insertelement <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000>, double [[BO_SCALAR]], i64 0
716 ; CHECK-NEXT: ret <2 x double> [[BO]]
718 %ins = insertelement <2 x double> undef, double %x, i32 0
719 %bo = frem nnan <2 x double> %ins, <double 42.0, double -42.0>