Debian Codegraph @

llvm/test/CodeGen/PowerPC/select_const.ll

raw
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
4
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.
7
8 ; select Cond, 0, 1 --> zext (!Cond)
9
10 define i32 @select_0_or_1(i1 %cond) {
11 ; ALL-LABEL: select_0_or_1:
12 ; ALL: # %bb.0:
13 ; ALL-NEXT: not 3, 3
14 ; ALL-NEXT: clrldi 3, 3, 63
15 ; ALL-NEXT: blr
16 %sel = select i1 %cond, i32 0, i32 1
17 ret i32 %sel
18 }
19
20 define i32 @select_0_or_1_zeroext(i1 zeroext %cond) {
21 ; ALL-LABEL: select_0_or_1_zeroext:
22 ; ALL: # %bb.0:
23 ; ALL-NEXT: xori 3, 3, 1
24 ; ALL-NEXT: blr
25 %sel = select i1 %cond, i32 0, i32 1
26 ret i32 %sel
27 }
28
29 define i32 @select_0_or_1_signext(i1 signext %cond) {
30 ; ALL-LABEL: select_0_or_1_signext:
31 ; ALL: # %bb.0:
32 ; ALL-NEXT: not 3, 3
33 ; ALL-NEXT: clrldi 3, 3, 63
34 ; ALL-NEXT: blr
35 %sel = select i1 %cond, i32 0, i32 1
36 ret i32 %sel
37 }
38
39 ; select Cond, 1, 0 --> zext (Cond)
40
41 define i32 @select_1_or_0(i1 %cond) {
42 ; ALL-LABEL: select_1_or_0:
43 ; ALL: # %bb.0:
44 ; ALL-NEXT: clrldi 3, 3, 63
45 ; ALL-NEXT: blr
46 %sel = select i1 %cond, i32 1, i32 0
47 ret i32 %sel
48 }
49
50 define i32 @select_1_or_0_zeroext(i1 zeroext %cond) {
51 ; ALL-LABEL: select_1_or_0_zeroext:
52 ; ALL: # %bb.0:
53 ; ALL-NEXT: blr
54 %sel = select i1 %cond, i32 1, i32 0
55 ret i32 %sel
56 }
57
58 define i32 @select_1_or_0_signext(i1 signext %cond) {
59 ; ALL-LABEL: select_1_or_0_signext:
60 ; ALL: # %bb.0:
61 ; ALL-NEXT: clrldi 3, 3, 63
62 ; ALL-NEXT: blr
63 %sel = select i1 %cond, i32 1, i32 0
64 ret i32 %sel
65 }
66
67 ; select Cond, 0, -1 --> sext (!Cond)
68
69 define i32 @select_0_or_neg1(i1 %cond) {
70 ; ALL-LABEL: select_0_or_neg1:
71 ; ALL: # %bb.0:
72 ; ALL-NEXT: clrldi 3, 3, 63
73 ; ALL-NEXT: addi 3, 3, -1
74 ; ALL-NEXT: blr
75 %sel = select i1 %cond, i32 0, i32 -1
76 ret i32 %sel
77 }
78
79 define i32 @select_0_or_neg1_zeroext(i1 zeroext %cond) {
80 ; ALL-LABEL: select_0_or_neg1_zeroext:
81 ; ALL: # %bb.0:
82 ; ALL-NEXT: addi 3, 3, -1
83 ; ALL-NEXT: blr
84 %sel = select i1 %cond, i32 0, i32 -1
85 ret i32 %sel
86 }
87
88 define i32 @select_0_or_neg1_signext(i1 signext %cond) {
89 ; ALL-LABEL: select_0_or_neg1_signext:
90 ; ALL: # %bb.0:
91 ; ALL-NEXT: not 3, 3
92 ; ALL-NEXT: blr
93 %sel = select i1 %cond, i32 0, i32 -1
94 ret i32 %sel
95 }
96
97 ; select Cond, -1, 0 --> sext (Cond)
98
99 define i32 @select_neg1_or_0(i1 %cond) {
100 ; ALL-LABEL: select_neg1_or_0:
101 ; ALL: # %bb.0:
102 ; ALL-NEXT: clrldi 3, 3, 63
103 ; ALL-NEXT: neg 3, 3
104 ; ALL-NEXT: blr
105 %sel = select i1 %cond, i32 -1, i32 0
106 ret i32 %sel
107 }
108
109 define i32 @select_neg1_or_0_zeroext(i1 zeroext %cond) {
110 ; ALL-LABEL: select_neg1_or_0_zeroext:
111 ; ALL: # %bb.0:
112 ; ALL-NEXT: neg 3, 3
113 ; ALL-NEXT: blr
114 %sel = select i1 %cond, i32 -1, i32 0
115 ret i32 %sel
116 }
117
118 define i32 @select_neg1_or_0_signext(i1 signext %cond) {
119 ; ALL-LABEL: select_neg1_or_0_signext:
120 ; ALL: # %bb.0:
121 ; ALL-NEXT: blr
122 %sel = select i1 %cond, i32 -1, i32 0
123 ret i32 %sel
124 }
125
126 ; select Cond, C+1, C --> add (zext Cond), C
127
128 define i32 @select_Cplus1_C(i1 %cond) {
129 ; ALL-LABEL: select_Cplus1_C:
130 ; ALL: # %bb.0:
131 ; ALL-NEXT: clrldi 3, 3, 63
132 ; ALL-NEXT: addi 3, 3, 41
133 ; ALL-NEXT: blr
134 %sel = select i1 %cond, i32 42, i32 41
135 ret i32 %sel
136 }
137
138 define i32 @select_Cplus1_C_zeroext(i1 zeroext %cond) {
139 ; ALL-LABEL: select_Cplus1_C_zeroext:
140 ; ALL: # %bb.0:
141 ; ALL-NEXT: addi 3, 3, 41
142 ; ALL-NEXT: blr
143 %sel = select i1 %cond, i32 42, i32 41
144 ret i32 %sel
145 }
146
147 define i32 @select_Cplus1_C_signext(i1 signext %cond) {
148 ; ALL-LABEL: select_Cplus1_C_signext:
149 ; ALL: # %bb.0:
150 ; ALL-NEXT: subfic 3, 3, 41
151 ; ALL-NEXT: blr
152 %sel = select i1 %cond, i32 42, i32 41
153 ret i32 %sel
154 }
155
156 ; select Cond, C, C+1 --> add (sext Cond), C
157
158 define i32 @select_C_Cplus1(i1 %cond) {
159 ; ALL-LABEL: select_C_Cplus1:
160 ; ALL: # %bb.0:
161 ; ALL-NEXT: clrldi 3, 3, 63
162 ; ALL-NEXT: subfic 3, 3, 42
163 ; ALL-NEXT: blr
164 %sel = select i1 %cond, i32 41, i32 42
165 ret i32 %sel
166 }
167
168 define i32 @select_C_Cplus1_zeroext(i1 zeroext %cond) {
169 ; ALL-LABEL: select_C_Cplus1_zeroext:
170 ; ALL: # %bb.0:
171 ; ALL-NEXT: subfic 3, 3, 42
172 ; ALL-NEXT: blr
173 %sel = select i1 %cond, i32 41, i32 42
174 ret i32 %sel
175 }
176
177 define i32 @select_C_Cplus1_signext(i1 signext %cond) {
178 ; ALL-LABEL: select_C_Cplus1_signext:
179 ; ALL: # %bb.0:
180 ; ALL-NEXT: addi 3, 3, 42
181 ; ALL-NEXT: blr
182 %sel = select i1 %cond, i32 41, i32 42
183 ret i32 %sel
184 }
185
186 ; In general, select of 2 constants could be:
187 ; select Cond, C1, C2 --> add (mul (zext Cond), C1-C2), C2 --> add (and (sext Cond), C1-C2), C2
188
189 define i32 @select_C1_C2(i1 %cond) {
190 ; ISEL-LABEL: select_C1_C2:
191 ; ISEL: # %bb.0:
192 ; ISEL-NEXT: andi. 3, 3, 1
193 ; ISEL-NEXT: li 3, 42
194 ; ISEL-NEXT: li 4, 421
195 ; ISEL-NEXT: iselgt 3, 4, 3
196 ; ISEL-NEXT: blr
197 ;
198 ; NO_ISEL-LABEL: select_C1_C2:
199 ; NO_ISEL: # %bb.0:
200 ; NO_ISEL-NEXT: andi. 3, 3, 1
201 ; NO_ISEL-NEXT: li 3, 421
202 ; NO_ISEL-NEXT: bclr 12, 1, 0
203 ; NO_ISEL-NEXT: # %bb.1:
204 ; NO_ISEL-NEXT: li 3, 42
205 ; NO_ISEL-NEXT: blr
206 %sel = select i1 %cond, i32 421, i32 42
207 ret i32 %sel
208 }
209
210 define i32 @select_C1_C2_zeroext(i1 zeroext %cond) {
211 ; ISEL-LABEL: select_C1_C2_zeroext:
212 ; ISEL: # %bb.0:
213 ; ISEL-NEXT: andi. 3, 3, 1
214 ; ISEL-NEXT: li 3, 42
215 ; ISEL-NEXT: li 4, 421
216 ; ISEL-NEXT: iselgt 3, 4, 3
217 ; ISEL-NEXT: blr
218 ;
219 ; NO_ISEL-LABEL: select_C1_C2_zeroext:
220 ; NO_ISEL: # %bb.0:
221 ; NO_ISEL-NEXT: andi. 3, 3, 1
222 ; NO_ISEL-NEXT: li 3, 421
223 ; NO_ISEL-NEXT: bclr 12, 1, 0
224 ; NO_ISEL-NEXT: # %bb.1:
225 ; NO_ISEL-NEXT: li 3, 42
226 ; NO_ISEL-NEXT: blr
227 %sel = select i1 %cond, i32 421, i32 42
228 ret i32 %sel
229 }
230
231 define i32 @select_C1_C2_signext(i1 signext %cond) {
232 ; ISEL-LABEL: select_C1_C2_signext:
233 ; ISEL: # %bb.0:
234 ; ISEL-NEXT: andi. 3, 3, 1
235 ; ISEL-NEXT: li 3, 42
236 ; ISEL-NEXT: li 4, 421
237 ; ISEL-NEXT: iselgt 3, 4, 3
238 ; ISEL-NEXT: blr
239 ;
240 ; NO_ISEL-LABEL: select_C1_C2_signext:
241 ; NO_ISEL: # %bb.0:
242 ; NO_ISEL-NEXT: andi. 3, 3, 1
243 ; NO_ISEL-NEXT: li 3, 421
244 ; NO_ISEL-NEXT: bclr 12, 1, 0
245 ; NO_ISEL-NEXT: # %bb.1:
246 ; NO_ISEL-NEXT: li 3, 42
247 ; NO_ISEL-NEXT: blr
248 %sel = select i1 %cond, i32 421, i32 42
249 ret i32 %sel
250 }
251
252 ; A binary operator with constant after the select should always get folded into the select.
253
254 define i8 @sel_constants_add_constant(i1 %cond) {
255 ; ISEL-LABEL: sel_constants_add_constant:
256 ; ISEL: # %bb.0:
257 ; ISEL-NEXT: andi. 3, 3, 1
258 ; ISEL-NEXT: li 3, 28
259 ; ISEL-NEXT: li 4, 1
260 ; ISEL-NEXT: iselgt 3, 4, 3
261 ; ISEL-NEXT: blr
262 ;
263 ; NO_ISEL-LABEL: sel_constants_add_constant:
264 ; NO_ISEL: # %bb.0:
265 ; NO_ISEL-NEXT: andi. 3, 3, 1
266 ; NO_ISEL-NEXT: li 3, 1
267 ; NO_ISEL-NEXT: bclr 12, 1, 0
268 ; NO_ISEL-NEXT: # %bb.1:
269 ; NO_ISEL-NEXT: li 3, 28
270 ; NO_ISEL-NEXT: blr
271 %sel = select i1 %cond, i8 -4, i8 23
272 %bo = add i8 %sel, 5
273 ret i8 %bo
274 }
275
276 define i8 @sel_constants_sub_constant(i1 %cond) {
277 ; ISEL-LABEL: sel_constants_sub_constant:
278 ; ISEL: # %bb.0:
279 ; ISEL-NEXT: andi. 3, 3, 1
280 ; ISEL-NEXT: li 3, 18
281 ; ISEL-NEXT: li 4, -9
282 ; ISEL-NEXT: iselgt 3, 4, 3
283 ; ISEL-NEXT: blr
284 ;
285 ; NO_ISEL-LABEL: sel_constants_sub_constant:
286 ; NO_ISEL: # %bb.0:
287 ; NO_ISEL-NEXT: andi. 3, 3, 1
288 ; NO_ISEL-NEXT: li 3, -9
289 ; NO_ISEL-NEXT: bclr 12, 1, 0
290 ; NO_ISEL-NEXT: # %bb.1:
291 ; NO_ISEL-NEXT: li 3, 18
292 ; NO_ISEL-NEXT: blr
293 %sel = select i1 %cond, i8 -4, i8 23
294 %bo = sub i8 %sel, 5
295 ret i8 %bo
296 }
297
298 define i8 @sel_constants_sub_constant_sel_constants(i1 %cond) {
299 ; ISEL-LABEL: sel_constants_sub_constant_sel_constants:
300 ; ISEL: # %bb.0:
301 ; ISEL-NEXT: andi. 3, 3, 1
302 ; ISEL-NEXT: li 3, 2
303 ; ISEL-NEXT: li 4, 9
304 ; ISEL-NEXT: iselgt 3, 4, 3
305 ; ISEL-NEXT: blr
306 ;
307 ; NO_ISEL-LABEL: sel_constants_sub_constant_sel_constants:
308 ; NO_ISEL: # %bb.0:
309 ; NO_ISEL-NEXT: andi. 3, 3, 1
310 ; NO_ISEL-NEXT: li 3, 9
311 ; NO_ISEL-NEXT: bclr 12, 1, 0
312 ; NO_ISEL-NEXT: # %bb.1:
313 ; NO_ISEL-NEXT: li 3, 2
314 ; NO_ISEL-NEXT: blr
315 %sel = select i1 %cond, i8 -4, i8 3
316 %bo = sub i8 5, %sel
317 ret i8 %bo
318 }
319
320 define i8 @sel_constants_mul_constant(i1 %cond) {
321 ; ISEL-LABEL: sel_constants_mul_constant:
322 ; ISEL: # %bb.0:
323 ; ISEL-NEXT: andi. 3, 3, 1
324 ; ISEL-NEXT: li 3, 115
325 ; ISEL-NEXT: li 4, -20
326 ; ISEL-NEXT: iselgt 3, 4, 3
327 ; ISEL-NEXT: blr
328 ;
329 ; NO_ISEL-LABEL: sel_constants_mul_constant:
330 ; NO_ISEL: # %bb.0:
331 ; NO_ISEL-NEXT: andi. 3, 3, 1
332 ; NO_ISEL-NEXT: li 3, -20
333 ; NO_ISEL-NEXT: bclr 12, 1, 0
334 ; NO_ISEL-NEXT: # %bb.1:
335 ; NO_ISEL-NEXT: li 3, 115
336 ; NO_ISEL-NEXT: blr
337 %sel = select i1 %cond, i8 -4, i8 23
338 %bo = mul i8 %sel, 5
339 ret i8 %bo
340 }
341
342 define i8 @sel_constants_sdiv_constant(i1 %cond) {
343 ; ISEL-LABEL: sel_constants_sdiv_constant:
344 ; ISEL: # %bb.0:
345 ; ISEL-NEXT: andi. 3, 3, 1
346 ; ISEL-NEXT: li 3, 4
347 ; ISEL-NEXT: iselgt 3, 0, 3
348 ; ISEL-NEXT: blr
349 ;
350 ; NO_ISEL-LABEL: sel_constants_sdiv_constant:
351 ; NO_ISEL: # %bb.0:
352 ; NO_ISEL-NEXT: andi. 3, 3, 1
353 ; NO_ISEL-NEXT: li 3, 0
354 ; NO_ISEL-NEXT: bclr 12, 1, 0
355 ; NO_ISEL-NEXT: # %bb.1:
356 ; NO_ISEL-NEXT: li 3, 4
357 ; NO_ISEL-NEXT: blr
358 %sel = select i1 %cond, i8 -4, i8 23
359 %bo = sdiv i8 %sel, 5
360 ret i8 %bo
361 }
362
363 define i8 @sdiv_constant_sel_constants(i1 %cond) {
364 ; ISEL-LABEL: sdiv_constant_sel_constants:
365 ; ISEL: # %bb.0:
366 ; ISEL-NEXT: andi. 3, 3, 1
367 ; ISEL-NEXT: li 3, 5
368 ; ISEL-NEXT: iselgt 3, 0, 3
369 ; ISEL-NEXT: blr
370 ;
371 ; NO_ISEL-LABEL: sdiv_constant_sel_constants:
372 ; NO_ISEL: # %bb.0:
373 ; NO_ISEL-NEXT: andi. 3, 3, 1
374 ; NO_ISEL-NEXT: li 3, 0
375 ; NO_ISEL-NEXT: bclr 12, 1, 0
376 ; NO_ISEL-NEXT: # %bb.1:
377 ; NO_ISEL-NEXT: li 3, 5
378 ; NO_ISEL-NEXT: blr
379 %sel = select i1 %cond, i8 121, i8 23
380 %bo = sdiv i8 120, %sel
381 ret i8 %bo
382 }
383
384 define i8 @sel_constants_udiv_constant(i1 %cond) {
385 ; ISEL-LABEL: sel_constants_udiv_constant:
386 ; ISEL: # %bb.0:
387 ; ISEL-NEXT: andi. 3, 3, 1
388 ; ISEL-NEXT: li 3, 4
389 ; ISEL-NEXT: li 4, 50
390 ; ISEL-NEXT: iselgt 3, 4, 3
391 ; ISEL-NEXT: blr
392 ;
393 ; NO_ISEL-LABEL: sel_constants_udiv_constant:
394 ; NO_ISEL: # %bb.0:
395 ; NO_ISEL-NEXT: andi. 3, 3, 1
396 ; NO_ISEL-NEXT: li 3, 50
397 ; NO_ISEL-NEXT: bclr 12, 1, 0
398 ; NO_ISEL-NEXT: # %bb.1:
399 ; NO_ISEL-NEXT: li 3, 4
400 ; NO_ISEL-NEXT: blr
401 %sel = select i1 %cond, i8 -4, i8 23
402 %bo = udiv i8 %sel, 5
403 ret i8 %bo
404 }
405
406 define i8 @udiv_constant_sel_constants(i1 %cond) {
407 ; ISEL-LABEL: udiv_constant_sel_constants:
408 ; ISEL: # %bb.0:
409 ; ISEL-NEXT: andi. 3, 3, 1
410 ; ISEL-NEXT: li 3, 5
411 ; ISEL-NEXT: iselgt 3, 0, 3
412 ; ISEL-NEXT: blr
413 ;
414 ; NO_ISEL-LABEL: udiv_constant_sel_constants:
415 ; NO_ISEL: # %bb.0:
416 ; NO_ISEL-NEXT: andi. 3, 3, 1
417 ; NO_ISEL-NEXT: li 3, 0
418 ; NO_ISEL-NEXT: bclr 12, 1, 0
419 ; NO_ISEL-NEXT: # %bb.1:
420 ; NO_ISEL-NEXT: li 3, 5
421 ; NO_ISEL-NEXT: blr
422 %sel = select i1 %cond, i8 -4, i8 23
423 %bo = udiv i8 120, %sel
424 ret i8 %bo
425 }
426
427 define i8 @sel_constants_srem_constant(i1 %cond) {
428 ; ISEL-LABEL: sel_constants_srem_constant:
429 ; ISEL: # %bb.0:
430 ; ISEL-NEXT: andi. 3, 3, 1
431 ; ISEL-NEXT: li 3, 3
432 ; ISEL-NEXT: li 4, -4
433 ; ISEL-NEXT: iselgt 3, 4, 3
434 ; ISEL-NEXT: blr
435 ;
436 ; NO_ISEL-LABEL: sel_constants_srem_constant:
437 ; NO_ISEL: # %bb.0:
438 ; NO_ISEL-NEXT: andi. 3, 3, 1
439 ; NO_ISEL-NEXT: li 3, -4
440 ; NO_ISEL-NEXT: bclr 12, 1, 0
441 ; NO_ISEL-NEXT: # %bb.1:
442 ; NO_ISEL-NEXT: li 3, 3
443 ; NO_ISEL-NEXT: blr
444 %sel = select i1 %cond, i8 -4, i8 23
445 %bo = srem i8 %sel, 5
446 ret i8 %bo
447 }
448
449 define i8 @srem_constant_sel_constants(i1 %cond) {
450 ; ISEL-LABEL: srem_constant_sel_constants:
451 ; ISEL: # %bb.0:
452 ; ISEL-NEXT: andi. 3, 3, 1
453 ; ISEL-NEXT: li 3, 5
454 ; ISEL-NEXT: li 4, 120
455 ; ISEL-NEXT: iselgt 3, 4, 3
456 ; ISEL-NEXT: blr
457 ;
458 ; NO_ISEL-LABEL: srem_constant_sel_constants:
459 ; NO_ISEL: # %bb.0:
460 ; NO_ISEL-NEXT: andi. 3, 3, 1
461 ; NO_ISEL-NEXT: li 3, 120
462 ; NO_ISEL-NEXT: bclr 12, 1, 0
463 ; NO_ISEL-NEXT: # %bb.1:
464 ; NO_ISEL-NEXT: li 3, 5
465 ; NO_ISEL-NEXT: blr
466 %sel = select i1 %cond, i8 121, i8 23
467 %bo = srem i8 120, %sel
468 ret i8 %bo
469 }
470
471 define i8 @sel_constants_urem_constant(i1 %cond) {
472 ; ALL-LABEL: sel_constants_urem_constant:
473 ; ALL: # %bb.0:
474 ; ALL-NEXT: clrldi 3, 3, 63
475 ; ALL-NEXT: xori 3, 3, 3
476 ; ALL-NEXT: blr
477 %sel = select i1 %cond, i8 -4, i8 23
478 %bo = urem i8 %sel, 5
479 ret i8 %bo
480 }
481
482 define i8 @urem_constant_sel_constants(i1 %cond) {
483 ; ISEL-LABEL: urem_constant_sel_constants:
484 ; ISEL: # %bb.0:
485 ; ISEL-NEXT: andi. 3, 3, 1
486 ; ISEL-NEXT: li 3, 5
487 ; ISEL-NEXT: li 4, 120
488 ; ISEL-NEXT: iselgt 3, 4, 3
489 ; ISEL-NEXT: blr
490 ;
491 ; NO_ISEL-LABEL: urem_constant_sel_constants:
492 ; NO_ISEL: # %bb.0:
493 ; NO_ISEL-NEXT: andi. 3, 3, 1
494 ; NO_ISEL-NEXT: li 3, 120
495 ; NO_ISEL-NEXT: bclr 12, 1, 0
496 ; NO_ISEL-NEXT: # %bb.1:
497 ; NO_ISEL-NEXT: li 3, 5
498 ; NO_ISEL-NEXT: blr
499 %sel = select i1 %cond, i8 -4, i8 23
500 %bo = urem i8 120, %sel
501 ret i8 %bo
502 }
503
504 define i8 @sel_constants_and_constant(i1 %cond) {
505 ; ALL-LABEL: sel_constants_and_constant:
506 ; ALL: # %bb.0:
507 ; ALL-NEXT: clrldi 3, 3, 63
508 ; ALL-NEXT: xori 3, 3, 5
509 ; ALL-NEXT: blr
510 %sel = select i1 %cond, i8 -4, i8 23
511 %bo = and i8 %sel, 5
512 ret i8 %bo
513 }
514
515 define i8 @sel_constants_or_constant(i1 %cond) {
516 ; ISEL-LABEL: sel_constants_or_constant:
517 ; ISEL: # %bb.0:
518 ; ISEL-NEXT: andi. 3, 3, 1
519 ; ISEL-NEXT: li 3, 23
520 ; ISEL-NEXT: li 4, -3
521 ; ISEL-NEXT: iselgt 3, 4, 3
522 ; ISEL-NEXT: blr
523 ;
524 ; NO_ISEL-LABEL: sel_constants_or_constant:
525 ; NO_ISEL: # %bb.0:
526 ; NO_ISEL-NEXT: andi. 3, 3, 1
527 ; NO_ISEL-NEXT: li 3, -3
528 ; NO_ISEL-NEXT: bclr 12, 1, 0
529 ; NO_ISEL-NEXT: # %bb.1:
530 ; NO_ISEL-NEXT: li 3, 23
531 ; NO_ISEL-NEXT: blr
532 %sel = select i1 %cond, i8 -4, i8 23
533 %bo = or i8 %sel, 5
534 ret i8 %bo
535 }
536
537 define i8 @sel_constants_xor_constant(i1 %cond) {
538 ; ISEL-LABEL: sel_constants_xor_constant:
539 ; ISEL: # %bb.0:
540 ; ISEL-NEXT: andi. 3, 3, 1
541 ; ISEL-NEXT: li 3, 18
542 ; ISEL-NEXT: li 4, -7
543 ; ISEL-NEXT: iselgt 3, 4, 3
544 ; ISEL-NEXT: blr
545 ;
546 ; NO_ISEL-LABEL: sel_constants_xor_constant:
547 ; NO_ISEL: # %bb.0:
548 ; NO_ISEL-NEXT: andi. 3, 3, 1
549 ; NO_ISEL-NEXT: li 3, -7
550 ; NO_ISEL-NEXT: bclr 12, 1, 0
551 ; NO_ISEL-NEXT: # %bb.1:
552 ; NO_ISEL-NEXT: li 3, 18
553 ; NO_ISEL-NEXT: blr
554 %sel = select i1 %cond, i8 -4, i8 23
555 %bo = xor i8 %sel, 5
556 ret i8 %bo
557 }
558
559 define i8 @sel_constants_shl_constant(i1 %cond) {
560 ; ISEL-LABEL: sel_constants_shl_constant:
561 ; ISEL: # %bb.0:
562 ; ISEL-NEXT: andi. 3, 3, 1
563 ; ISEL-NEXT: li 3, -32
564 ; ISEL-NEXT: li 4, -128
565 ; ISEL-NEXT: iselgt 3, 4, 3
566 ; ISEL-NEXT: blr
567 ;
568 ; NO_ISEL-LABEL: sel_constants_shl_constant:
569 ; NO_ISEL: # %bb.0:
570 ; NO_ISEL-NEXT: andi. 3, 3, 1
571 ; NO_ISEL-NEXT: li 3, -128
572 ; NO_ISEL-NEXT: bclr 12, 1, 0
573 ; NO_ISEL-NEXT: # %bb.1:
574 ; NO_ISEL-NEXT: li 3, -32
575 ; NO_ISEL-NEXT: blr
576 %sel = select i1 %cond, i8 -4, i8 23
577 %bo = shl i8 %sel, 5
578 ret i8 %bo
579 }
580
581 define i8 @shl_constant_sel_constants(i1 %cond) {
582 ; ALL-LABEL: shl_constant_sel_constants:
583 ; ALL: # %bb.0:
584 ; ALL-NEXT: clrlwi 3, 3, 31
585 ; ALL-NEXT: li 4, 1
586 ; ALL-NEXT: xori 3, 3, 3
587 ; ALL-NEXT: slw 3, 4, 3
588 ; ALL-NEXT: blr
589 %sel = select i1 %cond, i8 2, i8 3
590 %bo = shl i8 1, %sel
591 ret i8 %bo
592 }
593
594 define i8 @sel_constants_lshr_constant(i1 %cond) {
595 ; ISEL-LABEL: sel_constants_lshr_constant:
596 ; ISEL: # %bb.0:
597 ; ISEL-NEXT: andi. 3, 3, 1
598 ; ISEL-NEXT: li 3, 0
599 ; ISEL-NEXT: li 4, 7
600 ; ISEL-NEXT: iselgt 3, 4, 3
601 ; ISEL-NEXT: blr
602 ;
603 ; NO_ISEL-LABEL: sel_constants_lshr_constant:
604 ; NO_ISEL: # %bb.0:
605 ; NO_ISEL-NEXT: andi. 3, 3, 1
606 ; NO_ISEL-NEXT: li 3, 7
607 ; NO_ISEL-NEXT: bclr 12, 1, 0
608 ; NO_ISEL-NEXT: # %bb.1:
609 ; NO_ISEL-NEXT: li 3, 0
610 ; NO_ISEL-NEXT: blr
611 %sel = select i1 %cond, i8 -4, i8 23
612 %bo = lshr i8 %sel, 5
613 ret i8 %bo
614 }
615
616 define i8 @lshr_constant_sel_constants(i1 %cond) {
617 ; ALL-LABEL: lshr_constant_sel_constants:
618 ; ALL: # %bb.0:
619 ; ALL-NEXT: clrlwi 3, 3, 31
620 ; ALL-NEXT: li 4, 64
621 ; ALL-NEXT: xori 3, 3, 3
622 ; ALL-NEXT: srw 3, 4, 3
623 ; ALL-NEXT: blr
624 %sel = select i1 %cond, i8 2, i8 3
625 %bo = lshr i8 64, %sel
626 ret i8 %bo
627 }
628
629
630 define i8 @sel_constants_ashr_constant(i1 %cond) {
631 ; ALL-LABEL: sel_constants_ashr_constant:
632 ; ALL: # %bb.0:
633 ; ALL-NEXT: clrlwi 3, 3, 31
634 ; ALL-NEXT: neg 3, 3
635 ; ALL-NEXT: blr
636 %sel = select i1 %cond, i8 -4, i8 23
637 %bo = ashr i8 %sel, 5
638 ret i8 %bo
639 }
640
641 define i8 @ashr_constant_sel_constants(i1 %cond) {
642 ; ALL-LABEL: ashr_constant_sel_constants:
643 ; ALL: # %bb.0:
644 ; ALL-NEXT: clrlwi 3, 3, 31
645 ; ALL-NEXT: li 4, -128
646 ; ALL-NEXT: xori 3, 3, 3
647 ; ALL-NEXT: sraw 3, 4, 3
648 ; ALL-NEXT: blr
649 %sel = select i1 %cond, i8 2, i8 3
650 %bo = ashr i8 128, %sel
651 ret i8 %bo
652 }
653
654 define double @sel_constants_fadd_constant(i1 %cond) {
655 ; ISEL-LABEL: sel_constants_fadd_constant:
656 ; ISEL: # %bb.0:
657 ; ISEL-NEXT: andi. 3, 3, 1
658 ; ISEL-NEXT: addis 3, 2, .LCPI42_0@toc@ha
659 ; ISEL-NEXT: addis 4, 2, .LCPI42_1@toc@ha
660 ; ISEL-NEXT: addi 3, 3, .LCPI42_0@toc@l
661 ; ISEL-NEXT: addi 4, 4, .LCPI42_1@toc@l
662 ; ISEL-NEXT: iselgt 3, 4, 3
663 ; ISEL-NEXT: lfd 1, 0(3)
664 ; ISEL-NEXT: blr
665 ;
666 ; NO_ISEL-LABEL: sel_constants_fadd_constant:
667 ; NO_ISEL: # %bb.0:
668 ; NO_ISEL-NEXT: andi. 3, 3, 1
669 ; NO_ISEL-NEXT: bc 12, 1, .LBB42_2
670 ; NO_ISEL-NEXT: # %bb.1:
671 ; NO_ISEL-NEXT: addis 3, 2, .LCPI42_0@toc@ha
672 ; NO_ISEL-NEXT: addi 3, 3, .LCPI42_0@toc@l
673 ; NO_ISEL-NEXT: lfd 1, 0(3)
674 ; NO_ISEL-NEXT: blr
675 ; NO_ISEL-NEXT: .LBB42_2:
676 ; NO_ISEL-NEXT: addis 3, 2, .LCPI42_1@toc@ha
677 ; NO_ISEL-NEXT: addi 3, 3, .LCPI42_1@toc@l
678 ; NO_ISEL-NEXT: lfd 1, 0(3)
679 ; NO_ISEL-NEXT: blr
680 %sel = select i1 %cond, double -4.0, double 23.3
681 %bo = fadd double %sel, 5.1
682 ret double %bo
683 }
684
685 define double @sel_constants_fsub_constant(i1 %cond) {
686 ; ISEL-LABEL: sel_constants_fsub_constant:
687 ; ISEL: # %bb.0:
688 ; ISEL-NEXT: andi. 3, 3, 1
689 ; ISEL-NEXT: addis 3, 2, .LCPI43_0@toc@ha
690 ; ISEL-NEXT: addis 4, 2, .LCPI43_1@toc@ha
691 ; ISEL-NEXT: addi 3, 3, .LCPI43_0@toc@l
692 ; ISEL-NEXT: addi 4, 4, .LCPI43_1@toc@l
693 ; ISEL-NEXT: iselgt 3, 4, 3
694 ; ISEL-NEXT: lfd 1, 0(3)
695 ; ISEL-NEXT: blr
696 ;
697 ; NO_ISEL-LABEL: sel_constants_fsub_constant:
698 ; NO_ISEL: # %bb.0:
699 ; NO_ISEL-NEXT: andi. 3, 3, 1
700 ; NO_ISEL-NEXT: bc 12, 1, .LBB43_2
701 ; NO_ISEL-NEXT: # %bb.1:
702 ; NO_ISEL-NEXT: addis 3, 2, .LCPI43_0@toc@ha
703 ; NO_ISEL-NEXT: addi 3, 3, .LCPI43_0@toc@l
704 ; NO_ISEL-NEXT: lfd 1, 0(3)
705 ; NO_ISEL-NEXT: blr
706 ; NO_ISEL-NEXT: .LBB43_2:
707 ; NO_ISEL-NEXT: addis 3, 2, .LCPI43_1@toc@ha
708 ; NO_ISEL-NEXT: addi 3, 3, .LCPI43_1@toc@l
709 ; NO_ISEL-NEXT: lfd 1, 0(3)
710 ; NO_ISEL-NEXT: blr
711 %sel = select i1 %cond, double -4.0, double 23.3
712 %bo = fsub double %sel, 5.1
713 ret double %bo
714 }
715
716 define double @fsub_constant_sel_constants(i1 %cond) {
717 ; ISEL-LABEL: fsub_constant_sel_constants:
718 ; ISEL: # %bb.0:
719 ; ISEL-NEXT: andi. 3, 3, 1
720 ; ISEL-NEXT: addis 3, 2, .LCPI44_0@toc@ha
721 ; ISEL-NEXT: addis 4, 2, .LCPI44_1@toc@ha
722 ; ISEL-NEXT: addi 3, 3, .LCPI44_0@toc@l
723 ; ISEL-NEXT: addi 4, 4, .LCPI44_1@toc@l
724 ; ISEL-NEXT: iselgt 3, 4, 3
725 ; ISEL-NEXT: lfd 1, 0(3)
726 ; ISEL-NEXT: blr
727 ;
728 ; NO_ISEL-LABEL: fsub_constant_sel_constants:
729 ; NO_ISEL: # %bb.0:
730 ; NO_ISEL-NEXT: andi. 3, 3, 1
731 ; NO_ISEL-NEXT: bc 12, 1, .LBB44_2
732 ; NO_ISEL-NEXT: # %bb.1:
733 ; NO_ISEL-NEXT: addis 3, 2, .LCPI44_0@toc@ha
734 ; NO_ISEL-NEXT: addi 3, 3, .LCPI44_0@toc@l
735 ; NO_ISEL-NEXT: lfd 1, 0(3)
736 ; NO_ISEL-NEXT: blr
737 ; NO_ISEL-NEXT: .LBB44_2:
738 ; NO_ISEL-NEXT: addis 3, 2, .LCPI44_1@toc@ha
739 ; NO_ISEL-NEXT: addi 3, 3, .LCPI44_1@toc@l
740 ; NO_ISEL-NEXT: lfd 1, 0(3)
741 ; NO_ISEL-NEXT: blr
742 %sel = select i1 %cond, double -4.0, double 23.3
743 %bo = fsub double 5.1, %sel
744 ret double %bo
745 }
746
747 define double @sel_constants_fmul_constant(i1 %cond) {
748 ; ISEL-LABEL: sel_constants_fmul_constant:
749 ; ISEL: # %bb.0:
750 ; ISEL-NEXT: andi. 3, 3, 1
751 ; ISEL-NEXT: addis 3, 2, .LCPI45_0@toc@ha
752 ; ISEL-NEXT: addis 4, 2, .LCPI45_1@toc@ha
753 ; ISEL-NEXT: addi 3, 3, .LCPI45_0@toc@l
754 ; ISEL-NEXT: addi 4, 4, .LCPI45_1@toc@l
755 ; ISEL-NEXT: iselgt 3, 4, 3
756 ; ISEL-NEXT: lfd 1, 0(3)
757 ; ISEL-NEXT: blr
758 ;
759 ; NO_ISEL-LABEL: sel_constants_fmul_constant:
760 ; NO_ISEL: # %bb.0:
761 ; NO_ISEL-NEXT: andi. 3, 3, 1
762 ; NO_ISEL-NEXT: bc 12, 1, .LBB45_2
763 ; NO_ISEL-NEXT: # %bb.1:
764 ; NO_ISEL-NEXT: addis 3, 2, .LCPI45_0@toc@ha
765 ; NO_ISEL-NEXT: addi 3, 3, .LCPI45_0@toc@l
766 ; NO_ISEL-NEXT: lfd 1, 0(3)
767 ; NO_ISEL-NEXT: blr
768 ; NO_ISEL-NEXT: .LBB45_2:
769 ; NO_ISEL-NEXT: addis 3, 2, .LCPI45_1@toc@ha
770 ; NO_ISEL-NEXT: addi 3, 3, .LCPI45_1@toc@l
771 ; NO_ISEL-NEXT: lfd 1, 0(3)
772 ; NO_ISEL-NEXT: blr
773 %sel = select i1 %cond, double -4.0, double 23.3
774 %bo = fmul double %sel, 5.1
775 ret double %bo
776 }
777
778 define double @sel_constants_fdiv_constant(i1 %cond) {
779 ; ISEL-LABEL: sel_constants_fdiv_constant:
780 ; ISEL: # %bb.0:
781 ; ISEL-NEXT: andi. 3, 3, 1
782 ; ISEL-NEXT: addis 3, 2, .LCPI46_0@toc@ha
783 ; ISEL-NEXT: addis 4, 2, .LCPI46_1@toc@ha
784 ; ISEL-NEXT: addi 3, 3, .LCPI46_0@toc@l
785 ; ISEL-NEXT: addi 4, 4, .LCPI46_1@toc@l
786 ; ISEL-NEXT: iselgt 3, 4, 3
787 ; ISEL-NEXT: lfd 1, 0(3)
788 ; ISEL-NEXT: blr
789 ;
790 ; NO_ISEL-LABEL: sel_constants_fdiv_constant:
791 ; NO_ISEL: # %bb.0:
792 ; NO_ISEL-NEXT: andi. 3, 3, 1
793 ; NO_ISEL-NEXT: bc 12, 1, .LBB46_2
794 ; NO_ISEL-NEXT: # %bb.1:
795 ; NO_ISEL-NEXT: addis 3, 2, .LCPI46_0@toc@ha
796 ; NO_ISEL-NEXT: addi 3, 3, .LCPI46_0@toc@l
797 ; NO_ISEL-NEXT: lfd 1, 0(3)
798 ; NO_ISEL-NEXT: blr
799 ; NO_ISEL-NEXT: .LBB46_2:
800 ; NO_ISEL-NEXT: addis 3, 2, .LCPI46_1@toc@ha
801 ; NO_ISEL-NEXT: addi 3, 3, .LCPI46_1@toc@l
802 ; NO_ISEL-NEXT: lfd 1, 0(3)
803 ; NO_ISEL-NEXT: blr
804 %sel = select i1 %cond, double -4.0, double 23.3
805 %bo = fdiv double %sel, 5.1
806 ret double %bo
807 }
808
809 define double @fdiv_constant_sel_constants(i1 %cond) {
810 ; ISEL-LABEL: fdiv_constant_sel_constants:
811 ; ISEL: # %bb.0:
812 ; ISEL-NEXT: andi. 3, 3, 1
813 ; ISEL-NEXT: addis 3, 2, .LCPI47_0@toc@ha
814 ; ISEL-NEXT: addis 4, 2, .LCPI47_1@toc@ha
815 ; ISEL-NEXT: addi 3, 3, .LCPI47_0@toc@l
816 ; ISEL-NEXT: addi 4, 4, .LCPI47_1@toc@l
817 ; ISEL-NEXT: iselgt 3, 4, 3
818 ; ISEL-NEXT: lfd 1, 0(3)
819 ; ISEL-NEXT: blr
820 ;
821 ; NO_ISEL-LABEL: fdiv_constant_sel_constants:
822 ; NO_ISEL: # %bb.0:
823 ; NO_ISEL-NEXT: andi. 3, 3, 1
824 ; NO_ISEL-NEXT: bc 12, 1, .LBB47_2
825 ; NO_ISEL-NEXT: # %bb.1:
826 ; NO_ISEL-NEXT: addis 3, 2, .LCPI47_0@toc@ha
827 ; NO_ISEL-NEXT: addi 3, 3, .LCPI47_0@toc@l
828 ; NO_ISEL-NEXT: lfd 1, 0(3)
829 ; NO_ISEL-NEXT: blr
830 ; NO_ISEL-NEXT: .LBB47_2:
831 ; NO_ISEL-NEXT: addis 3, 2, .LCPI47_1@toc@ha
832 ; NO_ISEL-NEXT: addi 3, 3, .LCPI47_1@toc@l
833 ; NO_ISEL-NEXT: lfd 1, 0(3)
834 ; NO_ISEL-NEXT: blr
835 %sel = select i1 %cond, double -4.0, double 23.3
836 %bo = fdiv double 5.1, %sel
837 ret double %bo
838 }
839
840 define double @sel_constants_frem_constant(i1 %cond) {
841 ; ALL-LABEL: sel_constants_frem_constant:
842 ; ALL: # %bb.0:
843 ; ALL-NEXT: andi. 3, 3, 1
844 ; ALL-NEXT: bc 12, 1, .LBB48_2
845 ; ALL-NEXT: # %bb.1:
846 ; ALL-NEXT: addis 3, 2, .LCPI48_0@toc@ha
847 ; ALL-NEXT: lfd 1, .LCPI48_0@toc@l(3)
848 ; ALL-NEXT: blr
849 ; ALL-NEXT: .LBB48_2:
850 ; ALL-NEXT: vspltisw 2, -4
851 ; ALL-NEXT: xvcvsxwdp 1, 34
852 ; ALL-NEXT: blr
853 %sel = select i1 %cond, double -4.0, double 23.3
854 %bo = frem double %sel, 5.1
855 ret double %bo
856 }
857
858 define double @frem_constant_sel_constants(i1 %cond) {
859 ; ISEL-LABEL: frem_constant_sel_constants:
860 ; ISEL: # %bb.0:
861 ; ISEL-NEXT: andi. 3, 3, 1
862 ; ISEL-NEXT: addis 3, 2, .LCPI49_0@toc@ha
863 ; ISEL-NEXT: addis 4, 2, .LCPI49_1@toc@ha
864 ; ISEL-NEXT: addi 3, 3, .LCPI49_0@toc@l
865 ; ISEL-NEXT: addi 4, 4, .LCPI49_1@toc@l
866 ; ISEL-NEXT: iselgt 3, 4, 3
867 ; ISEL-NEXT: lfd 1, 0(3)
868 ; ISEL-NEXT: blr
869 ;
870 ; NO_ISEL-LABEL: frem_constant_sel_constants:
871 ; NO_ISEL: # %bb.0:
872 ; NO_ISEL-NEXT: andi. 3, 3, 1
873 ; NO_ISEL-NEXT: bc 12, 1, .LBB49_2
874 ; NO_ISEL-NEXT: # %bb.1:
875 ; NO_ISEL-NEXT: addis 3, 2, .LCPI49_0@toc@ha
876 ; NO_ISEL-NEXT: addi 3, 3, .LCPI49_0@toc@l
877 ; NO_ISEL-NEXT: lfd 1, 0(3)
878 ; NO_ISEL-NEXT: blr
879 ; NO_ISEL-NEXT: .LBB49_2:
880 ; NO_ISEL-NEXT: addis 3, 2, .LCPI49_1@toc@ha
881 ; NO_ISEL-NEXT: addi 3, 3, .LCPI49_1@toc@l
882 ; NO_ISEL-NEXT: lfd 1, 0(3)
883 ; NO_ISEL-NEXT: blr
884 %sel = select i1 %cond, double -4.0, double 23.3
885 %bo = frem double 5.1, %sel
886 ret double %bo
887 }