1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=powerpc64le-unknown-unknown -verify-machineinstrs -mattr=+isel | FileCheck %s --check-prefix=ALL --check-prefix=ISEL
3 ; RUN: llc < %s -mtriple=powerpc64le-unknown-unknown -verify-machineinstrs -mattr=-isel | FileCheck %s --check-prefix=ALL --check-prefix=NO_ISEL
5 ; Select of constants: control flow / conditional moves can always be replaced by logic+math (but may not be worth it?).
6 ; Test the zeroext/signext variants of each pattern to see if that makes a difference.
8 ; select Cond, 0, 1 --> zext (!Cond)
10 define i32 @select_0_or_1(i1 %cond) {
11 ; ALL-LABEL: select_0_or_1:
14 ; ALL-NEXT: clrldi 3, 3, 63
16 %sel = select i1 %cond, i32 0, i32 1
20 define i32 @select_0_or_1_zeroext(i1 zeroext %cond) {
21 ; ALL-LABEL: select_0_or_1_zeroext:
23 ; ALL-NEXT: xori 3, 3, 1
25 %sel = select i1 %cond, i32 0, i32 1
29 define i32 @select_0_or_1_signext(i1 signext %cond) {
30 ; ALL-LABEL: select_0_or_1_signext:
33 ; ALL-NEXT: clrldi 3, 3, 63
35 %sel = select i1 %cond, i32 0, i32 1
39 ; select Cond, 1, 0 --> zext (Cond)
41 define i32 @select_1_or_0(i1 %cond) {
42 ; ALL-LABEL: select_1_or_0:
44 ; ALL-NEXT: clrldi 3, 3, 63
46 %sel = select i1 %cond, i32 1, i32 0
50 define i32 @select_1_or_0_zeroext(i1 zeroext %cond) {
51 ; ALL-LABEL: select_1_or_0_zeroext:
54 %sel = select i1 %cond, i32 1, i32 0
58 define i32 @select_1_or_0_signext(i1 signext %cond) {
59 ; ALL-LABEL: select_1_or_0_signext:
61 ; ALL-NEXT: clrldi 3, 3, 63
63 %sel = select i1 %cond, i32 1, i32 0
67 ; select Cond, 0, -1 --> sext (!Cond)
69 define i32 @select_0_or_neg1(i1 %cond) {
70 ; ISEL-LABEL: select_0_or_neg1:
73 ; ISEL-NEXT: andi. 3, 3, 1
74 ; ISEL-NEXT: oris 3, 4, 65535
75 ; ISEL-NEXT: ori 3, 3, 65535
76 ; ISEL-NEXT: isel 3, 0, 3, 1
79 ; NO_ISEL-LABEL: select_0_or_neg1:
81 ; NO_ISEL-NEXT: li 4, 0
82 ; NO_ISEL-NEXT: andi. 3, 3, 1
83 ; NO_ISEL-NEXT: oris 3, 4, 65535
84 ; NO_ISEL-NEXT: ori 3, 3, 65535
85 ; NO_ISEL-NEXT: bc 12, 1, .LBB6_1
87 ; NO_ISEL-NEXT: .LBB6_1:
88 ; NO_ISEL-NEXT: addi 3, 0, 0
90 %sel = select i1 %cond, i32 0, i32 -1
94 define i32 @select_0_or_neg1_zeroext(i1 zeroext %cond) {
95 ; ISEL-LABEL: select_0_or_neg1_zeroext:
98 ; ISEL-NEXT: andi. 3, 3, 1
99 ; ISEL-NEXT: oris 3, 4, 65535
100 ; ISEL-NEXT: ori 3, 3, 65535
101 ; ISEL-NEXT: isel 3, 0, 3, 1
104 ; NO_ISEL-LABEL: select_0_or_neg1_zeroext:
106 ; NO_ISEL-NEXT: li 4, 0
107 ; NO_ISEL-NEXT: andi. 3, 3, 1
108 ; NO_ISEL-NEXT: oris 3, 4, 65535
109 ; NO_ISEL-NEXT: ori 3, 3, 65535
110 ; NO_ISEL-NEXT: bc 12, 1, .LBB7_1
112 ; NO_ISEL-NEXT: .LBB7_1:
113 ; NO_ISEL-NEXT: addi 3, 0, 0
115 %sel = select i1 %cond, i32 0, i32 -1
119 define i32 @select_0_or_neg1_signext(i1 signext %cond) {
120 ; ISEL-LABEL: select_0_or_neg1_signext:
123 ; ISEL-NEXT: andi. 3, 3, 1
124 ; ISEL-NEXT: oris 3, 4, 65535
125 ; ISEL-NEXT: ori 3, 3, 65535
126 ; ISEL-NEXT: isel 3, 0, 3, 1
129 ; NO_ISEL-LABEL: select_0_or_neg1_signext:
131 ; NO_ISEL-NEXT: li 4, 0
132 ; NO_ISEL-NEXT: andi. 3, 3, 1
133 ; NO_ISEL-NEXT: oris 3, 4, 65535
134 ; NO_ISEL-NEXT: ori 3, 3, 65535
135 ; NO_ISEL-NEXT: bc 12, 1, .LBB8_1
137 ; NO_ISEL-NEXT: .LBB8_1:
138 ; NO_ISEL-NEXT: addi 3, 0, 0
140 %sel = select i1 %cond, i32 0, i32 -1
144 ; select Cond, -1, 0 --> sext (Cond)
146 define i32 @select_neg1_or_0(i1 %cond) {
147 ; ISEL-LABEL: select_neg1_or_0:
150 ; ISEL-NEXT: andi. 3, 3, 1
151 ; ISEL-NEXT: oris 3, 4, 65535
152 ; ISEL-NEXT: ori 3, 3, 65535
153 ; ISEL-NEXT: isel 3, 3, 4, 1
156 ; NO_ISEL-LABEL: select_neg1_or_0:
158 ; NO_ISEL-NEXT: li 4, 0
159 ; NO_ISEL-NEXT: andi. 3, 3, 1
160 ; NO_ISEL-NEXT: oris 3, 4, 65535
161 ; NO_ISEL-NEXT: ori 3, 3, 65535
162 ; NO_ISEL-NEXT: bclr 12, 1, 0
163 ; NO_ISEL-NEXT: # %bb.1:
164 ; NO_ISEL-NEXT: ori 3, 4, 0
166 %sel = select i1 %cond, i32 -1, i32 0
170 define i32 @select_neg1_or_0_zeroext(i1 zeroext %cond) {
171 ; ISEL-LABEL: select_neg1_or_0_zeroext:
174 ; ISEL-NEXT: andi. 3, 3, 1
175 ; ISEL-NEXT: oris 3, 4, 65535
176 ; ISEL-NEXT: ori 3, 3, 65535
177 ; ISEL-NEXT: isel 3, 3, 4, 1
180 ; NO_ISEL-LABEL: select_neg1_or_0_zeroext:
182 ; NO_ISEL-NEXT: li 4, 0
183 ; NO_ISEL-NEXT: andi. 3, 3, 1
184 ; NO_ISEL-NEXT: oris 3, 4, 65535
185 ; NO_ISEL-NEXT: ori 3, 3, 65535
186 ; NO_ISEL-NEXT: bclr 12, 1, 0
187 ; NO_ISEL-NEXT: # %bb.1:
188 ; NO_ISEL-NEXT: ori 3, 4, 0
190 %sel = select i1 %cond, i32 -1, i32 0
194 define i32 @select_neg1_or_0_signext(i1 signext %cond) {
195 ; ISEL-LABEL: select_neg1_or_0_signext:
198 ; ISEL-NEXT: andi. 3, 3, 1
199 ; ISEL-NEXT: oris 3, 4, 65535
200 ; ISEL-NEXT: ori 3, 3, 65535
201 ; ISEL-NEXT: isel 3, 3, 4, 1
204 ; NO_ISEL-LABEL: select_neg1_or_0_signext:
206 ; NO_ISEL-NEXT: li 4, 0
207 ; NO_ISEL-NEXT: andi. 3, 3, 1
208 ; NO_ISEL-NEXT: oris 3, 4, 65535
209 ; NO_ISEL-NEXT: ori 3, 3, 65535
210 ; NO_ISEL-NEXT: bclr 12, 1, 0
211 ; NO_ISEL-NEXT: # %bb.1:
212 ; NO_ISEL-NEXT: ori 3, 4, 0
214 %sel = select i1 %cond, i32 -1, i32 0
218 ; select Cond, C+1, C --> add (zext Cond), C
220 define i32 @select_Cplus1_C(i1 %cond) {
221 ; ALL-LABEL: select_Cplus1_C:
223 ; ALL-NEXT: clrldi 3, 3, 63
224 ; ALL-NEXT: addi 3, 3, 41
226 %sel = select i1 %cond, i32 42, i32 41
230 define i32 @select_Cplus1_C_zeroext(i1 zeroext %cond) {
231 ; ALL-LABEL: select_Cplus1_C_zeroext:
233 ; ALL-NEXT: addi 3, 3, 41
235 %sel = select i1 %cond, i32 42, i32 41
239 define i32 @select_Cplus1_C_signext(i1 signext %cond) {
240 ; ALL-LABEL: select_Cplus1_C_signext:
242 ; ALL-NEXT: subfic 3, 3, 41
244 %sel = select i1 %cond, i32 42, i32 41
248 ; select Cond, C, C+1 --> add (sext Cond), C
250 define i32 @select_C_Cplus1(i1 %cond) {
251 ; ALL-LABEL: select_C_Cplus1:
253 ; ALL-NEXT: clrldi 3, 3, 63
254 ; ALL-NEXT: subfic 3, 3, 42
256 %sel = select i1 %cond, i32 41, i32 42
260 define i32 @select_C_Cplus1_zeroext(i1 zeroext %cond) {
261 ; ALL-LABEL: select_C_Cplus1_zeroext:
263 ; ALL-NEXT: subfic 3, 3, 42
265 %sel = select i1 %cond, i32 41, i32 42
269 define i32 @select_C_Cplus1_signext(i1 signext %cond) {
270 ; ALL-LABEL: select_C_Cplus1_signext:
272 ; ALL-NEXT: addi 3, 3, 42
274 %sel = select i1 %cond, i32 41, i32 42
278 ; In general, select of 2 constants could be:
279 ; select Cond, C1, C2 --> add (mul (zext Cond), C1-C2), C2 --> add (and (sext Cond), C1-C2), C2
281 define i32 @select_C1_C2(i1 %cond) {
282 ; ISEL-LABEL: select_C1_C2:
284 ; ISEL-NEXT: andi. 3, 3, 1
285 ; ISEL-NEXT: li 4, 421
286 ; ISEL-NEXT: li 3, 42
287 ; ISEL-NEXT: isel 3, 4, 3, 1
290 ; NO_ISEL-LABEL: select_C1_C2:
292 ; NO_ISEL-NEXT: andi. 3, 3, 1
293 ; NO_ISEL-NEXT: li 4, 421
294 ; NO_ISEL-NEXT: li 3, 42
295 ; NO_ISEL-NEXT: bc 12, 1, .LBB18_1
297 ; NO_ISEL-NEXT: .LBB18_1:
298 ; NO_ISEL-NEXT: addi 3, 4, 0
300 %sel = select i1 %cond, i32 421, i32 42
304 define i32 @select_C1_C2_zeroext(i1 zeroext %cond) {
305 ; ISEL-LABEL: select_C1_C2_zeroext:
307 ; ISEL-NEXT: andi. 3, 3, 1
308 ; ISEL-NEXT: li 4, 421
309 ; ISEL-NEXT: li 3, 42
310 ; ISEL-NEXT: isel 3, 4, 3, 1
313 ; NO_ISEL-LABEL: select_C1_C2_zeroext:
315 ; NO_ISEL-NEXT: andi. 3, 3, 1
316 ; NO_ISEL-NEXT: li 4, 421
317 ; NO_ISEL-NEXT: li 3, 42
318 ; NO_ISEL-NEXT: bc 12, 1, .LBB19_1
320 ; NO_ISEL-NEXT: .LBB19_1:
321 ; NO_ISEL-NEXT: addi 3, 4, 0
323 %sel = select i1 %cond, i32 421, i32 42
327 define i32 @select_C1_C2_signext(i1 signext %cond) {
328 ; ISEL-LABEL: select_C1_C2_signext:
330 ; ISEL-NEXT: andi. 3, 3, 1
331 ; ISEL-NEXT: li 4, 421
332 ; ISEL-NEXT: li 3, 42
333 ; ISEL-NEXT: isel 3, 4, 3, 1
336 ; NO_ISEL-LABEL: select_C1_C2_signext:
338 ; NO_ISEL-NEXT: andi. 3, 3, 1
339 ; NO_ISEL-NEXT: li 4, 421
340 ; NO_ISEL-NEXT: li 3, 42
341 ; NO_ISEL-NEXT: bc 12, 1, .LBB20_1
343 ; NO_ISEL-NEXT: .LBB20_1:
344 ; NO_ISEL-NEXT: addi 3, 4, 0
346 %sel = select i1 %cond, i32 421, i32 42
350 ; A binary operator with constant after the select should always get folded into the select.
352 define i8 @sel_constants_add_constant(i1 %cond) {
353 ; ISEL-LABEL: sel_constants_add_constant:
355 ; ISEL-NEXT: andi. 3, 3, 1
357 ; ISEL-NEXT: li 3, 28
358 ; ISEL-NEXT: isel 3, 4, 3, 1
361 ; NO_ISEL-LABEL: sel_constants_add_constant:
363 ; NO_ISEL-NEXT: andi. 3, 3, 1
364 ; NO_ISEL-NEXT: li 4, 1
365 ; NO_ISEL-NEXT: li 3, 28
366 ; NO_ISEL-NEXT: bc 12, 1, .LBB21_1
368 ; NO_ISEL-NEXT: .LBB21_1:
369 ; NO_ISEL-NEXT: addi 3, 4, 0
371 %sel = select i1 %cond, i8 -4, i8 23
376 define i8 @sel_constants_sub_constant(i1 %cond) {
377 ; ISEL-LABEL: sel_constants_sub_constant:
380 ; ISEL-NEXT: andi. 3, 3, 1
381 ; ISEL-NEXT: oris 3, 4, 65535
382 ; ISEL-NEXT: li 4, 18
383 ; ISEL-NEXT: ori 3, 3, 65527
384 ; ISEL-NEXT: isel 3, 3, 4, 1
387 ; NO_ISEL-LABEL: sel_constants_sub_constant:
389 ; NO_ISEL-NEXT: li 4, 0
390 ; NO_ISEL-NEXT: andi. 3, 3, 1
391 ; NO_ISEL-NEXT: oris 3, 4, 65535
392 ; NO_ISEL-NEXT: li 4, 18
393 ; NO_ISEL-NEXT: ori 3, 3, 65527
394 ; NO_ISEL-NEXT: bclr 12, 1, 0
395 ; NO_ISEL-NEXT: # %bb.1:
396 ; NO_ISEL-NEXT: ori 3, 4, 0
398 %sel = select i1 %cond, i8 -4, i8 23
403 define i8 @sel_constants_sub_constant_sel_constants(i1 %cond) {
404 ; ISEL-LABEL: sel_constants_sub_constant_sel_constants:
406 ; ISEL-NEXT: andi. 3, 3, 1
409 ; ISEL-NEXT: isel 3, 4, 3, 1
412 ; NO_ISEL-LABEL: sel_constants_sub_constant_sel_constants:
414 ; NO_ISEL-NEXT: andi. 3, 3, 1
415 ; NO_ISEL-NEXT: li 4, 9
416 ; NO_ISEL-NEXT: li 3, 2
417 ; NO_ISEL-NEXT: bc 12, 1, .LBB23_1
419 ; NO_ISEL-NEXT: .LBB23_1:
420 ; NO_ISEL-NEXT: addi 3, 4, 0
422 %sel = select i1 %cond, i8 -4, i8 3
427 define i8 @sel_constants_mul_constant(i1 %cond) {
428 ; ISEL-LABEL: sel_constants_mul_constant:
430 ; ISEL-NEXT: lis 4, 16383
431 ; ISEL-NEXT: andi. 3, 3, 1
432 ; ISEL-NEXT: ori 3, 4, 65531
433 ; ISEL-NEXT: li 4, 115
434 ; ISEL-NEXT: sldi 3, 3, 2
435 ; ISEL-NEXT: isel 3, 3, 4, 1
438 ; NO_ISEL-LABEL: sel_constants_mul_constant:
440 ; NO_ISEL-NEXT: lis 4, 16383
441 ; NO_ISEL-NEXT: andi. 3, 3, 1
442 ; NO_ISEL-NEXT: ori 3, 4, 65531
443 ; NO_ISEL-NEXT: li 4, 115
444 ; NO_ISEL-NEXT: sldi 3, 3, 2
445 ; NO_ISEL-NEXT: bclr 12, 1, 0
446 ; NO_ISEL-NEXT: # %bb.1:
447 ; NO_ISEL-NEXT: ori 3, 4, 0
449 %sel = select i1 %cond, i8 -4, i8 23
454 define i8 @sel_constants_sdiv_constant(i1 %cond) {
455 ; ISEL-LABEL: sel_constants_sdiv_constant:
457 ; ISEL-NEXT: andi. 3, 3, 1
459 ; ISEL-NEXT: isel 3, 0, 3, 1
462 ; NO_ISEL-LABEL: sel_constants_sdiv_constant:
464 ; NO_ISEL-NEXT: andi. 3, 3, 1
465 ; NO_ISEL-NEXT: li 3, 4
466 ; NO_ISEL-NEXT: bc 12, 1, .LBB25_1
468 ; NO_ISEL-NEXT: .LBB25_1:
469 ; NO_ISEL-NEXT: addi 3, 0, 0
471 %sel = select i1 %cond, i8 -4, i8 23
472 %bo = sdiv i8 %sel, 5
476 define i8 @sdiv_constant_sel_constants(i1 %cond) {
477 ; ISEL-LABEL: sdiv_constant_sel_constants:
479 ; ISEL-NEXT: andi. 3, 3, 1
481 ; ISEL-NEXT: isel 3, 0, 3, 1
484 ; NO_ISEL-LABEL: sdiv_constant_sel_constants:
486 ; NO_ISEL-NEXT: andi. 3, 3, 1
487 ; NO_ISEL-NEXT: li 3, 5
488 ; NO_ISEL-NEXT: bc 12, 1, .LBB26_1
490 ; NO_ISEL-NEXT: .LBB26_1:
491 ; NO_ISEL-NEXT: addi 3, 0, 0
493 %sel = select i1 %cond, i8 121, i8 23
494 %bo = sdiv i8 120, %sel
498 define i8 @sel_constants_udiv_constant(i1 %cond) {
499 ; ISEL-LABEL: sel_constants_udiv_constant:
501 ; ISEL-NEXT: andi. 3, 3, 1
502 ; ISEL-NEXT: li 4, 50
504 ; ISEL-NEXT: isel 3, 4, 3, 1
507 ; NO_ISEL-LABEL: sel_constants_udiv_constant:
509 ; NO_ISEL-NEXT: andi. 3, 3, 1
510 ; NO_ISEL-NEXT: li 4, 50
511 ; NO_ISEL-NEXT: li 3, 4
512 ; NO_ISEL-NEXT: bc 12, 1, .LBB27_1
514 ; NO_ISEL-NEXT: .LBB27_1:
515 ; NO_ISEL-NEXT: addi 3, 4, 0
517 %sel = select i1 %cond, i8 -4, i8 23
518 %bo = udiv i8 %sel, 5
522 define i8 @udiv_constant_sel_constants(i1 %cond) {
523 ; ISEL-LABEL: udiv_constant_sel_constants:
525 ; ISEL-NEXT: andi. 3, 3, 1
527 ; ISEL-NEXT: isel 3, 0, 3, 1
530 ; NO_ISEL-LABEL: udiv_constant_sel_constants:
532 ; NO_ISEL-NEXT: andi. 3, 3, 1
533 ; NO_ISEL-NEXT: li 3, 5
534 ; NO_ISEL-NEXT: bc 12, 1, .LBB28_1
536 ; NO_ISEL-NEXT: .LBB28_1:
537 ; NO_ISEL-NEXT: addi 3, 0, 0
539 %sel = select i1 %cond, i8 -4, i8 23
540 %bo = udiv i8 120, %sel
544 define i8 @sel_constants_srem_constant(i1 %cond) {
545 ; ISEL-LABEL: sel_constants_srem_constant:
547 ; ISEL-NEXT: lis 4, 16383
548 ; ISEL-NEXT: andi. 3, 3, 1
549 ; ISEL-NEXT: ori 3, 4, 65535
551 ; ISEL-NEXT: sldi 3, 3, 2
552 ; ISEL-NEXT: isel 3, 3, 4, 1
555 ; NO_ISEL-LABEL: sel_constants_srem_constant:
557 ; NO_ISEL-NEXT: lis 4, 16383
558 ; NO_ISEL-NEXT: andi. 3, 3, 1
559 ; NO_ISEL-NEXT: ori 3, 4, 65535
560 ; NO_ISEL-NEXT: li 4, 3
561 ; NO_ISEL-NEXT: sldi 3, 3, 2
562 ; NO_ISEL-NEXT: bclr 12, 1, 0
563 ; NO_ISEL-NEXT: # %bb.1:
564 ; NO_ISEL-NEXT: ori 3, 4, 0
566 %sel = select i1 %cond, i8 -4, i8 23
567 %bo = srem i8 %sel, 5
571 define i8 @srem_constant_sel_constants(i1 %cond) {
572 ; ISEL-LABEL: srem_constant_sel_constants:
574 ; ISEL-NEXT: andi. 3, 3, 1
575 ; ISEL-NEXT: li 4, 120
577 ; ISEL-NEXT: isel 3, 4, 3, 1
580 ; NO_ISEL-LABEL: srem_constant_sel_constants:
582 ; NO_ISEL-NEXT: andi. 3, 3, 1
583 ; NO_ISEL-NEXT: li 4, 120
584 ; NO_ISEL-NEXT: li 3, 5
585 ; NO_ISEL-NEXT: bc 12, 1, .LBB30_1
587 ; NO_ISEL-NEXT: .LBB30_1:
588 ; NO_ISEL-NEXT: addi 3, 4, 0
590 %sel = select i1 %cond, i8 121, i8 23
591 %bo = srem i8 120, %sel
595 define i8 @sel_constants_urem_constant(i1 %cond) {
596 ; ALL-LABEL: sel_constants_urem_constant:
598 ; ALL-NEXT: rlwinm 3, 3, 0, 31, 31
599 ; ALL-NEXT: subfic 3, 3, 3
601 %sel = select i1 %cond, i8 -4, i8 23
602 %bo = urem i8 %sel, 5
606 define i8 @urem_constant_sel_constants(i1 %cond) {
607 ; ISEL-LABEL: urem_constant_sel_constants:
609 ; ISEL-NEXT: andi. 3, 3, 1
610 ; ISEL-NEXT: li 4, 120
612 ; ISEL-NEXT: isel 3, 4, 3, 1
615 ; NO_ISEL-LABEL: urem_constant_sel_constants:
617 ; NO_ISEL-NEXT: andi. 3, 3, 1
618 ; NO_ISEL-NEXT: li 4, 120
619 ; NO_ISEL-NEXT: li 3, 5
620 ; NO_ISEL-NEXT: bc 12, 1, .LBB32_1
622 ; NO_ISEL-NEXT: .LBB32_1:
623 ; NO_ISEL-NEXT: addi 3, 4, 0
625 %sel = select i1 %cond, i8 -4, i8 23
626 %bo = urem i8 120, %sel
630 define i8 @sel_constants_and_constant(i1 %cond) {
631 ; ALL-LABEL: sel_constants_and_constant:
633 ; ALL-NEXT: rlwinm 3, 3, 0, 31, 31
634 ; ALL-NEXT: subfic 3, 3, 5
636 %sel = select i1 %cond, i8 -4, i8 23
641 define i8 @sel_constants_or_constant(i1 %cond) {
642 ; ISEL-LABEL: sel_constants_or_constant:
645 ; ISEL-NEXT: andi. 3, 3, 1
646 ; ISEL-NEXT: oris 3, 4, 65535
647 ; ISEL-NEXT: li 4, 23
648 ; ISEL-NEXT: ori 3, 3, 65533
649 ; ISEL-NEXT: isel 3, 3, 4, 1
652 ; NO_ISEL-LABEL: sel_constants_or_constant:
654 ; NO_ISEL-NEXT: li 4, 0
655 ; NO_ISEL-NEXT: andi. 3, 3, 1
656 ; NO_ISEL-NEXT: oris 3, 4, 65535
657 ; NO_ISEL-NEXT: li 4, 23
658 ; NO_ISEL-NEXT: ori 3, 3, 65533
659 ; NO_ISEL-NEXT: bclr 12, 1, 0
660 ; NO_ISEL-NEXT: # %bb.1:
661 ; NO_ISEL-NEXT: ori 3, 4, 0
663 %sel = select i1 %cond, i8 -4, i8 23
668 define i8 @sel_constants_xor_constant(i1 %cond) {
669 ; ISEL-LABEL: sel_constants_xor_constant:
672 ; ISEL-NEXT: andi. 3, 3, 1
673 ; ISEL-NEXT: oris 3, 4, 65535
674 ; ISEL-NEXT: li 4, 18
675 ; ISEL-NEXT: ori 3, 3, 65529
676 ; ISEL-NEXT: isel 3, 3, 4, 1
679 ; NO_ISEL-LABEL: sel_constants_xor_constant:
681 ; NO_ISEL-NEXT: li 4, 0
682 ; NO_ISEL-NEXT: andi. 3, 3, 1
683 ; NO_ISEL-NEXT: oris 3, 4, 65535
684 ; NO_ISEL-NEXT: li 4, 18
685 ; NO_ISEL-NEXT: ori 3, 3, 65529
686 ; NO_ISEL-NEXT: bclr 12, 1, 0
687 ; NO_ISEL-NEXT: # %bb.1:
688 ; NO_ISEL-NEXT: ori 3, 4, 0
690 %sel = select i1 %cond, i8 -4, i8 23
695 define i8 @sel_constants_shl_constant(i1 %cond) {
696 ; ISEL-LABEL: sel_constants_shl_constant:
698 ; ISEL-NEXT: lis 4, 2047
699 ; ISEL-NEXT: lis 5, 511
700 ; ISEL-NEXT: andi. 3, 3, 1
701 ; ISEL-NEXT: ori 3, 4, 65535
702 ; ISEL-NEXT: ori 4, 5, 65535
703 ; ISEL-NEXT: sldi 3, 3, 5
704 ; ISEL-NEXT: sldi 4, 4, 7
705 ; ISEL-NEXT: isel 3, 4, 3, 1
708 ; NO_ISEL-LABEL: sel_constants_shl_constant:
710 ; NO_ISEL-NEXT: lis 4, 2047
711 ; NO_ISEL-NEXT: lis 5, 511
712 ; NO_ISEL-NEXT: andi. 3, 3, 1
713 ; NO_ISEL-NEXT: ori 3, 4, 65535
714 ; NO_ISEL-NEXT: ori 4, 5, 65535
715 ; NO_ISEL-NEXT: sldi 3, 3, 5
716 ; NO_ISEL-NEXT: sldi 4, 4, 7
717 ; NO_ISEL-NEXT: bc 12, 1, .LBB36_1
719 ; NO_ISEL-NEXT: .LBB36_1:
720 ; NO_ISEL-NEXT: addi 3, 4, 0
722 %sel = select i1 %cond, i8 -4, i8 23
727 define i8 @shl_constant_sel_constants(i1 %cond) {
728 ; ALL-LABEL: shl_constant_sel_constants:
730 ; ALL-NEXT: rlwinm 3, 3, 0, 31, 31
732 ; ALL-NEXT: subfic 3, 3, 3
733 ; ALL-NEXT: slw 3, 4, 3
735 %sel = select i1 %cond, i8 2, i8 3
740 define i8 @sel_constants_lshr_constant(i1 %cond) {
741 ; ISEL-LABEL: sel_constants_lshr_constant:
743 ; ISEL-NEXT: andi. 3, 3, 1
746 ; ISEL-NEXT: isel 3, 4, 3, 1
749 ; NO_ISEL-LABEL: sel_constants_lshr_constant:
751 ; NO_ISEL-NEXT: andi. 3, 3, 1
752 ; NO_ISEL-NEXT: li 4, 7
753 ; NO_ISEL-NEXT: li 3, 0
754 ; NO_ISEL-NEXT: bc 12, 1, .LBB38_1
756 ; NO_ISEL-NEXT: .LBB38_1:
757 ; NO_ISEL-NEXT: addi 3, 4, 0
759 %sel = select i1 %cond, i8 -4, i8 23
760 %bo = lshr i8 %sel, 5
764 define i8 @lshr_constant_sel_constants(i1 %cond) {
765 ; ALL-LABEL: lshr_constant_sel_constants:
767 ; ALL-NEXT: rlwinm 3, 3, 0, 31, 31
769 ; ALL-NEXT: subfic 3, 3, 3
770 ; ALL-NEXT: srw 3, 4, 3
772 %sel = select i1 %cond, i8 2, i8 3
773 %bo = lshr i8 64, %sel
778 define i8 @sel_constants_ashr_constant(i1 %cond) {
779 ; ALL-LABEL: sel_constants_ashr_constant:
781 ; ALL-NEXT: clrldi 3, 3, 63
784 %sel = select i1 %cond, i8 -4, i8 23
785 %bo = ashr i8 %sel, 5
789 define i8 @ashr_constant_sel_constants(i1 %cond) {
790 ; ALL-LABEL: ashr_constant_sel_constants:
792 ; ALL-NEXT: rlwinm 3, 3, 0, 31, 31
793 ; ALL-NEXT: li 4, -128
794 ; ALL-NEXT: subfic 3, 3, 3
795 ; ALL-NEXT: sraw 3, 4, 3
797 %sel = select i1 %cond, i8 2, i8 3
798 %bo = ashr i8 128, %sel
802 define double @sel_constants_fadd_constant(i1 %cond) {
803 ; ISEL-LABEL: sel_constants_fadd_constant:
805 ; ISEL-NEXT: andi. 3, 3, 1
806 ; ISEL-NEXT: addis 4, 2, .LCPI42_0@toc@ha
807 ; ISEL-NEXT: addis 3, 2, .LCPI42_1@toc@ha
808 ; ISEL-NEXT: addi 4, 4, .LCPI42_0@toc@l
809 ; ISEL-NEXT: addi 3, 3, .LCPI42_1@toc@l
810 ; ISEL-NEXT: isel 3, 3, 4, 1
811 ; ISEL-NEXT: lfdx 1, 0, 3
814 ; NO_ISEL-LABEL: sel_constants_fadd_constant:
816 ; NO_ISEL-NEXT: andi. 3, 3, 1
817 ; NO_ISEL-NEXT: addis 4, 2, .LCPI42_0@toc@ha
818 ; NO_ISEL-NEXT: addis 3, 2, .LCPI42_1@toc@ha
819 ; NO_ISEL-NEXT: addi 4, 4, .LCPI42_0@toc@l
820 ; NO_ISEL-NEXT: addi 3, 3, .LCPI42_1@toc@l
821 ; NO_ISEL-NEXT: bc 12, 1, .LBB42_2
822 ; NO_ISEL-NEXT: # %bb.1:
823 ; NO_ISEL-NEXT: ori 3, 4, 0
824 ; NO_ISEL-NEXT: b .LBB42_2
825 ; NO_ISEL-NEXT: .LBB42_2:
826 ; NO_ISEL-NEXT: lfdx 1, 0, 3
828 %sel = select i1 %cond, double -4.0, double 23.3
829 %bo = fadd double %sel, 5.1
833 define double @sel_constants_fsub_constant(i1 %cond) {
834 ; ISEL-LABEL: sel_constants_fsub_constant:
836 ; ISEL-NEXT: andi. 3, 3, 1
837 ; ISEL-NEXT: addis 4, 2, .LCPI43_0@toc@ha
838 ; ISEL-NEXT: addis 3, 2, .LCPI43_1@toc@ha
839 ; ISEL-NEXT: addi 4, 4, .LCPI43_0@toc@l
840 ; ISEL-NEXT: addi 3, 3, .LCPI43_1@toc@l
841 ; ISEL-NEXT: isel 3, 3, 4, 1
842 ; ISEL-NEXT: lfdx 1, 0, 3
845 ; NO_ISEL-LABEL: sel_constants_fsub_constant:
847 ; NO_ISEL-NEXT: andi. 3, 3, 1
848 ; NO_ISEL-NEXT: addis 4, 2, .LCPI43_0@toc@ha
849 ; NO_ISEL-NEXT: addis 3, 2, .LCPI43_1@toc@ha
850 ; NO_ISEL-NEXT: addi 4, 4, .LCPI43_0@toc@l
851 ; NO_ISEL-NEXT: addi 3, 3, .LCPI43_1@toc@l
852 ; NO_ISEL-NEXT: bc 12, 1, .LBB43_2
853 ; NO_ISEL-NEXT: # %bb.1:
854 ; NO_ISEL-NEXT: ori 3, 4, 0
855 ; NO_ISEL-NEXT: b .LBB43_2
856 ; NO_ISEL-NEXT: .LBB43_2:
857 ; NO_ISEL-NEXT: lfdx 1, 0, 3
859 %sel = select i1 %cond, double -4.0, double 23.3
860 %bo = fsub double %sel, 5.1
864 define double @fsub_constant_sel_constants(i1 %cond) {
865 ; ISEL-LABEL: fsub_constant_sel_constants:
867 ; ISEL-NEXT: andi. 3, 3, 1
868 ; ISEL-NEXT: addis 4, 2, .LCPI44_0@toc@ha
869 ; ISEL-NEXT: addis 3, 2, .LCPI44_1@toc@ha
870 ; ISEL-NEXT: addi 4, 4, .LCPI44_0@toc@l
871 ; ISEL-NEXT: addi 3, 3, .LCPI44_1@toc@l
872 ; ISEL-NEXT: isel 3, 3, 4, 1
873 ; ISEL-NEXT: lfdx 1, 0, 3
876 ; NO_ISEL-LABEL: fsub_constant_sel_constants:
878 ; NO_ISEL-NEXT: andi. 3, 3, 1
879 ; NO_ISEL-NEXT: addis 4, 2, .LCPI44_0@toc@ha
880 ; NO_ISEL-NEXT: addis 3, 2, .LCPI44_1@toc@ha
881 ; NO_ISEL-NEXT: addi 4, 4, .LCPI44_0@toc@l
882 ; NO_ISEL-NEXT: addi 3, 3, .LCPI44_1@toc@l
883 ; NO_ISEL-NEXT: bc 12, 1, .LBB44_2
884 ; NO_ISEL-NEXT: # %bb.1:
885 ; NO_ISEL-NEXT: ori 3, 4, 0
886 ; NO_ISEL-NEXT: b .LBB44_2
887 ; NO_ISEL-NEXT: .LBB44_2:
888 ; NO_ISEL-NEXT: lfdx 1, 0, 3
890 %sel = select i1 %cond, double -4.0, double 23.3
891 %bo = fsub double 5.1, %sel
895 define double @sel_constants_fmul_constant(i1 %cond) {
896 ; ISEL-LABEL: sel_constants_fmul_constant:
898 ; ISEL-NEXT: andi. 3, 3, 1
899 ; ISEL-NEXT: addis 4, 2, .LCPI45_0@toc@ha
900 ; ISEL-NEXT: addis 3, 2, .LCPI45_1@toc@ha
901 ; ISEL-NEXT: addi 4, 4, .LCPI45_0@toc@l
902 ; ISEL-NEXT: addi 3, 3, .LCPI45_1@toc@l
903 ; ISEL-NEXT: isel 3, 3, 4, 1
904 ; ISEL-NEXT: lfdx 1, 0, 3
907 ; NO_ISEL-LABEL: sel_constants_fmul_constant:
909 ; NO_ISEL-NEXT: andi. 3, 3, 1
910 ; NO_ISEL-NEXT: addis 4, 2, .LCPI45_0@toc@ha
911 ; NO_ISEL-NEXT: addis 3, 2, .LCPI45_1@toc@ha
912 ; NO_ISEL-NEXT: addi 4, 4, .LCPI45_0@toc@l
913 ; NO_ISEL-NEXT: addi 3, 3, .LCPI45_1@toc@l
914 ; NO_ISEL-NEXT: bc 12, 1, .LBB45_2
915 ; NO_ISEL-NEXT: # %bb.1:
916 ; NO_ISEL-NEXT: ori 3, 4, 0
917 ; NO_ISEL-NEXT: b .LBB45_2
918 ; NO_ISEL-NEXT: .LBB45_2:
919 ; NO_ISEL-NEXT: lfdx 1, 0, 3
921 %sel = select i1 %cond, double -4.0, double 23.3
922 %bo = fmul double %sel, 5.1
926 define double @sel_constants_fdiv_constant(i1 %cond) {
927 ; ISEL-LABEL: sel_constants_fdiv_constant:
929 ; ISEL-NEXT: andi. 3, 3, 1
930 ; ISEL-NEXT: addis 4, 2, .LCPI46_0@toc@ha
931 ; ISEL-NEXT: addis 3, 2, .LCPI46_1@toc@ha
932 ; ISEL-NEXT: addi 4, 4, .LCPI46_0@toc@l
933 ; ISEL-NEXT: addi 3, 3, .LCPI46_1@toc@l
934 ; ISEL-NEXT: isel 3, 3, 4, 1
935 ; ISEL-NEXT: lfdx 1, 0, 3
938 ; NO_ISEL-LABEL: sel_constants_fdiv_constant:
940 ; NO_ISEL-NEXT: andi. 3, 3, 1
941 ; NO_ISEL-NEXT: addis 4, 2, .LCPI46_0@toc@ha
942 ; NO_ISEL-NEXT: addis 3, 2, .LCPI46_1@toc@ha
943 ; NO_ISEL-NEXT: addi 4, 4, .LCPI46_0@toc@l
944 ; NO_ISEL-NEXT: addi 3, 3, .LCPI46_1@toc@l
945 ; NO_ISEL-NEXT: bc 12, 1, .LBB46_2
946 ; NO_ISEL-NEXT: # %bb.1:
947 ; NO_ISEL-NEXT: ori 3, 4, 0
948 ; NO_ISEL-NEXT: b .LBB46_2
949 ; NO_ISEL-NEXT: .LBB46_2:
950 ; NO_ISEL-NEXT: lfdx 1, 0, 3
952 %sel = select i1 %cond, double -4.0, double 23.3
953 %bo = fdiv double %sel, 5.1
957 define double @fdiv_constant_sel_constants(i1 %cond) {
958 ; ISEL-LABEL: fdiv_constant_sel_constants:
960 ; ISEL-NEXT: andi. 3, 3, 1
961 ; ISEL-NEXT: addis 4, 2, .LCPI47_0@toc@ha
962 ; ISEL-NEXT: addis 3, 2, .LCPI47_1@toc@ha
963 ; ISEL-NEXT: addi 4, 4, .LCPI47_0@toc@l
964 ; ISEL-NEXT: addi 3, 3, .LCPI47_1@toc@l
965 ; ISEL-NEXT: isel 3, 3, 4, 1
966 ; ISEL-NEXT: lfdx 1, 0, 3
969 ; NO_ISEL-LABEL: fdiv_constant_sel_constants:
971 ; NO_ISEL-NEXT: andi. 3, 3, 1
972 ; NO_ISEL-NEXT: addis 4, 2, .LCPI47_0@toc@ha
973 ; NO_ISEL-NEXT: addis 3, 2, .LCPI47_1@toc@ha
974 ; NO_ISEL-NEXT: addi 4, 4, .LCPI47_0@toc@l
975 ; NO_ISEL-NEXT: addi 3, 3, .LCPI47_1@toc@l
976 ; NO_ISEL-NEXT: bc 12, 1, .LBB47_2
977 ; NO_ISEL-NEXT: # %bb.1:
978 ; NO_ISEL-NEXT: ori 3, 4, 0
979 ; NO_ISEL-NEXT: b .LBB47_2
980 ; NO_ISEL-NEXT: .LBB47_2:
981 ; NO_ISEL-NEXT: lfdx 1, 0, 3
983 %sel = select i1 %cond, double -4.0, double 23.3
984 %bo = fdiv double 5.1, %sel
988 define double @sel_constants_frem_constant(i1 %cond) {
989 ; ALL-LABEL: sel_constants_frem_constant:
991 ; ALL-NEXT: andi. 3, 3, 1
992 ; ALL-NEXT: bc 12, 1, .LBB48_2
994 ; ALL-NEXT: addis 3, 2, .LCPI48_0@toc@ha
995 ; ALL-NEXT: lfd 1, .LCPI48_0@toc@l(3)
997 ; ALL-NEXT: .LBB48_2:
998 ; ALL-NEXT: addis 3, 2, .LCPI48_1@toc@ha
999 ; ALL-NEXT: lfs 1, .LCPI48_1@toc@l(3)
1001 %sel = select i1 %cond, double -4.0, double 23.3
1002 %bo = frem double %sel, 5.1
1006 define double @frem_constant_sel_constants(i1 %cond) {
1007 ; ISEL-LABEL: frem_constant_sel_constants:
1009 ; ISEL-NEXT: andi. 3, 3, 1
1010 ; ISEL-NEXT: addis 4, 2, .LCPI49_0@toc@ha
1011 ; ISEL-NEXT: addis 3, 2, .LCPI49_1@toc@ha
1012 ; ISEL-NEXT: addi 4, 4, .LCPI49_0@toc@l
1013 ; ISEL-NEXT: addi 3, 3, .LCPI49_1@toc@l
1014 ; ISEL-NEXT: isel 3, 3, 4, 1
1015 ; ISEL-NEXT: lfdx 1, 0, 3
1018 ; NO_ISEL-LABEL: frem_constant_sel_constants:
1020 ; NO_ISEL-NEXT: andi. 3, 3, 1
1021 ; NO_ISEL-NEXT: addis 4, 2, .LCPI49_0@toc@ha
1022 ; NO_ISEL-NEXT: addis 3, 2, .LCPI49_1@toc@ha
1023 ; NO_ISEL-NEXT: addi 4, 4, .LCPI49_0@toc@l
1024 ; NO_ISEL-NEXT: addi 3, 3, .LCPI49_1@toc@l
1025 ; NO_ISEL-NEXT: bc 12, 1, .LBB49_2
1026 ; NO_ISEL-NEXT: # %bb.1:
1027 ; NO_ISEL-NEXT: ori 3, 4, 0
1028 ; NO_ISEL-NEXT: b .LBB49_2
1029 ; NO_ISEL-NEXT: .LBB49_2:
1030 ; NO_ISEL-NEXT: lfdx 1, 0, 3
1032 %sel = select i1 %cond, double -4.0, double 23.3
1033 %bo = frem double 5.1, %sel