Recommit r310809 with a fix for the spill problem
[llvm-core.git] / test / CodeGen / PowerPC / select_const.ll
blob29548123be8881f4e6b943417494493262a3b5c3
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:
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
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
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
39 ; select Cond, 1, 0 --> zext (Cond)
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
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
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
67 ; select Cond, 0, -1 --> sext (!Cond)
69 define i32 @select_0_or_neg1(i1 %cond) {
70 ; ISEL-LABEL: select_0_or_neg1:
71 ; ISEL:       # BB#0:
72 ; ISEL-NEXT:    li 4, 0
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
77 ; ISEL-NEXT:    blr
79 ; NO_ISEL-LABEL: select_0_or_neg1:
80 ; NO_ISEL:       # BB#0:
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
86 ; NO_ISEL-NEXT:    blr
87 ; NO_ISEL-NEXT:  .LBB6_1:
88 ; NO_ISEL-NEXT:    addi 3, 0, 0
89 ; NO_ISEL-NEXT:    blr
90   %sel = select i1 %cond, i32 0, i32 -1
91   ret i32 %sel
94 define i32 @select_0_or_neg1_zeroext(i1 zeroext %cond) {
95 ; ISEL-LABEL: select_0_or_neg1_zeroext:
96 ; ISEL:       # BB#0:
97 ; ISEL-NEXT:    li 4, 0
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
102 ; ISEL-NEXT:    blr
104 ; NO_ISEL-LABEL: select_0_or_neg1_zeroext:
105 ; NO_ISEL:       # BB#0:
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
111 ; NO_ISEL-NEXT:    blr
112 ; NO_ISEL-NEXT:  .LBB7_1:
113 ; NO_ISEL-NEXT:    addi 3, 0, 0
114 ; NO_ISEL-NEXT:    blr
115   %sel = select i1 %cond, i32 0, i32 -1
116   ret i32 %sel
119 define i32 @select_0_or_neg1_signext(i1 signext %cond) {
120 ; ISEL-LABEL: select_0_or_neg1_signext:
121 ; ISEL:       # BB#0:
122 ; ISEL-NEXT:    li 4, 0
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
127 ; ISEL-NEXT:    blr
129 ; NO_ISEL-LABEL: select_0_or_neg1_signext:
130 ; NO_ISEL:       # BB#0:
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
136 ; NO_ISEL-NEXT:    blr
137 ; NO_ISEL-NEXT:  .LBB8_1:
138 ; NO_ISEL-NEXT:    addi 3, 0, 0
139 ; NO_ISEL-NEXT:    blr
140   %sel = select i1 %cond, i32 0, i32 -1
141   ret i32 %sel
144 ; select Cond, -1, 0 --> sext (Cond)
146 define i32 @select_neg1_or_0(i1 %cond) {
147 ; ISEL-LABEL: select_neg1_or_0:
148 ; ISEL:       # BB#0:
149 ; ISEL-NEXT:    li 4, 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
154 ; ISEL-NEXT:    blr
156 ; NO_ISEL-LABEL: select_neg1_or_0:
157 ; NO_ISEL:       # BB#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
165 ; NO_ISEL-NEXT:    blr
166   %sel = select i1 %cond, i32 -1, i32 0
167   ret i32 %sel
170 define i32 @select_neg1_or_0_zeroext(i1 zeroext %cond) {
171 ; ISEL-LABEL: select_neg1_or_0_zeroext:
172 ; ISEL:       # BB#0:
173 ; ISEL-NEXT:    li 4, 0
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
178 ; ISEL-NEXT:    blr
180 ; NO_ISEL-LABEL: select_neg1_or_0_zeroext:
181 ; NO_ISEL:       # BB#0:
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
189 ; NO_ISEL-NEXT:    blr
190   %sel = select i1 %cond, i32 -1, i32 0
191   ret i32 %sel
194 define i32 @select_neg1_or_0_signext(i1 signext %cond) {
195 ; ISEL-LABEL: select_neg1_or_0_signext:
196 ; ISEL:       # BB#0:
197 ; ISEL-NEXT:    li 4, 0
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
202 ; ISEL-NEXT:    blr
204 ; NO_ISEL-LABEL: select_neg1_or_0_signext:
205 ; NO_ISEL:       # BB#0:
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
213 ; NO_ISEL-NEXT:    blr
214   %sel = select i1 %cond, i32 -1, i32 0
215   ret i32 %sel
218 ; select Cond, C+1, C --> add (zext Cond), C
220 define i32 @select_Cplus1_C(i1 %cond) {
221 ; ALL-LABEL: select_Cplus1_C:
222 ; ALL:       # BB#0:
223 ; ALL-NEXT:    clrldi 3, 3, 63
224 ; ALL-NEXT:    addi 3, 3, 41
225 ; ALL-NEXT:    blr
226   %sel = select i1 %cond, i32 42, i32 41
227   ret i32 %sel
230 define i32 @select_Cplus1_C_zeroext(i1 zeroext %cond) {
231 ; ALL-LABEL: select_Cplus1_C_zeroext:
232 ; ALL:       # BB#0:
233 ; ALL-NEXT:    addi 3, 3, 41
234 ; ALL-NEXT:    blr
235   %sel = select i1 %cond, i32 42, i32 41
236   ret i32 %sel
239 define i32 @select_Cplus1_C_signext(i1 signext %cond) {
240 ; ALL-LABEL: select_Cplus1_C_signext:
241 ; ALL:       # BB#0:
242 ; ALL-NEXT:    subfic 3, 3, 41
243 ; ALL-NEXT:    blr
244   %sel = select i1 %cond, i32 42, i32 41
245   ret i32 %sel
248 ; select Cond, C, C+1 --> add (sext Cond), C
250 define i32 @select_C_Cplus1(i1 %cond) {
251 ; ALL-LABEL: select_C_Cplus1:
252 ; ALL:       # BB#0:
253 ; ALL-NEXT:    clrldi 3, 3, 63
254 ; ALL-NEXT:    subfic 3, 3, 42
255 ; ALL-NEXT:    blr
256   %sel = select i1 %cond, i32 41, i32 42
257   ret i32 %sel
260 define i32 @select_C_Cplus1_zeroext(i1 zeroext %cond) {
261 ; ALL-LABEL: select_C_Cplus1_zeroext:
262 ; ALL:       # BB#0:
263 ; ALL-NEXT:    subfic 3, 3, 42
264 ; ALL-NEXT:    blr
265   %sel = select i1 %cond, i32 41, i32 42
266   ret i32 %sel
269 define i32 @select_C_Cplus1_signext(i1 signext %cond) {
270 ; ALL-LABEL: select_C_Cplus1_signext:
271 ; ALL:       # BB#0:
272 ; ALL-NEXT:    addi 3, 3, 42
273 ; ALL-NEXT:    blr
274   %sel = select i1 %cond, i32 41, i32 42
275   ret i32 %sel
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:
283 ; ISEL:       # BB#0:
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
288 ; ISEL-NEXT:    blr
290 ; NO_ISEL-LABEL: select_C1_C2:
291 ; NO_ISEL:       # BB#0:
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
296 ; NO_ISEL-NEXT:    blr
297 ; NO_ISEL-NEXT:  .LBB18_1:
298 ; NO_ISEL-NEXT:    addi 3, 4, 0
299 ; NO_ISEL-NEXT:    blr
300   %sel = select i1 %cond, i32 421, i32 42
301   ret i32 %sel
304 define i32 @select_C1_C2_zeroext(i1 zeroext %cond) {
305 ; ISEL-LABEL: select_C1_C2_zeroext:
306 ; ISEL:       # BB#0:
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
311 ; ISEL-NEXT:    blr
313 ; NO_ISEL-LABEL: select_C1_C2_zeroext:
314 ; NO_ISEL:       # BB#0:
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
319 ; NO_ISEL-NEXT:    blr
320 ; NO_ISEL-NEXT:  .LBB19_1:
321 ; NO_ISEL-NEXT:    addi 3, 4, 0
322 ; NO_ISEL-NEXT:    blr
323   %sel = select i1 %cond, i32 421, i32 42
324   ret i32 %sel
327 define i32 @select_C1_C2_signext(i1 signext %cond) {
328 ; ISEL-LABEL: select_C1_C2_signext:
329 ; ISEL:       # BB#0:
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
334 ; ISEL-NEXT:    blr
336 ; NO_ISEL-LABEL: select_C1_C2_signext:
337 ; NO_ISEL:       # BB#0:
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
342 ; NO_ISEL-NEXT:    blr
343 ; NO_ISEL-NEXT:  .LBB20_1:
344 ; NO_ISEL-NEXT:    addi 3, 4, 0
345 ; NO_ISEL-NEXT:    blr
346   %sel = select i1 %cond, i32 421, i32 42
347   ret i32 %sel
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:
354 ; ISEL:       # BB#0:
355 ; ISEL-NEXT:    andi. 3, 3, 1
356 ; ISEL-NEXT:    li 4, 1
357 ; ISEL-NEXT:    li 3, 28
358 ; ISEL-NEXT:    isel 3, 4, 3, 1
359 ; ISEL-NEXT:    blr
361 ; NO_ISEL-LABEL: sel_constants_add_constant:
362 ; NO_ISEL:       # BB#0:
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
367 ; NO_ISEL-NEXT:    blr
368 ; NO_ISEL-NEXT:  .LBB21_1:
369 ; NO_ISEL-NEXT:    addi 3, 4, 0
370 ; NO_ISEL-NEXT:    blr
371   %sel = select i1 %cond, i8 -4, i8 23
372   %bo = add i8 %sel, 5
373   ret i8 %bo
376 define i8 @sel_constants_sub_constant(i1 %cond) {
377 ; ISEL-LABEL: sel_constants_sub_constant:
378 ; ISEL:       # BB#0:
379 ; ISEL-NEXT:    li 4, 0
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
385 ; ISEL-NEXT:    blr
387 ; NO_ISEL-LABEL: sel_constants_sub_constant:
388 ; NO_ISEL:       # BB#0:
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
397 ; NO_ISEL-NEXT:    blr
398   %sel = select i1 %cond, i8 -4, i8 23
399   %bo = sub i8 %sel, 5
400   ret i8 %bo
403 define i8 @sel_constants_mul_constant(i1 %cond) {
404 ; ISEL-LABEL: sel_constants_mul_constant:
405 ; ISEL:       # BB#0:
406 ; ISEL-NEXT:    lis 4, 16383
407 ; ISEL-NEXT:    andi. 3, 3, 1
408 ; ISEL-NEXT:    ori 3, 4, 65531
409 ; ISEL-NEXT:    li 4, 115
410 ; ISEL-NEXT:    sldi 3, 3, 2
411 ; ISEL-NEXT:    isel 3, 3, 4, 1
412 ; ISEL-NEXT:    blr
414 ; NO_ISEL-LABEL: sel_constants_mul_constant:
415 ; NO_ISEL:       # BB#0:
416 ; NO_ISEL-NEXT:    lis 4, 16383
417 ; NO_ISEL-NEXT:    andi. 3, 3, 1
418 ; NO_ISEL-NEXT:    ori 3, 4, 65531
419 ; NO_ISEL-NEXT:    li 4, 115
420 ; NO_ISEL-NEXT:    sldi 3, 3, 2
421 ; NO_ISEL-NEXT:    bclr 12, 1, 0
422 ; NO_ISEL-NEXT:  # BB#1:
423 ; NO_ISEL-NEXT:    ori 3, 4, 0
424 ; NO_ISEL-NEXT:    blr
425   %sel = select i1 %cond, i8 -4, i8 23
426   %bo = mul i8 %sel, 5
427   ret i8 %bo
430 define i8 @sel_constants_sdiv_constant(i1 %cond) {
431 ; ISEL-LABEL: sel_constants_sdiv_constant:
432 ; ISEL:       # BB#0:
433 ; ISEL-NEXT:    andi. 3, 3, 1
434 ; ISEL-NEXT:    li 3, 4
435 ; ISEL-NEXT:    isel 3, 0, 3, 1
436 ; ISEL-NEXT:    blr
438 ; NO_ISEL-LABEL: sel_constants_sdiv_constant:
439 ; NO_ISEL:       # BB#0:
440 ; NO_ISEL-NEXT:    andi. 3, 3, 1
441 ; NO_ISEL-NEXT:    li 3, 4
442 ; NO_ISEL-NEXT:    bc 12, 1, .LBB24_1
443 ; NO_ISEL-NEXT:    blr
444 ; NO_ISEL-NEXT:  .LBB24_1:
445 ; NO_ISEL-NEXT:    addi 3, 0, 0
446 ; NO_ISEL-NEXT:    blr
447   %sel = select i1 %cond, i8 -4, i8 23
448   %bo = sdiv i8 %sel, 5
449   ret i8 %bo
452 define i8 @sel_constants_udiv_constant(i1 %cond) {
453 ; ISEL-LABEL: sel_constants_udiv_constant:
454 ; ISEL:       # BB#0:
455 ; ISEL-NEXT:    andi. 3, 3, 1
456 ; ISEL-NEXT:    li 4, 50
457 ; ISEL-NEXT:    li 3, 4
458 ; ISEL-NEXT:    isel 3, 4, 3, 1
459 ; ISEL-NEXT:    blr
461 ; NO_ISEL-LABEL: sel_constants_udiv_constant:
462 ; NO_ISEL:       # BB#0:
463 ; NO_ISEL-NEXT:    andi. 3, 3, 1
464 ; NO_ISEL-NEXT:    li 4, 50
465 ; NO_ISEL-NEXT:    li 3, 4
466 ; NO_ISEL-NEXT:    bc 12, 1, .LBB25_1
467 ; NO_ISEL-NEXT:    blr
468 ; NO_ISEL-NEXT:  .LBB25_1:
469 ; NO_ISEL-NEXT:    addi 3, 4, 0
470 ; NO_ISEL-NEXT:    blr
471   %sel = select i1 %cond, i8 -4, i8 23
472   %bo = udiv i8 %sel, 5
473   ret i8 %bo
476 define i8 @sel_constants_srem_constant(i1 %cond) {
477 ; ISEL-LABEL: sel_constants_srem_constant:
478 ; ISEL:       # BB#0:
479 ; ISEL-NEXT:    lis 4, 16383
480 ; ISEL-NEXT:    andi. 3, 3, 1
481 ; ISEL-NEXT:    ori 3, 4, 65535
482 ; ISEL-NEXT:    li 4, 3
483 ; ISEL-NEXT:    sldi 3, 3, 2
484 ; ISEL-NEXT:    isel 3, 3, 4, 1
485 ; ISEL-NEXT:    blr
487 ; NO_ISEL-LABEL: sel_constants_srem_constant:
488 ; NO_ISEL:       # BB#0:
489 ; NO_ISEL-NEXT:    lis 4, 16383
490 ; NO_ISEL-NEXT:    andi. 3, 3, 1
491 ; NO_ISEL-NEXT:    ori 3, 4, 65535
492 ; NO_ISEL-NEXT:    li 4, 3
493 ; NO_ISEL-NEXT:    sldi 3, 3, 2
494 ; NO_ISEL-NEXT:    bclr 12, 1, 0
495 ; NO_ISEL-NEXT:  # BB#1:
496 ; NO_ISEL-NEXT:    ori 3, 4, 0
497 ; NO_ISEL-NEXT:    blr
498   %sel = select i1 %cond, i8 -4, i8 23
499   %bo = srem i8 %sel, 5
500   ret i8 %bo
503 define i8 @sel_constants_urem_constant(i1 %cond) {
504 ; ALL-LABEL: sel_constants_urem_constant:
505 ; ALL:       # BB#0:
506 ; ALL-NEXT:    rlwinm 3, 3, 0, 31, 31
507 ; ALL-NEXT:    subfic 3, 3, 3
508 ; ALL-NEXT:    blr
509   %sel = select i1 %cond, i8 -4, i8 23
510   %bo = urem i8 %sel, 5
511   ret i8 %bo
514 define i8 @sel_constants_and_constant(i1 %cond) {
515 ; ALL-LABEL: sel_constants_and_constant:
516 ; ALL:       # BB#0:
517 ; ALL-NEXT:    rlwinm 3, 3, 0, 31, 31
518 ; ALL-NEXT:    subfic 3, 3, 5
519 ; ALL-NEXT:    blr
520   %sel = select i1 %cond, i8 -4, i8 23
521   %bo = and i8 %sel, 5
522   ret i8 %bo
525 define i8 @sel_constants_or_constant(i1 %cond) {
526 ; ISEL-LABEL: sel_constants_or_constant:
527 ; ISEL:       # BB#0:
528 ; ISEL-NEXT:    li 4, 0
529 ; ISEL-NEXT:    andi. 3, 3, 1
530 ; ISEL-NEXT:    oris 3, 4, 65535
531 ; ISEL-NEXT:    li 4, 23
532 ; ISEL-NEXT:    ori 3, 3, 65533
533 ; ISEL-NEXT:    isel 3, 3, 4, 1
534 ; ISEL-NEXT:    blr
536 ; NO_ISEL-LABEL: sel_constants_or_constant:
537 ; NO_ISEL:       # BB#0:
538 ; NO_ISEL-NEXT:    li 4, 0
539 ; NO_ISEL-NEXT:    andi. 3, 3, 1
540 ; NO_ISEL-NEXT:    oris 3, 4, 65535
541 ; NO_ISEL-NEXT:    li 4, 23
542 ; NO_ISEL-NEXT:    ori 3, 3, 65533
543 ; NO_ISEL-NEXT:    bclr 12, 1, 0
544 ; NO_ISEL-NEXT:  # BB#1:
545 ; NO_ISEL-NEXT:    ori 3, 4, 0
546 ; NO_ISEL-NEXT:    blr
547   %sel = select i1 %cond, i8 -4, i8 23
548   %bo = or i8 %sel, 5
549   ret i8 %bo
552 define i8 @sel_constants_xor_constant(i1 %cond) {
553 ; ISEL-LABEL: sel_constants_xor_constant:
554 ; ISEL:       # BB#0:
555 ; ISEL-NEXT:    li 4, 0
556 ; ISEL-NEXT:    andi. 3, 3, 1
557 ; ISEL-NEXT:    oris 3, 4, 65535
558 ; ISEL-NEXT:    li 4, 18
559 ; ISEL-NEXT:    ori 3, 3, 65529
560 ; ISEL-NEXT:    isel 3, 3, 4, 1
561 ; ISEL-NEXT:    blr
563 ; NO_ISEL-LABEL: sel_constants_xor_constant:
564 ; NO_ISEL:       # BB#0:
565 ; NO_ISEL-NEXT:    li 4, 0
566 ; NO_ISEL-NEXT:    andi. 3, 3, 1
567 ; NO_ISEL-NEXT:    oris 3, 4, 65535
568 ; NO_ISEL-NEXT:    li 4, 18
569 ; NO_ISEL-NEXT:    ori 3, 3, 65529
570 ; NO_ISEL-NEXT:    bclr 12, 1, 0
571 ; NO_ISEL-NEXT:  # BB#1:
572 ; NO_ISEL-NEXT:    ori 3, 4, 0
573 ; NO_ISEL-NEXT:    blr
574   %sel = select i1 %cond, i8 -4, i8 23
575   %bo = xor i8 %sel, 5
576   ret i8 %bo
579 define i8 @sel_constants_shl_constant(i1 %cond) {
580 ; ISEL-LABEL: sel_constants_shl_constant:
581 ; ISEL:       # BB#0:
582 ; ISEL-NEXT:    lis 5, 511
583 ; ISEL-NEXT:    lis 4, 2047
584 ; ISEL-NEXT:    andi. 3, 3, 1
585 ; ISEL-NEXT:    ori 3, 4, 65535
586 ; ISEL-NEXT:    ori 12, 5, 65535
587 ; ISEL-NEXT:    sldi 3, 3, 5
588 ; ISEL-NEXT:    sldi 4, 12, 7
589 ; ISEL-NEXT:    isel 3, 4, 3, 1
590 ; ISEL-NEXT:    blr
592 ; NO_ISEL-LABEL: sel_constants_shl_constant:
593 ; NO_ISEL:       # BB#0:
594 ; NO_ISEL-NEXT:    lis 5, 511
595 ; NO_ISEL-NEXT:    lis 4, 2047
596 ; NO_ISEL-NEXT:    andi. 3, 3, 1
597 ; NO_ISEL-NEXT:    ori 3, 4, 65535
598 ; NO_ISEL-NEXT:    ori 12, 5, 65535
599 ; NO_ISEL-NEXT:    sldi 3, 3, 5
600 ; NO_ISEL-NEXT:    sldi 4, 12, 7
601 ; NO_ISEL-NEXT:    bc 12, 1, .LBB31_1
602 ; NO_ISEL-NEXT:    blr
603 ; NO_ISEL-NEXT:  .LBB31_1:
604 ; NO_ISEL-NEXT:    addi 3, 4, 0
605 ; NO_ISEL-NEXT:    blr
606   %sel = select i1 %cond, i8 -4, i8 23
607   %bo = shl i8 %sel, 5
608   ret i8 %bo
611 define i8 @sel_constants_lshr_constant(i1 %cond) {
612 ; ISEL-LABEL: sel_constants_lshr_constant:
613 ; ISEL:       # BB#0:
614 ; ISEL-NEXT:    andi. 3, 3, 1
615 ; ISEL-NEXT:    li 4, 7
616 ; ISEL-NEXT:    li 3, 0
617 ; ISEL-NEXT:    isel 3, 4, 3, 1
618 ; ISEL-NEXT:    blr
620 ; NO_ISEL-LABEL: sel_constants_lshr_constant:
621 ; NO_ISEL:       # BB#0:
622 ; NO_ISEL-NEXT:    andi. 3, 3, 1
623 ; NO_ISEL-NEXT:    li 4, 7
624 ; NO_ISEL-NEXT:    li 3, 0
625 ; NO_ISEL-NEXT:    bc 12, 1, .LBB32_1
626 ; NO_ISEL-NEXT:    blr
627 ; NO_ISEL-NEXT:  .LBB32_1:
628 ; NO_ISEL-NEXT:    addi 3, 4, 0
629 ; NO_ISEL-NEXT:    blr
630   %sel = select i1 %cond, i8 -4, i8 23
631   %bo = lshr i8 %sel, 5
632   ret i8 %bo
635 define i8 @sel_constants_ashr_constant(i1 %cond) {
636 ; ALL-LABEL: sel_constants_ashr_constant:
637 ; ALL:       # BB#0:
638 ; ALL-NEXT:    clrldi 3, 3, 63
639 ; ALL-NEXT:    neg 3, 3
640 ; ALL-NEXT:    blr
641   %sel = select i1 %cond, i8 -4, i8 23
642   %bo = ashr i8 %sel, 5
643   ret i8 %bo
646 define double @sel_constants_fadd_constant(i1 %cond) {
647 ; ISEL-LABEL: sel_constants_fadd_constant:
648 ; ISEL:       # BB#0:
649 ; ISEL-NEXT:    andi. 3, 3, 1
650 ; ISEL-NEXT:    addis 4, 2, .LCPI34_0@toc@ha
651 ; ISEL-NEXT:    addis 3, 2, .LCPI34_1@toc@ha
652 ; ISEL-NEXT:    addi 4, 4, .LCPI34_0@toc@l
653 ; ISEL-NEXT:    addi 3, 3, .LCPI34_1@toc@l
654 ; ISEL-NEXT:    isel 3, 3, 4, 1
655 ; ISEL-NEXT:    lxsdx 1, 0, 3
656 ; ISEL-NEXT:    blr
658 ; NO_ISEL-LABEL: sel_constants_fadd_constant:
659 ; NO_ISEL:       # BB#0:
660 ; NO_ISEL-NEXT:    andi. 3, 3, 1
661 ; NO_ISEL-NEXT:    addis 4, 2, .LCPI34_0@toc@ha
662 ; NO_ISEL-NEXT:    addis 3, 2, .LCPI34_1@toc@ha
663 ; NO_ISEL-NEXT:    addi 4, 4, .LCPI34_0@toc@l
664 ; NO_ISEL-NEXT:    addi 3, 3, .LCPI34_1@toc@l
665 ; NO_ISEL-NEXT:    bc 12, 1, .LBB34_2
666 ; NO_ISEL-NEXT:  # BB#1:
667 ; NO_ISEL-NEXT:    ori 3, 4, 0
668 ; NO_ISEL-NEXT:    b .LBB34_2
669 ; NO_ISEL-NEXT:  .LBB34_2:
670 ; NO_ISEL-NEXT:    lxsdx 1, 0, 3
671 ; NO_ISEL-NEXT:    blr
672   %sel = select i1 %cond, double -4.0, double 23.3
673   %bo = fadd double %sel, 5.1
674   ret double %bo
677 define double @sel_constants_fsub_constant(i1 %cond) {
678 ; ISEL-LABEL: sel_constants_fsub_constant:
679 ; ISEL:       # BB#0:
680 ; ISEL-NEXT:    andi. 3, 3, 1
681 ; ISEL-NEXT:    addis 4, 2, .LCPI35_0@toc@ha
682 ; ISEL-NEXT:    addis 3, 2, .LCPI35_1@toc@ha
683 ; ISEL-NEXT:    addi 4, 4, .LCPI35_0@toc@l
684 ; ISEL-NEXT:    addi 3, 3, .LCPI35_1@toc@l
685 ; ISEL-NEXT:    isel 3, 3, 4, 1
686 ; ISEL-NEXT:    lxsdx 1, 0, 3
687 ; ISEL-NEXT:    blr
689 ; NO_ISEL-LABEL: sel_constants_fsub_constant:
690 ; NO_ISEL:       # BB#0:
691 ; NO_ISEL-NEXT:    andi. 3, 3, 1
692 ; NO_ISEL-NEXT:    addis 4, 2, .LCPI35_0@toc@ha
693 ; NO_ISEL-NEXT:    addis 3, 2, .LCPI35_1@toc@ha
694 ; NO_ISEL-NEXT:    addi 4, 4, .LCPI35_0@toc@l
695 ; NO_ISEL-NEXT:    addi 3, 3, .LCPI35_1@toc@l
696 ; NO_ISEL-NEXT:    bc 12, 1, .LBB35_2
697 ; NO_ISEL-NEXT:  # BB#1:
698 ; NO_ISEL-NEXT:    ori 3, 4, 0
699 ; NO_ISEL-NEXT:    b .LBB35_2
700 ; NO_ISEL-NEXT:  .LBB35_2:
701 ; NO_ISEL-NEXT:    lxsdx 1, 0, 3
702 ; NO_ISEL-NEXT:    blr
703   %sel = select i1 %cond, double -4.0, double 23.3
704   %bo = fsub double %sel, 5.1
705   ret double %bo
708 define double @sel_constants_fmul_constant(i1 %cond) {
709 ; ISEL-LABEL: sel_constants_fmul_constant:
710 ; ISEL:       # BB#0:
711 ; ISEL-NEXT:    andi. 3, 3, 1
712 ; ISEL-NEXT:    addis 4, 2, .LCPI36_0@toc@ha
713 ; ISEL-NEXT:    addis 3, 2, .LCPI36_1@toc@ha
714 ; ISEL-NEXT:    addi 4, 4, .LCPI36_0@toc@l
715 ; ISEL-NEXT:    addi 3, 3, .LCPI36_1@toc@l
716 ; ISEL-NEXT:    isel 3, 3, 4, 1
717 ; ISEL-NEXT:    lxsdx 1, 0, 3
718 ; ISEL-NEXT:    blr
720 ; NO_ISEL-LABEL: sel_constants_fmul_constant:
721 ; NO_ISEL:       # BB#0:
722 ; NO_ISEL-NEXT:    andi. 3, 3, 1
723 ; NO_ISEL-NEXT:    addis 4, 2, .LCPI36_0@toc@ha
724 ; NO_ISEL-NEXT:    addis 3, 2, .LCPI36_1@toc@ha
725 ; NO_ISEL-NEXT:    addi 4, 4, .LCPI36_0@toc@l
726 ; NO_ISEL-NEXT:    addi 3, 3, .LCPI36_1@toc@l
727 ; NO_ISEL-NEXT:    bc 12, 1, .LBB36_2
728 ; NO_ISEL-NEXT:  # BB#1:
729 ; NO_ISEL-NEXT:    ori 3, 4, 0
730 ; NO_ISEL-NEXT:    b .LBB36_2
731 ; NO_ISEL-NEXT:  .LBB36_2:
732 ; NO_ISEL-NEXT:    lxsdx 1, 0, 3
733 ; NO_ISEL-NEXT:    blr
734   %sel = select i1 %cond, double -4.0, double 23.3
735   %bo = fmul double %sel, 5.1
736   ret double %bo
739 define double @sel_constants_fdiv_constant(i1 %cond) {
740 ; ISEL-LABEL: sel_constants_fdiv_constant:
741 ; ISEL:       # BB#0:
742 ; ISEL-NEXT:    andi. 3, 3, 1
743 ; ISEL-NEXT:    addis 4, 2, .LCPI37_0@toc@ha
744 ; ISEL-NEXT:    addis 3, 2, .LCPI37_1@toc@ha
745 ; ISEL-NEXT:    addi 4, 4, .LCPI37_0@toc@l
746 ; ISEL-NEXT:    addi 3, 3, .LCPI37_1@toc@l
747 ; ISEL-NEXT:    isel 3, 3, 4, 1
748 ; ISEL-NEXT:    lxsdx 1, 0, 3
749 ; ISEL-NEXT:    blr
751 ; NO_ISEL-LABEL: sel_constants_fdiv_constant:
752 ; NO_ISEL:       # BB#0:
753 ; NO_ISEL-NEXT:    andi. 3, 3, 1
754 ; NO_ISEL-NEXT:    addis 4, 2, .LCPI37_0@toc@ha
755 ; NO_ISEL-NEXT:    addis 3, 2, .LCPI37_1@toc@ha
756 ; NO_ISEL-NEXT:    addi 4, 4, .LCPI37_0@toc@l
757 ; NO_ISEL-NEXT:    addi 3, 3, .LCPI37_1@toc@l
758 ; NO_ISEL-NEXT:    bc 12, 1, .LBB37_2
759 ; NO_ISEL-NEXT:  # BB#1:
760 ; NO_ISEL-NEXT:    ori 3, 4, 0
761 ; NO_ISEL-NEXT:    b .LBB37_2
762 ; NO_ISEL-NEXT:  .LBB37_2:
763 ; NO_ISEL-NEXT:    lxsdx 1, 0, 3
764 ; NO_ISEL-NEXT:    blr
765   %sel = select i1 %cond, double -4.0, double 23.3
766   %bo = fdiv double %sel, 5.1
767   ret double %bo
770 define double @sel_constants_frem_constant(i1 %cond) {
771 ; ALL-LABEL: sel_constants_frem_constant:
772 ; ALL:       # BB#0:
773 ; ALL-NEXT:    andi. 3, 3, 1
774 ; ALL-NEXT:    bc 12, 1, .LBB38_2
775 ; ALL-NEXT:  # BB#1:
776 ; ALL-NEXT:    addis 3, 2, .LCPI38_0@toc@ha
777 ; ALL-NEXT:    addi 3, 3, .LCPI38_0@toc@l
778 ; ALL-NEXT:    lxsdx 1, 0, 3
779 ; ALL-NEXT:    blr
780 ; ALL-NEXT:  .LBB38_2:
781 ; ALL-NEXT:    addis 3, 2, .LCPI38_1@toc@ha
782 ; ALL-NEXT:    addi 3, 3, .LCPI38_1@toc@l
783 ; ALL-NEXT:    lxsspx 1, 0, 3
784 ; ALL-NEXT:    blr
785   %sel = select i1 %cond, double -4.0, double 23.3
786   %bo = frem double %sel, 5.1
787   ret double %bo