1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -O3 < %s | FileCheck %s -check-prefix=PPC64LE
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"
16 target triple = "powerpc64le-unknown-linux-gnu"
18 define i64 @ll_a_op_b__2(i64 %a, i64 %b) {
19 ; PPC64LE-LABEL: ll_a_op_b__2:
20 ; PPC64LE: # %bb.0: # %entry
21 ; PPC64LE-NEXT: sld 5, 3, 4
22 ; PPC64LE-NEXT: cmpdi 5, -2
23 ; PPC64LE-NEXT: ble 0, .LBB0_2
24 ; PPC64LE-NEXT: # %bb.1: # %return
25 ; PPC64LE-NEXT: mr 3, 4
27 ; PPC64LE-NEXT: .LBB0_2: # %if.end
28 ; PPC64LE-NEXT: li 5, 1
29 ; PPC64LE-NEXT: isel 4, 4, 5, 2
30 ; PPC64LE-NEXT: mulld 3, 4, 3
34 %cmp = icmp sgt i64 %shl, -2
35 br i1 %cmp, label %return, label %if.end
37 if.end: ; preds = %entry
38 %cmp2 = icmp eq i64 %shl, -2
39 %mul = select i1 %cmp2, i64 %b, i64 1
40 %spec.select = mul nsw i64 %mul, %a
43 return: ; preds = %entry
47 define i64 @ll_a_op_b__1(i64 %a, i64 %b) {
48 ; PPC64LE-LABEL: ll_a_op_b__1:
49 ; PPC64LE: # %bb.0: # %entry
50 ; PPC64LE-NEXT: sld 5, 3, 4
51 ; PPC64LE-NEXT: cmpdi 5, -1
52 ; PPC64LE-NEXT: ble 0, .LBB1_2
53 ; PPC64LE-NEXT: # %bb.1: # %return
54 ; PPC64LE-NEXT: mr 3, 4
56 ; PPC64LE-NEXT: .LBB1_2: # %if.end
57 ; PPC64LE-NEXT: li 5, 1
58 ; PPC64LE-NEXT: isel 4, 4, 5, 2
59 ; PPC64LE-NEXT: mulld 3, 4, 3
63 %cmp = icmp sgt i64 %shl, -1
64 br i1 %cmp, label %return, label %if.end
66 if.end: ; preds = %entry
67 %cmp2 = icmp eq i64 %shl, -1
68 %mul = select i1 %cmp2, i64 %b, i64 1
69 %spec.select = mul nsw i64 %mul, %a
72 return: ; preds = %entry
76 define i64 @ll_a_op_b_0(i64 %a, i64 %b) {
77 ; PPC64LE-LABEL: ll_a_op_b_0:
78 ; PPC64LE: # %bb.0: # %entry
79 ; PPC64LE-NEXT: sld. 5, 3, 4
80 ; PPC64LE-NEXT: ble 0, .LBB2_2
81 ; PPC64LE-NEXT: # %bb.1: # %return
82 ; PPC64LE-NEXT: mr 3, 4
84 ; PPC64LE-NEXT: .LBB2_2: # %if.end
85 ; PPC64LE-NEXT: cmpldi 5, 0
86 ; PPC64LE-NEXT: li 5, 1
87 ; PPC64LE-NEXT: isel 4, 4, 5, 2
88 ; PPC64LE-NEXT: mulld 3, 4, 3
92 %cmp = icmp sgt i64 %shl, 0
93 br i1 %cmp, label %return, label %if.end
95 if.end: ; preds = %entry
96 %cmp2 = icmp eq i64 %shl, 0
97 %mul = select i1 %cmp2, i64 %b, i64 1
98 %spec.select = mul nsw i64 %mul, %a
101 return: ; preds = %entry
105 define i64 @ll_a_op_b_1(i64 %a, i64 %b) {
106 ; PPC64LE-LABEL: ll_a_op_b_1:
107 ; PPC64LE: # %bb.0: # %entry
108 ; PPC64LE-NEXT: sld 5, 3, 4
109 ; PPC64LE-NEXT: cmpdi 5, 1
110 ; PPC64LE-NEXT: ble 0, .LBB3_2
111 ; PPC64LE-NEXT: # %bb.1: # %return
112 ; PPC64LE-NEXT: mr 3, 4
114 ; PPC64LE-NEXT: .LBB3_2: # %if.end
115 ; PPC64LE-NEXT: cmpldi 5, 1
116 ; PPC64LE-NEXT: li 5, 1
117 ; PPC64LE-NEXT: isel 4, 4, 5, 2
118 ; PPC64LE-NEXT: mulld 3, 4, 3
121 %shl = shl i64 %a, %b
122 %cmp = icmp sgt i64 %shl, 1
123 br i1 %cmp, label %return, label %if.end
125 if.end: ; preds = %entry
126 %cmp2 = icmp eq i64 %shl, 1
127 %mul = select i1 %cmp2, i64 %b, i64 1
128 %spec.select = mul nsw i64 %mul, %a
131 return: ; preds = %entry
135 define i64 @ll_a_op_b_2(i64 %a, i64 %b) {
136 ; PPC64LE-LABEL: ll_a_op_b_2:
137 ; PPC64LE: # %bb.0: # %entry
138 ; PPC64LE-NEXT: sld 5, 3, 4
139 ; PPC64LE-NEXT: cmpdi 5, 2
140 ; PPC64LE-NEXT: ble 0, .LBB4_2
141 ; PPC64LE-NEXT: # %bb.1: # %return
142 ; PPC64LE-NEXT: mr 3, 4
144 ; PPC64LE-NEXT: .LBB4_2: # %if.end
145 ; PPC64LE-NEXT: cmpldi 5, 2
146 ; PPC64LE-NEXT: li 5, 1
147 ; PPC64LE-NEXT: isel 4, 4, 5, 2
148 ; PPC64LE-NEXT: mulld 3, 4, 3
151 %shl = shl i64 %a, %b
152 %cmp = icmp sgt i64 %shl, 2
153 br i1 %cmp, label %return, label %if.end
155 if.end: ; preds = %entry
156 %cmp2 = icmp eq i64 %shl, 2
157 %mul = select i1 %cmp2, i64 %b, i64 1
158 %spec.select = mul nsw i64 %mul, %a
161 return: ; preds = %entry
165 define i64 @ll_a__2(i64 %a, i64 %b) {
166 ; PPC64LE-LABEL: ll_a__2:
167 ; PPC64LE: # %bb.0: # %entry
168 ; PPC64LE-NEXT: cmpdi 3, -2
169 ; PPC64LE-NEXT: ble 0, .LBB5_2
170 ; PPC64LE-NEXT: # %bb.1: # %return
171 ; PPC64LE-NEXT: mr 3, 4
173 ; PPC64LE-NEXT: .LBB5_2: # %if.end
174 ; PPC64LE-NEXT: li 5, 1
175 ; PPC64LE-NEXT: isel 4, 4, 5, 2
176 ; PPC64LE-NEXT: mulld 3, 4, 3
179 %cmp = icmp sgt i64 %a, -2
180 br i1 %cmp, label %return, label %if.end
182 if.end: ; preds = %entry
183 %cmp1 = icmp eq i64 %a, -2
184 %mul = select i1 %cmp1, i64 %b, i64 1
185 %spec.select = mul nsw i64 %mul, %a
188 return: ; preds = %entry
192 define i64 @ll_a__1(i64 %a, i64 %b) {
193 ; PPC64LE-LABEL: ll_a__1:
194 ; PPC64LE: # %bb.0: # %entry
195 ; PPC64LE-NEXT: cmpdi 3, -1
196 ; PPC64LE-NEXT: ble 0, .LBB6_2
197 ; PPC64LE-NEXT: # %bb.1: # %return
198 ; PPC64LE-NEXT: mr 3, 4
200 ; PPC64LE-NEXT: .LBB6_2: # %if.end
201 ; PPC64LE-NEXT: li 5, 1
202 ; PPC64LE-NEXT: isel 4, 4, 5, 2
203 ; PPC64LE-NEXT: mulld 3, 4, 3
206 %cmp = icmp sgt i64 %a, -1
207 br i1 %cmp, label %return, label %if.end
209 if.end: ; preds = %entry
210 %cmp1 = icmp eq i64 %a, -1
211 %mul = select i1 %cmp1, i64 %b, i64 1
212 %spec.select = mul nsw i64 %mul, %a
215 return: ; preds = %entry
219 define i64 @ll_a_0(i64 %a, i64 %b) {
220 ; PPC64LE-LABEL: ll_a_0:
221 ; PPC64LE: # %bb.0: # %entry
222 ; PPC64LE-NEXT: cmpdi 3, 0
223 ; PPC64LE-NEXT: ble 0, .LBB7_2
224 ; PPC64LE-NEXT: # %bb.1: # %return
225 ; PPC64LE-NEXT: mr 3, 4
227 ; PPC64LE-NEXT: .LBB7_2: # %if.end
228 ; PPC64LE-NEXT: cmpldi 3, 0
229 ; PPC64LE-NEXT: li 5, 1
230 ; PPC64LE-NEXT: isel 4, 4, 5, 2
231 ; PPC64LE-NEXT: mulld 3, 4, 3
234 %cmp = icmp sgt i64 %a, 0
235 br i1 %cmp, label %return, label %if.end
237 if.end: ; preds = %entry
238 %cmp1 = icmp eq i64 %a, 0
239 %mul = select i1 %cmp1, i64 %b, i64 1
240 %spec.select = mul nsw i64 %mul, %a
243 return: ; preds = %entry
247 define i64 @ll_a_1(i64 %a, i64 %b) {
248 ; PPC64LE-LABEL: ll_a_1:
249 ; PPC64LE: # %bb.0: # %entry
250 ; PPC64LE-NEXT: cmpdi 3, 1
251 ; PPC64LE-NEXT: ble 0, .LBB8_2
252 ; PPC64LE-NEXT: # %bb.1: # %return
253 ; PPC64LE-NEXT: mr 3, 4
255 ; PPC64LE-NEXT: .LBB8_2: # %if.end
256 ; PPC64LE-NEXT: cmpldi 3, 1
257 ; PPC64LE-NEXT: li 5, 1
258 ; PPC64LE-NEXT: isel 4, 4, 5, 2
259 ; PPC64LE-NEXT: mulld 3, 4, 3
262 %cmp = icmp sgt i64 %a, 1
263 br i1 %cmp, label %return, label %if.end
265 if.end: ; preds = %entry
266 %cmp1 = icmp eq i64 %a, 1
267 %mul = select i1 %cmp1, i64 %b, i64 1
268 %spec.select = mul nsw i64 %mul, %a
271 return: ; preds = %entry
275 define i64 @ll_a_2(i64 %a, i64 %b) {
276 ; PPC64LE-LABEL: ll_a_2:
277 ; PPC64LE: # %bb.0: # %entry
278 ; PPC64LE-NEXT: cmpdi 3, 2
279 ; PPC64LE-NEXT: ble 0, .LBB9_2
280 ; PPC64LE-NEXT: # %bb.1: # %return
281 ; PPC64LE-NEXT: mr 3, 4
283 ; PPC64LE-NEXT: .LBB9_2: # %if.end
284 ; PPC64LE-NEXT: cmpldi 3, 2
285 ; PPC64LE-NEXT: li 5, 1
286 ; PPC64LE-NEXT: isel 4, 4, 5, 2
287 ; PPC64LE-NEXT: mulld 3, 4, 3
290 %cmp = icmp sgt i64 %a, 2
291 br i1 %cmp, label %return, label %if.end
293 if.end: ; preds = %entry
294 %cmp1 = icmp eq i64 %a, 2
295 %mul = select i1 %cmp1, i64 %b, i64 1
296 %spec.select = mul nsw i64 %mul, %a
299 return: ; preds = %entry
303 define i64 @i_a_op_b__2(i32 signext %a, i32 signext %b) {
304 ; PPC64LE-LABEL: i_a_op_b__2:
305 ; PPC64LE: # %bb.0: # %entry
306 ; PPC64LE-NEXT: slw 6, 3, 4
307 ; PPC64LE-NEXT: li 5, 1
308 ; PPC64LE-NEXT: cmpwi 6, -2
309 ; PPC64LE-NEXT: isel 5, 4, 5, 2
310 ; PPC64LE-NEXT: mullw 3, 5, 3
311 ; PPC64LE-NEXT: isel 3, 4, 3, 1
312 ; PPC64LE-NEXT: extsw 3, 3
315 %shl = shl i32 %a, %b
316 %cmp = icmp sgt i32 %shl, -2
317 br i1 %cmp, label %return, label %if.end
319 if.end: ; preds = %entry
320 %cmp2 = icmp eq i32 %shl, -2
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 ; PPC64LE-LABEL: i_a_op_b__1:
333 ; PPC64LE: # %bb.0: # %entry
334 ; PPC64LE-NEXT: slw 6, 3, 4
335 ; PPC64LE-NEXT: li 5, 1
336 ; PPC64LE-NEXT: cmpwi 6, -1
337 ; PPC64LE-NEXT: isel 5, 4, 5, 2
338 ; PPC64LE-NEXT: mullw 3, 5, 3
339 ; PPC64LE-NEXT: isel 3, 4, 3, 1
340 ; PPC64LE-NEXT: extsw 3, 3
343 %shl = shl i32 %a, %b
344 %cmp = icmp sgt i32 %shl, -1
345 br i1 %cmp, label %return, label %if.end
347 if.end: ; preds = %entry
348 %cmp2 = icmp eq i32 %shl, -1
349 %mul = select i1 %cmp2, i32 %b, i32 1
350 %spec.select = mul nsw i32 %mul, %a
353 return: ; preds = %if.end, %entry
354 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
355 %retval.0 = sext i32 %retval.0.in to i64
359 define i64 @i_a_op_b_0(i32 signext %a, i32 signext %b) {
360 ; PPC64LE-LABEL: i_a_op_b_0:
361 ; PPC64LE: # %bb.0: # %entry
362 ; PPC64LE-NEXT: slw. 5, 3, 4
363 ; PPC64LE-NEXT: li 6, 1
364 ; PPC64LE-NEXT: isel 6, 4, 6, 2
365 ; PPC64LE-NEXT: cmpwi 5, 0
366 ; PPC64LE-NEXT: mullw 3, 6, 3
367 ; PPC64LE-NEXT: isel 3, 4, 3, 1
368 ; PPC64LE-NEXT: extsw 3, 3
371 %shl = shl i32 %a, %b
372 %cmp = icmp sgt i32 %shl, 0
373 br i1 %cmp, label %return, label %if.end
375 if.end: ; preds = %entry
376 %cmp2 = icmp eq i32 %shl, 0
377 %mul = select i1 %cmp2, i32 %b, i32 1
378 %spec.select = mul nsw i32 %mul, %a
381 return: ; preds = %if.end, %entry
382 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
383 %retval.0 = sext i32 %retval.0.in to i64
387 define i64 @i_a_op_b_1(i32 signext %a, i32 signext %b) {
388 ; PPC64LE-LABEL: i_a_op_b_1:
389 ; PPC64LE: # %bb.0: # %entry
390 ; PPC64LE-NEXT: slw 6, 3, 4
391 ; PPC64LE-NEXT: li 5, 1
392 ; PPC64LE-NEXT: cmplwi 6, 1
393 ; PPC64LE-NEXT: isel 5, 4, 5, 2
394 ; PPC64LE-NEXT: cmpwi 6, 1
395 ; PPC64LE-NEXT: mullw 3, 5, 3
396 ; PPC64LE-NEXT: isel 3, 4, 3, 1
397 ; PPC64LE-NEXT: extsw 3, 3
400 %shl = shl i32 %a, %b
401 %cmp = icmp sgt i32 %shl, 1
402 br i1 %cmp, label %return, label %if.end
404 if.end: ; preds = %entry
405 %cmp2 = icmp eq i32 %shl, 1
406 %mul = select i1 %cmp2, i32 %b, i32 1
407 %spec.select = mul nsw i32 %mul, %a
410 return: ; preds = %if.end, %entry
411 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
412 %retval.0 = sext i32 %retval.0.in to i64
416 define i64 @i_a_op_b_2(i32 signext %a, i32 signext %b) {
417 ; PPC64LE-LABEL: i_a_op_b_2:
418 ; PPC64LE: # %bb.0: # %entry
419 ; PPC64LE-NEXT: slw 6, 3, 4
420 ; PPC64LE-NEXT: li 5, 1
421 ; PPC64LE-NEXT: cmplwi 6, 2
422 ; PPC64LE-NEXT: isel 5, 4, 5, 2
423 ; PPC64LE-NEXT: cmpwi 6, 2
424 ; PPC64LE-NEXT: mullw 3, 5, 3
425 ; PPC64LE-NEXT: isel 3, 4, 3, 1
426 ; PPC64LE-NEXT: extsw 3, 3
429 %shl = shl i32 %a, %b
430 %cmp = icmp sgt i32 %shl, 2
431 br i1 %cmp, label %return, label %if.end
433 if.end: ; preds = %entry
434 %cmp2 = icmp eq i32 %shl, 2
435 %mul = select i1 %cmp2, i32 %b, i32 1
436 %spec.select = mul nsw i32 %mul, %a
439 return: ; preds = %if.end, %entry
440 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
441 %retval.0 = sext i32 %retval.0.in to i64
445 define i64 @i_a__2(i32 signext %a, i32 signext %b) {
446 ; PPC64LE-LABEL: i_a__2:
447 ; PPC64LE: # %bb.0: # %entry
448 ; PPC64LE-NEXT: li 5, 1
449 ; PPC64LE-NEXT: cmpwi 3, -2
450 ; PPC64LE-NEXT: isel 5, 4, 5, 2
451 ; PPC64LE-NEXT: mullw 3, 5, 3
452 ; PPC64LE-NEXT: isel 3, 4, 3, 1
453 ; PPC64LE-NEXT: extsw 3, 3
456 %cmp = icmp sgt i32 %a, -2
457 br i1 %cmp, label %return, label %if.end
459 if.end: ; preds = %entry
460 %cmp1 = icmp eq i32 %a, -2
461 %mul = select i1 %cmp1, i32 %b, i32 1
462 %spec.select = mul nsw i32 %mul, %a
465 return: ; preds = %if.end, %entry
466 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
467 %retval.0 = sext i32 %retval.0.in to i64
471 define i64 @i_a__1(i32 signext %a, i32 signext %b) {
472 ; PPC64LE-LABEL: i_a__1:
473 ; PPC64LE: # %bb.0: # %entry
474 ; PPC64LE-NEXT: li 5, 1
475 ; PPC64LE-NEXT: cmpwi 3, -1
476 ; PPC64LE-NEXT: isel 5, 4, 5, 2
477 ; PPC64LE-NEXT: mullw 3, 5, 3
478 ; PPC64LE-NEXT: isel 3, 4, 3, 1
479 ; PPC64LE-NEXT: extsw 3, 3
482 %cmp = icmp sgt i32 %a, -1
483 br i1 %cmp, label %return, label %if.end
485 if.end: ; preds = %entry
486 %cmp1 = icmp eq i32 %a, -1
487 %mul = select i1 %cmp1, i32 %b, i32 1
488 %spec.select = mul nsw i32 %mul, %a
491 return: ; preds = %if.end, %entry
492 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
493 %retval.0 = sext i32 %retval.0.in to i64
497 define i64 @i_a_0(i32 signext %a, i32 signext %b) {
498 ; PPC64LE-LABEL: i_a_0:
499 ; PPC64LE: # %bb.0: # %entry
500 ; PPC64LE-NEXT: li 5, 1
501 ; PPC64LE-NEXT: cmplwi 3, 0
502 ; PPC64LE-NEXT: isel 5, 4, 5, 2
503 ; PPC64LE-NEXT: cmpwi 0, 3, 0
504 ; PPC64LE-NEXT: mullw 5, 5, 3
505 ; PPC64LE-NEXT: isel 3, 4, 5, 1
506 ; PPC64LE-NEXT: extsw 3, 3
509 %cmp = icmp sgt i32 %a, 0
510 br i1 %cmp, label %return, label %if.end
512 if.end: ; preds = %entry
513 %cmp1 = icmp eq i32 %a, 0
514 %mul = select i1 %cmp1, i32 %b, i32 1
515 %spec.select = mul nsw i32 %mul, %a
518 return: ; preds = %if.end, %entry
519 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
520 %retval.0 = sext i32 %retval.0.in to i64
524 define i64 @i_a_1(i32 signext %a, i32 signext %b) {
525 ; PPC64LE-LABEL: i_a_1:
526 ; PPC64LE: # %bb.0: # %entry
527 ; PPC64LE-NEXT: li 5, 1
528 ; PPC64LE-NEXT: cmplwi 3, 1
529 ; PPC64LE-NEXT: isel 5, 4, 5, 2
530 ; PPC64LE-NEXT: cmpwi 0, 3, 1
531 ; PPC64LE-NEXT: mullw 5, 5, 3
532 ; PPC64LE-NEXT: isel 3, 4, 5, 1
533 ; PPC64LE-NEXT: extsw 3, 3
536 %cmp = icmp sgt i32 %a, 1
537 br i1 %cmp, label %return, label %if.end
539 if.end: ; preds = %entry
540 %cmp1 = icmp eq i32 %a, 1
541 %mul = select i1 %cmp1, i32 %b, i32 1
542 %spec.select = mul nsw i32 %mul, %a
545 return: ; preds = %if.end, %entry
546 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
547 %retval.0 = sext i32 %retval.0.in to i64
551 define i64 @i_a_2(i32 signext %a, i32 signext %b) {
552 ; PPC64LE-LABEL: i_a_2:
553 ; PPC64LE: # %bb.0: # %entry
554 ; PPC64LE-NEXT: li 5, 1
555 ; PPC64LE-NEXT: cmplwi 3, 2
556 ; PPC64LE-NEXT: isel 5, 4, 5, 2
557 ; PPC64LE-NEXT: cmpwi 0, 3, 2
558 ; PPC64LE-NEXT: mullw 5, 5, 3
559 ; PPC64LE-NEXT: isel 3, 4, 5, 1
560 ; PPC64LE-NEXT: extsw 3, 3
563 %cmp = icmp sgt i32 %a, 2
564 br i1 %cmp, label %return, label %if.end
566 if.end: ; preds = %entry
567 %cmp1 = icmp eq i32 %a, 2
568 %mul = select i1 %cmp1, i32 %b, i32 1
569 %spec.select = mul nsw i32 %mul, %a
572 return: ; preds = %if.end, %entry
573 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
574 %retval.0 = sext i32 %retval.0.in to i64