1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-unknown-unknown -O3 -cgp-icmp-eq2icmp-st -verify-machineinstrs < %s | FileCheck %s
4 ; Test cases are generated from:
5 ; long long NAME(PARAM a, PARAM b) {
12 ; Please note funtion name is defined as <PARAM>_<LHS>_<RHS>. Take ll_a_op_b__1
13 ; for example. ll is PARAM, a_op_b (i.e., a << b) is LHS, _1 (i.e., -1) is RHS.
15 target datalayout = "e-m:e-i64:64-n32:64"
17 define i64 @ll_a_op_b__2(i64 %a, i64 %b) {
18 ; CHECK-LABEL: ll_a_op_b__2:
19 ; CHECK: // %bb.0: // %entry
20 ; CHECK-NEXT: lsl x8, x0, x1
21 ; CHECK-NEXT: cmn x8, #2
22 ; CHECK-NEXT: csinc x8, x1, xzr, eq
23 ; CHECK-NEXT: mul x8, x8, x0
24 ; CHECK-NEXT: csel x0, x1, x8, gt
28 %cmp = icmp sgt i64 %shl, -2
29 br i1 %cmp, label %return, label %if.end
31 if.end: ; preds = %entry
32 %cmp2 = icmp eq i64 %shl, -2
33 %mul = select i1 %cmp2, i64 %b, i64 1
34 %spec.select = mul nsw i64 %mul, %a
37 return: ; preds = %entry
41 define i64 @ll_a_op_b__1(i64 %a, i64 %b) {
42 ; CHECK-LABEL: ll_a_op_b__1:
43 ; CHECK: // %bb.0: // %entry
44 ; CHECK-NEXT: lsl x8, x0, x1
45 ; CHECK-NEXT: cmn x8, #1
46 ; CHECK-NEXT: csinc x9, x1, xzr, eq
47 ; CHECK-NEXT: cmp x8, #0
48 ; CHECK-NEXT: mul x9, x9, x0
49 ; CHECK-NEXT: csel x0, x1, x9, ge
53 %cmp = icmp sgt i64 %shl, -1
54 br i1 %cmp, label %return, label %if.end
56 if.end: ; preds = %entry
57 %cmp2 = icmp eq i64 %shl, -1
58 %mul = select i1 %cmp2, i64 %b, i64 1
59 %spec.select = mul nsw i64 %mul, %a
62 return: ; preds = %entry
66 define i64 @ll_a_op_b_0(i64 %a, i64 %b) {
67 ; CHECK-LABEL: ll_a_op_b_0:
68 ; CHECK: // %bb.0: // %entry
69 ; CHECK-NEXT: lsl x8, x0, x1
70 ; CHECK-NEXT: cmp x8, #0
71 ; CHECK-NEXT: csinc x8, x1, xzr, eq
72 ; CHECK-NEXT: mul x8, x8, x0
73 ; CHECK-NEXT: csel x0, x1, x8, gt
77 %cmp = icmp sgt i64 %shl, 0
78 br i1 %cmp, label %return, label %if.end
80 if.end: ; preds = %entry
81 %cmp2 = icmp eq i64 %shl, 0
82 %mul = select i1 %cmp2, i64 %b, i64 1
83 %spec.select = mul nsw i64 %mul, %a
86 return: ; preds = %entry
90 define i64 @ll_a_op_b_1(i64 %a, i64 %b) {
91 ; CHECK-LABEL: ll_a_op_b_1:
92 ; CHECK: // %bb.0: // %entry
93 ; CHECK-NEXT: lsl x8, x0, x1
94 ; CHECK-NEXT: cmp x8, #1
95 ; CHECK-NEXT: csinc x8, x1, xzr, eq
96 ; CHECK-NEXT: mul x8, x8, x0
97 ; CHECK-NEXT: csel x0, x1, x8, gt
100 %shl = shl i64 %a, %b
101 %cmp = icmp sgt i64 %shl, 1
102 br i1 %cmp, label %return, label %if.end
104 if.end: ; preds = %entry
105 %cmp2 = icmp eq i64 %shl, 1
106 %mul = select i1 %cmp2, i64 %b, i64 1
107 %spec.select = mul nsw i64 %mul, %a
110 return: ; preds = %entry
114 define i64 @ll_a_op_b_2(i64 %a, i64 %b) {
115 ; CHECK-LABEL: ll_a_op_b_2:
116 ; CHECK: // %bb.0: // %entry
117 ; CHECK-NEXT: lsl x8, x0, x1
118 ; CHECK-NEXT: cmp x8, #2
119 ; CHECK-NEXT: csinc x8, x1, xzr, eq
120 ; CHECK-NEXT: mul x8, x8, x0
121 ; CHECK-NEXT: csel x0, x1, x8, gt
124 %shl = shl i64 %a, %b
125 %cmp = icmp sgt i64 %shl, 2
126 br i1 %cmp, label %return, label %if.end
128 if.end: ; preds = %entry
129 %cmp2 = icmp eq i64 %shl, 2
130 %mul = select i1 %cmp2, i64 %b, i64 1
131 %spec.select = mul nsw i64 %mul, %a
134 return: ; preds = %entry
138 define i64 @ll_a__2(i64 %a, i64 %b) {
139 ; CHECK-LABEL: ll_a__2:
140 ; CHECK: // %bb.0: // %entry
141 ; CHECK-NEXT: cmn x0, #2
142 ; CHECK-NEXT: csinc x8, x1, xzr, eq
143 ; CHECK-NEXT: mul x8, x8, x0
144 ; CHECK-NEXT: csel x0, x1, x8, gt
147 %cmp = icmp sgt i64 %a, -2
148 br i1 %cmp, label %return, label %if.end
150 if.end: ; preds = %entry
151 %cmp1 = icmp eq i64 %a, -2
152 %mul = select i1 %cmp1, i64 %b, i64 1
153 %spec.select = mul nsw i64 %mul, %a
156 return: ; preds = %entry
160 define i64 @ll_a__1(i64 %a, i64 %b) {
161 ; CHECK-LABEL: ll_a__1:
162 ; CHECK: // %bb.0: // %entry
163 ; CHECK-NEXT: cmn x0, #1
164 ; CHECK-NEXT: csinc x8, x1, xzr, eq
165 ; CHECK-NEXT: cmp x0, #0
166 ; CHECK-NEXT: mul x8, x8, x0
167 ; CHECK-NEXT: csel x0, x1, x8, ge
170 %cmp = icmp sgt i64 %a, -1
171 br i1 %cmp, label %return, label %if.end
173 if.end: ; preds = %entry
174 %cmp1 = icmp eq i64 %a, -1
175 %mul = select i1 %cmp1, i64 %b, i64 1
176 %spec.select = mul nsw i64 %mul, %a
179 return: ; preds = %entry
183 define i64 @ll_a_0(i64 %a, i64 %b) {
184 ; CHECK-LABEL: ll_a_0:
185 ; CHECK: // %bb.0: // %entry
186 ; CHECK-NEXT: cmp x0, #0
187 ; CHECK-NEXT: csinc x8, x1, xzr, eq
188 ; CHECK-NEXT: mul x8, x8, x0
189 ; CHECK-NEXT: csel x0, x1, x8, gt
192 %cmp = icmp sgt i64 %a, 0
193 br i1 %cmp, label %return, label %if.end
195 if.end: ; preds = %entry
196 %cmp1 = icmp eq i64 %a, 0
197 %mul = select i1 %cmp1, i64 %b, i64 1
198 %spec.select = mul nsw i64 %mul, %a
201 return: ; preds = %entry
205 define i64 @ll_a_1(i64 %a, i64 %b) {
206 ; CHECK-LABEL: ll_a_1:
207 ; CHECK: // %bb.0: // %entry
208 ; CHECK-NEXT: cmp x0, #1
209 ; CHECK-NEXT: csinc x8, x1, xzr, eq
210 ; CHECK-NEXT: mul x8, x8, x0
211 ; CHECK-NEXT: csel x0, x1, x8, gt
214 %cmp = icmp sgt i64 %a, 1
215 br i1 %cmp, label %return, label %if.end
217 if.end: ; preds = %entry
218 %cmp1 = icmp eq i64 %a, 1
219 %mul = select i1 %cmp1, i64 %b, i64 1
220 %spec.select = mul nsw i64 %mul, %a
223 return: ; preds = %entry
227 define i64 @ll_a_2(i64 %a, i64 %b) {
228 ; CHECK-LABEL: ll_a_2:
229 ; CHECK: // %bb.0: // %entry
230 ; CHECK-NEXT: cmp x0, #2
231 ; CHECK-NEXT: csinc x8, x1, xzr, eq
232 ; CHECK-NEXT: mul x8, x8, x0
233 ; CHECK-NEXT: csel x0, x1, x8, gt
236 %cmp = icmp sgt i64 %a, 2
237 br i1 %cmp, label %return, label %if.end
239 if.end: ; preds = %entry
240 %cmp1 = icmp eq i64 %a, 2
241 %mul = select i1 %cmp1, i64 %b, i64 1
242 %spec.select = mul nsw i64 %mul, %a
245 return: ; preds = %entry
249 define i64 @i_a_op_b__2(i32 signext %a, i32 signext %b) {
250 ; CHECK-LABEL: i_a_op_b__2:
251 ; CHECK: // %bb.0: // %entry
252 ; CHECK-NEXT: lsl w8, w0, w1
253 ; CHECK-NEXT: cmn w8, #2
254 ; CHECK-NEXT: csinc w8, w1, wzr, eq
255 ; CHECK-NEXT: mul w8, w8, w0
256 ; CHECK-NEXT: csel w8, w1, w8, gt
257 ; CHECK-NEXT: sxtw x0, w8
260 %shl = shl i32 %a, %b
261 %cmp = icmp sgt i32 %shl, -2
262 br i1 %cmp, label %return, label %if.end
264 if.end: ; preds = %entry
265 %cmp2 = icmp eq i32 %shl, -2
266 %mul = select i1 %cmp2, i32 %b, i32 1
267 %spec.select = mul nsw i32 %mul, %a
270 return: ; preds = %if.end, %entry
271 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
272 %retval.0 = sext i32 %retval.0.in to i64
276 define i64 @i_a_op_b__1(i32 signext %a, i32 signext %b) {
277 ; CHECK-LABEL: i_a_op_b__1:
278 ; CHECK: // %bb.0: // %entry
279 ; CHECK-NEXT: lsl w8, w0, w1
280 ; CHECK-NEXT: cmn w8, #1
281 ; CHECK-NEXT: csinc w9, w1, wzr, eq
282 ; CHECK-NEXT: cmp w8, #0
283 ; CHECK-NEXT: mul w9, w9, w0
284 ; CHECK-NEXT: csel w8, w1, w9, ge
285 ; CHECK-NEXT: sxtw x0, w8
288 %shl = shl i32 %a, %b
289 %cmp = icmp sgt i32 %shl, -1
290 br i1 %cmp, label %return, label %if.end
292 if.end: ; preds = %entry
293 %cmp2 = icmp eq i32 %shl, -1
294 %mul = select i1 %cmp2, i32 %b, i32 1
295 %spec.select = mul nsw i32 %mul, %a
298 return: ; preds = %if.end, %entry
299 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
300 %retval.0 = sext i32 %retval.0.in to i64
304 define i64 @i_a_op_b_0(i32 signext %a, i32 signext %b) {
305 ; CHECK-LABEL: i_a_op_b_0:
306 ; CHECK: // %bb.0: // %entry
307 ; CHECK-NEXT: lsl w8, w0, w1
308 ; CHECK-NEXT: cmp w8, #0
309 ; CHECK-NEXT: csinc w8, w1, wzr, eq
310 ; CHECK-NEXT: mul w8, w8, w0
311 ; CHECK-NEXT: csel w8, w1, w8, gt
312 ; CHECK-NEXT: sxtw x0, w8
315 %shl = shl i32 %a, %b
316 %cmp = icmp sgt i32 %shl, 0
317 br i1 %cmp, label %return, label %if.end
319 if.end: ; preds = %entry
320 %cmp2 = icmp eq i32 %shl, 0
321 %mul = select i1 %cmp2, i32 %b, i32 1
322 %spec.select = mul nsw i32 %mul, %a
325 return: ; preds = %if.end, %entry
326 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
327 %retval.0 = sext i32 %retval.0.in to i64
331 define i64 @i_a_op_b_1(i32 signext %a, i32 signext %b) {
332 ; CHECK-LABEL: i_a_op_b_1:
333 ; CHECK: // %bb.0: // %entry
334 ; CHECK-NEXT: lsl w8, w0, w1
335 ; CHECK-NEXT: cmp w8, #1
336 ; CHECK-NEXT: csinc w8, w1, wzr, eq
337 ; CHECK-NEXT: mul w8, w8, w0
338 ; CHECK-NEXT: csel w8, w1, w8, gt
339 ; CHECK-NEXT: sxtw x0, w8
342 %shl = shl i32 %a, %b
343 %cmp = icmp sgt i32 %shl, 1
344 br i1 %cmp, label %return, label %if.end
346 if.end: ; preds = %entry
347 %cmp2 = icmp eq i32 %shl, 1
348 %mul = select i1 %cmp2, i32 %b, i32 1
349 %spec.select = mul nsw i32 %mul, %a
352 return: ; preds = %if.end, %entry
353 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
354 %retval.0 = sext i32 %retval.0.in to i64
358 define i64 @i_a_op_b_2(i32 signext %a, i32 signext %b) {
359 ; CHECK-LABEL: i_a_op_b_2:
360 ; CHECK: // %bb.0: // %entry
361 ; CHECK-NEXT: lsl w8, w0, w1
362 ; CHECK-NEXT: cmp w8, #2
363 ; CHECK-NEXT: csinc w8, w1, wzr, eq
364 ; CHECK-NEXT: mul w8, w8, w0
365 ; CHECK-NEXT: csel w8, w1, w8, gt
366 ; CHECK-NEXT: sxtw x0, w8
369 %shl = shl i32 %a, %b
370 %cmp = icmp sgt i32 %shl, 2
371 br i1 %cmp, label %return, label %if.end
373 if.end: ; preds = %entry
374 %cmp2 = icmp eq i32 %shl, 2
375 %mul = select i1 %cmp2, i32 %b, i32 1
376 %spec.select = mul nsw i32 %mul, %a
379 return: ; preds = %if.end, %entry
380 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
381 %retval.0 = sext i32 %retval.0.in to i64
385 define i64 @i_a__2(i32 signext %a, i32 signext %b) {
386 ; CHECK-LABEL: i_a__2:
387 ; CHECK: // %bb.0: // %entry
388 ; CHECK-NEXT: cmn w0, #2
389 ; CHECK-NEXT: csinc w8, w1, wzr, eq
390 ; CHECK-NEXT: mul w8, w8, w0
391 ; CHECK-NEXT: csel w8, w1, w8, gt
392 ; CHECK-NEXT: sxtw x0, w8
395 %cmp = icmp sgt i32 %a, -2
396 br i1 %cmp, label %return, label %if.end
398 if.end: ; preds = %entry
399 %cmp1 = icmp eq i32 %a, -2
400 %mul = select i1 %cmp1, i32 %b, i32 1
401 %spec.select = mul nsw i32 %mul, %a
404 return: ; preds = %if.end, %entry
405 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
406 %retval.0 = sext i32 %retval.0.in to i64
410 define i64 @i_a__1(i32 signext %a, i32 signext %b) {
411 ; CHECK-LABEL: i_a__1:
412 ; CHECK: // %bb.0: // %entry
413 ; CHECK-NEXT: cmn w0, #1
414 ; CHECK-NEXT: csinc w8, w1, wzr, eq
415 ; CHECK-NEXT: cmp w0, #0
416 ; CHECK-NEXT: mul w8, w8, w0
417 ; CHECK-NEXT: csel w8, w1, w8, ge
418 ; CHECK-NEXT: sxtw x0, w8
421 %cmp = icmp sgt i32 %a, -1
422 br i1 %cmp, label %return, label %if.end
424 if.end: ; preds = %entry
425 %cmp1 = icmp eq i32 %a, -1
426 %mul = select i1 %cmp1, i32 %b, i32 1
427 %spec.select = mul nsw i32 %mul, %a
430 return: ; preds = %if.end, %entry
431 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
432 %retval.0 = sext i32 %retval.0.in to i64
436 define i64 @i_a_0(i32 signext %a, i32 signext %b) {
437 ; CHECK-LABEL: i_a_0:
438 ; CHECK: // %bb.0: // %entry
439 ; CHECK-NEXT: cmp w0, #0
440 ; CHECK-NEXT: csinc w8, w1, wzr, eq
441 ; CHECK-NEXT: mul w8, w8, w0
442 ; CHECK-NEXT: csel w8, w1, w8, gt
443 ; CHECK-NEXT: sxtw x0, w8
446 %cmp = icmp sgt i32 %a, 0
447 br i1 %cmp, label %return, label %if.end
449 if.end: ; preds = %entry
450 %cmp1 = icmp eq i32 %a, 0
451 %mul = select i1 %cmp1, i32 %b, i32 1
452 %spec.select = mul nsw i32 %mul, %a
455 return: ; preds = %if.end, %entry
456 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
457 %retval.0 = sext i32 %retval.0.in to i64
461 define i64 @i_a_1(i32 signext %a, i32 signext %b) {
462 ; CHECK-LABEL: i_a_1:
463 ; CHECK: // %bb.0: // %entry
464 ; CHECK-NEXT: cmp w0, #1
465 ; CHECK-NEXT: csinc w8, w1, wzr, eq
466 ; CHECK-NEXT: mul w8, w8, w0
467 ; CHECK-NEXT: csel w8, w1, w8, gt
468 ; CHECK-NEXT: sxtw x0, w8
471 %cmp = icmp sgt i32 %a, 1
472 br i1 %cmp, label %return, label %if.end
474 if.end: ; preds = %entry
475 %cmp1 = icmp eq i32 %a, 1
476 %mul = select i1 %cmp1, i32 %b, i32 1
477 %spec.select = mul nsw i32 %mul, %a
480 return: ; preds = %if.end, %entry
481 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
482 %retval.0 = sext i32 %retval.0.in to i64
486 define i64 @i_a_2(i32 signext %a, i32 signext %b) {
487 ; CHECK-LABEL: i_a_2:
488 ; CHECK: // %bb.0: // %entry
489 ; CHECK-NEXT: cmp w0, #2
490 ; CHECK-NEXT: csinc w8, w1, wzr, eq
491 ; CHECK-NEXT: mul w8, w8, w0
492 ; CHECK-NEXT: csel w8, w1, w8, gt
493 ; CHECK-NEXT: sxtw x0, w8
496 %cmp = icmp sgt i32 %a, 2
497 br i1 %cmp, label %return, label %if.end
499 if.end: ; preds = %entry
500 %cmp1 = icmp eq i32 %a, 2
501 %mul = select i1 %cmp1, i32 %b, i32 1
502 %spec.select = mul nsw i32 %mul, %a
505 return: ; preds = %if.end, %entry
506 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
507 %retval.0 = sext i32 %retval.0.in to i64