1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mcpu=pwr9 -mtriple=powerpc64le-unknown-linux-gnu -O3 -ppc-asm-full-reg-names -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: sld r5, r3, r4
21 ; CHECK-NEXT: cmpdi r5, -2
22 ; CHECK-NEXT: ble cr0, .LBB0_2
23 ; CHECK-NEXT: # %bb.1: # %return
24 ; CHECK-NEXT: mr r3, r4
26 ; CHECK-NEXT: .LBB0_2: # %if.end
27 ; CHECK-NEXT: li r5, 1
28 ; CHECK-NEXT: isel r4, r4, r5, eq
29 ; CHECK-NEXT: mulld r3, r4, r3
33 %cmp = icmp sgt i64 %shl, -2
34 br i1 %cmp, label %return, label %if.end
36 if.end: ; preds = %entry
37 %cmp2 = icmp eq i64 %shl, -2
38 %mul = select i1 %cmp2, i64 %b, i64 1
39 %spec.select = mul nsw i64 %mul, %a
42 return: ; preds = %entry
46 define i64 @ll_a_op_b__1(i64 %a, i64 %b) {
47 ; CHECK-LABEL: ll_a_op_b__1:
48 ; CHECK: # %bb.0: # %entry
49 ; CHECK-NEXT: sld r5, r3, r4
50 ; CHECK-NEXT: cmpdi r5, -1
51 ; CHECK-NEXT: ble cr0, .LBB1_2
52 ; CHECK-NEXT: # %bb.1: # %return
53 ; CHECK-NEXT: mr r3, r4
55 ; CHECK-NEXT: .LBB1_2: # %if.end
56 ; CHECK-NEXT: li r5, 1
57 ; CHECK-NEXT: isel r4, r4, r5, eq
58 ; CHECK-NEXT: mulld r3, r4, r3
62 %cmp = icmp sgt i64 %shl, -1
63 br i1 %cmp, label %return, label %if.end
65 if.end: ; preds = %entry
66 %cmp2 = icmp eq i64 %shl, -1
67 %mul = select i1 %cmp2, i64 %b, i64 1
68 %spec.select = mul nsw i64 %mul, %a
71 return: ; preds = %entry
75 define i64 @ll_a_op_b_0(i64 %a, i64 %b) {
76 ; CHECK-LABEL: ll_a_op_b_0:
77 ; CHECK: # %bb.0: # %entry
78 ; CHECK-NEXT: sld. r5, r3, r4
79 ; CHECK-NEXT: ble cr0, .LBB2_2
80 ; CHECK-NEXT: # %bb.1: # %return
81 ; CHECK-NEXT: mr r3, r4
83 ; CHECK-NEXT: .LBB2_2: # %if.end
84 ; CHECK-NEXT: cmpldi r5, 0
85 ; CHECK-NEXT: li r5, 1
86 ; CHECK-NEXT: isel r4, r4, r5, eq
87 ; CHECK-NEXT: mulld r3, r4, r3
91 %cmp = icmp sgt i64 %shl, 0
92 br i1 %cmp, label %return, label %if.end
94 if.end: ; preds = %entry
95 %cmp2 = icmp eq i64 %shl, 0
96 %mul = select i1 %cmp2, i64 %b, i64 1
97 %spec.select = mul nsw i64 %mul, %a
100 return: ; preds = %entry
104 define i64 @ll_a_op_b_1(i64 %a, i64 %b) {
105 ; CHECK-LABEL: ll_a_op_b_1:
106 ; CHECK: # %bb.0: # %entry
107 ; CHECK-NEXT: sld r5, r3, r4
108 ; CHECK-NEXT: cmpdi r5, 1
109 ; CHECK-NEXT: ble cr0, .LBB3_2
110 ; CHECK-NEXT: # %bb.1: # %return
111 ; CHECK-NEXT: mr r3, r4
113 ; CHECK-NEXT: .LBB3_2: # %if.end
114 ; CHECK-NEXT: cmpldi r5, 1
115 ; CHECK-NEXT: li r5, 1
116 ; CHECK-NEXT: isel r4, r4, r5, eq
117 ; CHECK-NEXT: mulld r3, r4, r3
120 %shl = shl i64 %a, %b
121 %cmp = icmp sgt i64 %shl, 1
122 br i1 %cmp, label %return, label %if.end
124 if.end: ; preds = %entry
125 %cmp2 = icmp eq i64 %shl, 1
126 %mul = select i1 %cmp2, i64 %b, i64 1
127 %spec.select = mul nsw i64 %mul, %a
130 return: ; preds = %entry
134 define i64 @ll_a_op_b_2(i64 %a, i64 %b) {
135 ; CHECK-LABEL: ll_a_op_b_2:
136 ; CHECK: # %bb.0: # %entry
137 ; CHECK-NEXT: sld r5, r3, r4
138 ; CHECK-NEXT: cmpdi r5, 2
139 ; CHECK-NEXT: ble cr0, .LBB4_2
140 ; CHECK-NEXT: # %bb.1: # %return
141 ; CHECK-NEXT: mr r3, r4
143 ; CHECK-NEXT: .LBB4_2: # %if.end
144 ; CHECK-NEXT: cmpldi r5, 2
145 ; CHECK-NEXT: li r5, 1
146 ; CHECK-NEXT: isel r4, r4, r5, eq
147 ; CHECK-NEXT: mulld r3, r4, r3
150 %shl = shl i64 %a, %b
151 %cmp = icmp sgt i64 %shl, 2
152 br i1 %cmp, label %return, label %if.end
154 if.end: ; preds = %entry
155 %cmp2 = icmp eq i64 %shl, 2
156 %mul = select i1 %cmp2, i64 %b, i64 1
157 %spec.select = mul nsw i64 %mul, %a
160 return: ; preds = %entry
164 define i64 @ll_a__2(i64 %a, i64 %b) {
165 ; CHECK-LABEL: ll_a__2:
166 ; CHECK: # %bb.0: # %entry
167 ; CHECK-NEXT: cmpdi r3, -2
168 ; CHECK-NEXT: ble cr0, .LBB5_2
169 ; CHECK-NEXT: # %bb.1: # %return
170 ; CHECK-NEXT: mr r3, r4
172 ; CHECK-NEXT: .LBB5_2: # %if.end
173 ; CHECK-NEXT: li r5, 1
174 ; CHECK-NEXT: isel r4, r4, r5, eq
175 ; CHECK-NEXT: mulld r3, r4, r3
178 %cmp = icmp sgt i64 %a, -2
179 br i1 %cmp, label %return, label %if.end
181 if.end: ; preds = %entry
182 %cmp1 = icmp eq i64 %a, -2
183 %mul = select i1 %cmp1, i64 %b, i64 1
184 %spec.select = mul nsw i64 %mul, %a
187 return: ; preds = %entry
191 define i64 @ll_a__1(i64 %a, i64 %b) {
192 ; CHECK-LABEL: ll_a__1:
193 ; CHECK: # %bb.0: # %entry
194 ; CHECK-NEXT: cmpdi r3, -1
195 ; CHECK-NEXT: ble cr0, .LBB6_2
196 ; CHECK-NEXT: # %bb.1: # %return
197 ; CHECK-NEXT: mr r3, r4
199 ; CHECK-NEXT: .LBB6_2: # %if.end
200 ; CHECK-NEXT: li r5, 1
201 ; CHECK-NEXT: isel r4, r4, r5, eq
202 ; CHECK-NEXT: mulld r3, r4, r3
205 %cmp = icmp sgt i64 %a, -1
206 br i1 %cmp, label %return, label %if.end
208 if.end: ; preds = %entry
209 %cmp1 = icmp eq i64 %a, -1
210 %mul = select i1 %cmp1, i64 %b, i64 1
211 %spec.select = mul nsw i64 %mul, %a
214 return: ; preds = %entry
218 define i64 @ll_a_0(i64 %a, i64 %b) {
219 ; CHECK-LABEL: ll_a_0:
220 ; CHECK: # %bb.0: # %entry
221 ; CHECK-NEXT: cmpdi r3, 0
222 ; CHECK-NEXT: ble cr0, .LBB7_2
223 ; CHECK-NEXT: # %bb.1: # %return
224 ; CHECK-NEXT: mr r3, r4
226 ; CHECK-NEXT: .LBB7_2: # %if.end
227 ; CHECK-NEXT: cmpldi r3, 0
228 ; CHECK-NEXT: li r5, 1
229 ; CHECK-NEXT: isel r4, r4, r5, eq
230 ; CHECK-NEXT: mulld r3, r4, r3
233 %cmp = icmp sgt i64 %a, 0
234 br i1 %cmp, label %return, label %if.end
236 if.end: ; preds = %entry
237 %cmp1 = icmp eq i64 %a, 0
238 %mul = select i1 %cmp1, i64 %b, i64 1
239 %spec.select = mul nsw i64 %mul, %a
242 return: ; preds = %entry
246 define i64 @ll_a_1(i64 %a, i64 %b) {
247 ; CHECK-LABEL: ll_a_1:
248 ; CHECK: # %bb.0: # %entry
249 ; CHECK-NEXT: cmpdi r3, 1
250 ; CHECK-NEXT: ble cr0, .LBB8_2
251 ; CHECK-NEXT: # %bb.1: # %return
252 ; CHECK-NEXT: mr r3, r4
254 ; CHECK-NEXT: .LBB8_2: # %if.end
255 ; CHECK-NEXT: cmpldi r3, 1
256 ; CHECK-NEXT: li r5, 1
257 ; CHECK-NEXT: isel r4, r4, r5, eq
258 ; CHECK-NEXT: mulld r3, r4, r3
261 %cmp = icmp sgt i64 %a, 1
262 br i1 %cmp, label %return, label %if.end
264 if.end: ; preds = %entry
265 %cmp1 = icmp eq i64 %a, 1
266 %mul = select i1 %cmp1, i64 %b, i64 1
267 %spec.select = mul nsw i64 %mul, %a
270 return: ; preds = %entry
274 define i64 @ll_a_2(i64 %a, i64 %b) {
275 ; CHECK-LABEL: ll_a_2:
276 ; CHECK: # %bb.0: # %entry
277 ; CHECK-NEXT: cmpdi r3, 2
278 ; CHECK-NEXT: ble cr0, .LBB9_2
279 ; CHECK-NEXT: # %bb.1: # %return
280 ; CHECK-NEXT: mr r3, r4
282 ; CHECK-NEXT: .LBB9_2: # %if.end
283 ; CHECK-NEXT: cmpldi r3, 2
284 ; CHECK-NEXT: li r5, 1
285 ; CHECK-NEXT: isel r4, r4, r5, eq
286 ; CHECK-NEXT: mulld r3, r4, r3
289 %cmp = icmp sgt i64 %a, 2
290 br i1 %cmp, label %return, label %if.end
292 if.end: ; preds = %entry
293 %cmp1 = icmp eq i64 %a, 2
294 %mul = select i1 %cmp1, i64 %b, i64 1
295 %spec.select = mul nsw i64 %mul, %a
298 return: ; preds = %entry
302 define i64 @i_a_op_b__2(i32 signext %a, i32 signext %b) {
303 ; CHECK-LABEL: i_a_op_b__2:
304 ; CHECK: # %bb.0: # %entry
305 ; CHECK-NEXT: slw r5, r3, r4
306 ; CHECK-NEXT: cmpwi r5, -2
307 ; CHECK-NEXT: bgt cr0, .LBB10_2
308 ; CHECK-NEXT: # %bb.1: # %if.end
309 ; CHECK-NEXT: li r5, 1
310 ; CHECK-NEXT: isel r4, r4, r5, eq
311 ; CHECK-NEXT: mullw r4, r4, r3
312 ; CHECK-NEXT: .LBB10_2: # %return
313 ; CHECK-NEXT: extsw r3, r4
316 %shl = shl i32 %a, %b
317 %cmp = icmp sgt i32 %shl, -2
318 br i1 %cmp, label %return, label %if.end
320 if.end: ; preds = %entry
321 %cmp2 = icmp eq i32 %shl, -2
322 %mul = select i1 %cmp2, i32 %b, i32 1
323 %spec.select = mul nsw i32 %mul, %a
326 return: ; preds = %if.end, %entry
327 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
328 %retval.0 = sext i32 %retval.0.in to i64
332 define i64 @i_a_op_b__1(i32 signext %a, i32 signext %b) {
333 ; CHECK-LABEL: i_a_op_b__1:
334 ; CHECK: # %bb.0: # %entry
335 ; CHECK-NEXT: slw r5, r3, r4
336 ; CHECK-NEXT: cmpwi r5, -1
337 ; CHECK-NEXT: ble cr0, .LBB11_2
338 ; CHECK-NEXT: # %bb.1: # %return
339 ; CHECK-NEXT: extsw r3, r4
341 ; CHECK-NEXT: .LBB11_2: # %if.end
342 ; CHECK-NEXT: li r5, 1
343 ; CHECK-NEXT: isel r4, r4, r5, eq
344 ; CHECK-NEXT: mullw r4, r4, r3
345 ; CHECK-NEXT: extsw r3, r4
348 %shl = shl i32 %a, %b
349 %cmp = icmp sgt i32 %shl, -1
350 br i1 %cmp, label %return, label %if.end
352 if.end: ; preds = %entry
353 %cmp2 = icmp eq i32 %shl, -1
354 %mul = select i1 %cmp2, i32 %b, i32 1
355 %spec.select = mul nsw i32 %mul, %a
358 return: ; preds = %if.end, %entry
359 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
360 %retval.0 = sext i32 %retval.0.in to i64
364 define i64 @i_a_op_b_0(i32 signext %a, i32 signext %b) {
365 ; CHECK-LABEL: i_a_op_b_0:
366 ; CHECK: # %bb.0: # %entry
367 ; CHECK-NEXT: slw r5, r3, r4
368 ; CHECK-NEXT: cmpwi r5, 0
369 ; CHECK-NEXT: ble cr0, .LBB12_2
370 ; CHECK-NEXT: # %bb.1: # %return
371 ; CHECK-NEXT: extsw r3, r4
373 ; CHECK-NEXT: .LBB12_2: # %if.end
374 ; CHECK-NEXT: cmplwi r5, 0
375 ; CHECK-NEXT: li r5, 1
376 ; CHECK-NEXT: isel r4, r4, r5, eq
377 ; CHECK-NEXT: mullw r4, r4, r3
378 ; CHECK-NEXT: extsw r3, r4
381 %shl = shl i32 %a, %b
382 %cmp = icmp sgt i32 %shl, 0
383 br i1 %cmp, label %return, label %if.end
385 if.end: ; preds = %entry
386 %cmp2 = icmp eq i32 %shl, 0
387 %mul = select i1 %cmp2, i32 %b, i32 1
388 %spec.select = mul nsw i32 %mul, %a
391 return: ; preds = %if.end, %entry
392 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
393 %retval.0 = sext i32 %retval.0.in to i64
397 define i64 @i_a_op_b_1(i32 signext %a, i32 signext %b) {
398 ; CHECK-LABEL: i_a_op_b_1:
399 ; CHECK: # %bb.0: # %entry
400 ; CHECK-NEXT: slw r5, r3, r4
401 ; CHECK-NEXT: cmpwi r5, 1
402 ; CHECK-NEXT: bgt cr0, .LBB13_2
403 ; CHECK-NEXT: # %bb.1: # %if.end
404 ; CHECK-NEXT: cmplwi r5, 1
405 ; CHECK-NEXT: li r5, 1
406 ; CHECK-NEXT: isel r4, r4, r5, eq
407 ; CHECK-NEXT: mullw r4, r4, r3
408 ; CHECK-NEXT: .LBB13_2: # %return
409 ; CHECK-NEXT: extsw r3, r4
412 %shl = shl i32 %a, %b
413 %cmp = icmp sgt i32 %shl, 1
414 br i1 %cmp, label %return, label %if.end
416 if.end: ; preds = %entry
417 %cmp2 = icmp eq i32 %shl, 1
418 %mul = select i1 %cmp2, i32 %b, i32 1
419 %spec.select = mul nsw i32 %mul, %a
422 return: ; preds = %if.end, %entry
423 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
424 %retval.0 = sext i32 %retval.0.in to i64
428 define i64 @i_a_op_b_2(i32 signext %a, i32 signext %b) {
429 ; CHECK-LABEL: i_a_op_b_2:
430 ; CHECK: # %bb.0: # %entry
431 ; CHECK-NEXT: slw r5, r3, r4
432 ; CHECK-NEXT: cmpwi r5, 2
433 ; CHECK-NEXT: bgt cr0, .LBB14_2
434 ; CHECK-NEXT: # %bb.1: # %if.end
435 ; CHECK-NEXT: cmplwi r5, 2
436 ; CHECK-NEXT: li r5, 1
437 ; CHECK-NEXT: isel r4, r4, r5, eq
438 ; CHECK-NEXT: mullw r4, r4, r3
439 ; CHECK-NEXT: .LBB14_2: # %return
440 ; CHECK-NEXT: extsw r3, r4
443 %shl = shl i32 %a, %b
444 %cmp = icmp sgt i32 %shl, 2
445 br i1 %cmp, label %return, label %if.end
447 if.end: ; preds = %entry
448 %cmp2 = icmp eq i32 %shl, 2
449 %mul = select i1 %cmp2, i32 %b, i32 1
450 %spec.select = mul nsw i32 %mul, %a
453 return: ; preds = %if.end, %entry
454 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
455 %retval.0 = sext i32 %retval.0.in to i64
459 define i64 @i_a__2(i32 signext %a, i32 signext %b) {
460 ; CHECK-LABEL: i_a__2:
461 ; CHECK: # %bb.0: # %entry
462 ; CHECK-NEXT: cmpwi r3, -2
463 ; CHECK-NEXT: bgt cr0, .LBB15_2
464 ; CHECK-NEXT: # %bb.1: # %if.end
465 ; CHECK-NEXT: li r5, 1
466 ; CHECK-NEXT: isel r4, r4, r5, eq
467 ; CHECK-NEXT: mullw r4, r4, r3
468 ; CHECK-NEXT: .LBB15_2: # %return
469 ; CHECK-NEXT: extsw r3, r4
472 %cmp = icmp sgt i32 %a, -2
473 br i1 %cmp, label %return, label %if.end
475 if.end: ; preds = %entry
476 %cmp1 = icmp eq i32 %a, -2
477 %mul = select i1 %cmp1, i32 %b, i32 1
478 %spec.select = mul nsw i32 %mul, %a
481 return: ; preds = %if.end, %entry
482 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
483 %retval.0 = sext i32 %retval.0.in to i64
487 define i64 @i_a__1(i32 signext %a, i32 signext %b) {
488 ; CHECK-LABEL: i_a__1:
489 ; CHECK: # %bb.0: # %entry
490 ; CHECK-NEXT: cmpwi r3, -1
491 ; CHECK-NEXT: ble cr0, .LBB16_2
492 ; CHECK-NEXT: # %bb.1: # %return
493 ; CHECK-NEXT: extsw r3, r4
495 ; CHECK-NEXT: .LBB16_2: # %if.end
496 ; CHECK-NEXT: li r5, 1
497 ; CHECK-NEXT: isel r4, r4, r5, eq
498 ; CHECK-NEXT: mullw r4, r4, r3
499 ; CHECK-NEXT: extsw r3, r4
502 %cmp = icmp sgt i32 %a, -1
503 br i1 %cmp, label %return, label %if.end
505 if.end: ; preds = %entry
506 %cmp1 = icmp eq i32 %a, -1
507 %mul = select i1 %cmp1, i32 %b, i32 1
508 %spec.select = mul nsw i32 %mul, %a
511 return: ; preds = %if.end, %entry
512 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
513 %retval.0 = sext i32 %retval.0.in to i64
517 define i64 @i_a_0(i32 signext %a, i32 signext %b) {
518 ; CHECK-LABEL: i_a_0:
519 ; CHECK: # %bb.0: # %entry
520 ; CHECK-NEXT: cmpwi r3, 0
521 ; CHECK-NEXT: ble cr0, .LBB17_2
522 ; CHECK-NEXT: # %bb.1: # %return
523 ; CHECK-NEXT: extsw r3, r4
525 ; CHECK-NEXT: .LBB17_2: # %if.end
526 ; CHECK-NEXT: cmplwi r3, 0
527 ; CHECK-NEXT: li r5, 1
528 ; CHECK-NEXT: isel r4, r4, r5, eq
529 ; CHECK-NEXT: mullw r4, r4, r3
530 ; CHECK-NEXT: extsw r3, r4
533 %cmp = icmp sgt i32 %a, 0
534 br i1 %cmp, label %return, label %if.end
536 if.end: ; preds = %entry
537 %cmp1 = icmp eq i32 %a, 0
538 %mul = select i1 %cmp1, i32 %b, i32 1
539 %spec.select = mul nsw i32 %mul, %a
542 return: ; preds = %if.end, %entry
543 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
544 %retval.0 = sext i32 %retval.0.in to i64
548 define i64 @i_a_1(i32 signext %a, i32 signext %b) {
549 ; CHECK-LABEL: i_a_1:
550 ; CHECK: # %bb.0: # %entry
551 ; CHECK-NEXT: cmpwi r3, 1
552 ; CHECK-NEXT: bgt cr0, .LBB18_2
553 ; CHECK-NEXT: # %bb.1: # %if.end
554 ; CHECK-NEXT: cmplwi r3, 1
555 ; CHECK-NEXT: li r5, 1
556 ; CHECK-NEXT: isel r4, r4, r5, eq
557 ; CHECK-NEXT: mullw r4, r4, r3
558 ; CHECK-NEXT: .LBB18_2: # %return
559 ; CHECK-NEXT: extsw r3, r4
562 %cmp = icmp sgt i32 %a, 1
563 br i1 %cmp, label %return, label %if.end
565 if.end: ; preds = %entry
566 %cmp1 = icmp eq i32 %a, 1
567 %mul = select i1 %cmp1, i32 %b, i32 1
568 %spec.select = mul nsw i32 %mul, %a
571 return: ; preds = %if.end, %entry
572 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
573 %retval.0 = sext i32 %retval.0.in to i64
577 define i64 @i_a_2(i32 signext %a, i32 signext %b) {
578 ; CHECK-LABEL: i_a_2:
579 ; CHECK: # %bb.0: # %entry
580 ; CHECK-NEXT: cmpwi r3, 2
581 ; CHECK-NEXT: bgt cr0, .LBB19_2
582 ; CHECK-NEXT: # %bb.1: # %if.end
583 ; CHECK-NEXT: cmplwi r3, 2
584 ; CHECK-NEXT: li r5, 1
585 ; CHECK-NEXT: isel r4, r4, r5, eq
586 ; CHECK-NEXT: mullw r4, r4, r3
587 ; CHECK-NEXT: .LBB19_2: # %return
588 ; CHECK-NEXT: extsw r3, r4
591 %cmp = icmp sgt i32 %a, 2
592 br i1 %cmp, label %return, label %if.end
594 if.end: ; preds = %entry
595 %cmp1 = icmp eq i32 %a, 2
596 %mul = select i1 %cmp1, i32 %b, i32 1
597 %spec.select = mul nsw i32 %mul, %a
600 return: ; preds = %if.end, %entry
601 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
602 %retval.0 = sext i32 %retval.0.in to i64