1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=x86_64-unknown-unknown -O3 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=DEFAULT
3 ; RUN: llc -mtriple=x86_64-unknown-unknown -O3 -cgp-icmp-eq2icmp-st -verify-machineinstrs < %s | FileCheck %s --check-prefixes=EQ2ICMP
5 ; Test cases are generated from:
6 ; long long NAME(PARAM a, PARAM b) {
13 ; Please note funtion name is defined as <PARAM>_<LHS>_<RHS>. Take ll_a_op_b__1
14 ; for example. ll is PARAM, a_op_b (i.e., a << b) is LHS, _1 (i.e., -1) is RHS.
16 target datalayout = "e-m:e-i64:64-n32:64"
18 define i64 @ll_a_op_b__2(i64 %a, i64 %b) {
19 ; DEFAULT-LABEL: ll_a_op_b__2:
20 ; DEFAULT: # %bb.0: # %entry
21 ; DEFAULT-NEXT: movq %rsi, %rcx
22 ; DEFAULT-NEXT: movq %rdi, %rax
23 ; DEFAULT-NEXT: shlq %cl, %rax
24 ; DEFAULT-NEXT: cmpq $-2, %rax
25 ; DEFAULT-NEXT: jle .LBB0_1
26 ; DEFAULT-NEXT: # %bb.2: # %return
27 ; DEFAULT-NEXT: movq %rcx, %rax
29 ; DEFAULT-NEXT: .LBB0_1: # %if.end
30 ; DEFAULT-NEXT: movl $1, %eax
31 ; DEFAULT-NEXT: cmoveq %rcx, %rax
32 ; DEFAULT-NEXT: imulq %rdi, %rax
35 ; EQ2ICMP-LABEL: ll_a_op_b__2:
36 ; EQ2ICMP: # %bb.0: # %entry
37 ; EQ2ICMP-NEXT: movq %rsi, %rax
38 ; EQ2ICMP-NEXT: movq %rdi, %rdx
39 ; EQ2ICMP-NEXT: movl %eax, %ecx
40 ; EQ2ICMP-NEXT: shlq %cl, %rdx
41 ; EQ2ICMP-NEXT: cmpq $-2, %rdx
42 ; EQ2ICMP-NEXT: jg .LBB0_2
43 ; EQ2ICMP-NEXT: # %bb.1: # %if.end
44 ; EQ2ICMP-NEXT: movl $1, %ecx
45 ; EQ2ICMP-NEXT: cmovlq %rcx, %rax
46 ; EQ2ICMP-NEXT: imulq %rdi, %rax
47 ; EQ2ICMP-NEXT: .LBB0_2: # %return
51 %cmp = icmp sgt i64 %shl, -2
52 br i1 %cmp, label %return, label %if.end
54 if.end: ; preds = %entry
55 %cmp2 = icmp eq i64 %shl, -2
56 %mul = select i1 %cmp2, i64 %b, i64 1
57 %spec.select = mul nsw i64 %mul, %a
60 return: ; preds = %entry
64 define i64 @ll_a_op_b__1(i64 %a, i64 %b) {
65 ; DEFAULT-LABEL: ll_a_op_b__1:
66 ; DEFAULT: # %bb.0: # %entry
67 ; DEFAULT-NEXT: movq %rsi, %rcx
68 ; DEFAULT-NEXT: movq %rdi, %rax
69 ; DEFAULT-NEXT: shlq %cl, %rax
70 ; DEFAULT-NEXT: testq %rax, %rax
71 ; DEFAULT-NEXT: js .LBB1_1
72 ; DEFAULT-NEXT: # %bb.2: # %return
73 ; DEFAULT-NEXT: movq %rcx, %rax
75 ; DEFAULT-NEXT: .LBB1_1: # %if.end
76 ; DEFAULT-NEXT: cmpq $-1, %rax
77 ; DEFAULT-NEXT: movl $1, %eax
78 ; DEFAULT-NEXT: cmoveq %rcx, %rax
79 ; DEFAULT-NEXT: imulq %rdi, %rax
82 ; EQ2ICMP-LABEL: ll_a_op_b__1:
83 ; EQ2ICMP: # %bb.0: # %entry
84 ; EQ2ICMP-NEXT: movq %rsi, %rax
85 ; EQ2ICMP-NEXT: movq %rdi, %rdx
86 ; EQ2ICMP-NEXT: movl %eax, %ecx
87 ; EQ2ICMP-NEXT: shlq %cl, %rdx
88 ; EQ2ICMP-NEXT: testq %rdx, %rdx
89 ; EQ2ICMP-NEXT: js .LBB1_1
90 ; EQ2ICMP-NEXT: # %bb.2: # %return
92 ; EQ2ICMP-NEXT: .LBB1_1: # %if.end
93 ; EQ2ICMP-NEXT: cmpq $-1, %rdx
94 ; EQ2ICMP-NEXT: movl $1, %ecx
95 ; EQ2ICMP-NEXT: cmovlq %rcx, %rax
96 ; EQ2ICMP-NEXT: imulq %rdi, %rax
100 %cmp = icmp sgt i64 %shl, -1
101 br i1 %cmp, label %return, label %if.end
103 if.end: ; preds = %entry
104 %cmp2 = icmp eq i64 %shl, -1
105 %mul = select i1 %cmp2, i64 %b, i64 1
106 %spec.select = mul nsw i64 %mul, %a
109 return: ; preds = %entry
113 define i64 @ll_a_op_b_0(i64 %a, i64 %b) {
114 ; DEFAULT-LABEL: ll_a_op_b_0:
115 ; DEFAULT: # %bb.0: # %entry
116 ; DEFAULT-NEXT: movq %rsi, %rcx
117 ; DEFAULT-NEXT: movq %rdi, %rax
118 ; DEFAULT-NEXT: shlq %cl, %rax
119 ; DEFAULT-NEXT: testq %rax, %rax
120 ; DEFAULT-NEXT: jle .LBB2_1
121 ; DEFAULT-NEXT: # %bb.2: # %return
122 ; DEFAULT-NEXT: movq %rcx, %rax
124 ; DEFAULT-NEXT: .LBB2_1: # %if.end
125 ; DEFAULT-NEXT: movl $1, %eax
126 ; DEFAULT-NEXT: cmoveq %rcx, %rax
127 ; DEFAULT-NEXT: imulq %rdi, %rax
130 ; EQ2ICMP-LABEL: ll_a_op_b_0:
131 ; EQ2ICMP: # %bb.0: # %entry
132 ; EQ2ICMP-NEXT: movq %rsi, %rax
133 ; EQ2ICMP-NEXT: movq %rdi, %rdx
134 ; EQ2ICMP-NEXT: movl %eax, %ecx
135 ; EQ2ICMP-NEXT: shlq %cl, %rdx
136 ; EQ2ICMP-NEXT: testq %rdx, %rdx
137 ; EQ2ICMP-NEXT: jle .LBB2_1
138 ; EQ2ICMP-NEXT: # %bb.2: # %return
140 ; EQ2ICMP-NEXT: .LBB2_1: # %if.end
141 ; EQ2ICMP-NEXT: movl $1, %ecx
142 ; EQ2ICMP-NEXT: cmovsq %rcx, %rax
143 ; EQ2ICMP-NEXT: imulq %rdi, %rax
146 %shl = shl i64 %a, %b
147 %cmp = icmp sgt i64 %shl, 0
148 br i1 %cmp, label %return, label %if.end
150 if.end: ; preds = %entry
151 %cmp2 = icmp eq i64 %shl, 0
152 %mul = select i1 %cmp2, i64 %b, i64 1
153 %spec.select = mul nsw i64 %mul, %a
156 return: ; preds = %entry
160 define i64 @ll_a_op_b_1(i64 %a, i64 %b) {
161 ; DEFAULT-LABEL: ll_a_op_b_1:
162 ; DEFAULT: # %bb.0: # %entry
163 ; DEFAULT-NEXT: movq %rsi, %rcx
164 ; DEFAULT-NEXT: movq %rdi, %rax
165 ; DEFAULT-NEXT: shlq %cl, %rax
166 ; DEFAULT-NEXT: cmpq $1, %rax
167 ; DEFAULT-NEXT: jle .LBB3_1
168 ; DEFAULT-NEXT: # %bb.2: # %return
169 ; DEFAULT-NEXT: movq %rcx, %rax
171 ; DEFAULT-NEXT: .LBB3_1: # %if.end
172 ; DEFAULT-NEXT: movl $1, %eax
173 ; DEFAULT-NEXT: cmoveq %rcx, %rax
174 ; DEFAULT-NEXT: imulq %rdi, %rax
177 ; EQ2ICMP-LABEL: ll_a_op_b_1:
178 ; EQ2ICMP: # %bb.0: # %entry
179 ; EQ2ICMP-NEXT: movq %rsi, %rax
180 ; EQ2ICMP-NEXT: movq %rdi, %rdx
181 ; EQ2ICMP-NEXT: movl %eax, %ecx
182 ; EQ2ICMP-NEXT: shlq %cl, %rdx
183 ; EQ2ICMP-NEXT: cmpq $1, %rdx
184 ; EQ2ICMP-NEXT: jg .LBB3_2
185 ; EQ2ICMP-NEXT: # %bb.1: # %if.end
186 ; EQ2ICMP-NEXT: movl $1, %ecx
187 ; EQ2ICMP-NEXT: cmovlq %rcx, %rax
188 ; EQ2ICMP-NEXT: imulq %rdi, %rax
189 ; EQ2ICMP-NEXT: .LBB3_2: # %return
192 %shl = shl i64 %a, %b
193 %cmp = icmp sgt i64 %shl, 1
194 br i1 %cmp, label %return, label %if.end
196 if.end: ; preds = %entry
197 %cmp2 = icmp eq i64 %shl, 1
198 %mul = select i1 %cmp2, i64 %b, i64 1
199 %spec.select = mul nsw i64 %mul, %a
202 return: ; preds = %entry
206 define i64 @ll_a_op_b_2(i64 %a, i64 %b) {
207 ; DEFAULT-LABEL: ll_a_op_b_2:
208 ; DEFAULT: # %bb.0: # %entry
209 ; DEFAULT-NEXT: movq %rsi, %rcx
210 ; DEFAULT-NEXT: movq %rdi, %rax
211 ; DEFAULT-NEXT: shlq %cl, %rax
212 ; DEFAULT-NEXT: cmpq $2, %rax
213 ; DEFAULT-NEXT: jle .LBB4_1
214 ; DEFAULT-NEXT: # %bb.2: # %return
215 ; DEFAULT-NEXT: movq %rcx, %rax
217 ; DEFAULT-NEXT: .LBB4_1: # %if.end
218 ; DEFAULT-NEXT: movl $1, %eax
219 ; DEFAULT-NEXT: cmoveq %rcx, %rax
220 ; DEFAULT-NEXT: imulq %rdi, %rax
223 ; EQ2ICMP-LABEL: ll_a_op_b_2:
224 ; EQ2ICMP: # %bb.0: # %entry
225 ; EQ2ICMP-NEXT: movq %rsi, %rax
226 ; EQ2ICMP-NEXT: movq %rdi, %rdx
227 ; EQ2ICMP-NEXT: movl %eax, %ecx
228 ; EQ2ICMP-NEXT: shlq %cl, %rdx
229 ; EQ2ICMP-NEXT: cmpq $2, %rdx
230 ; EQ2ICMP-NEXT: jg .LBB4_2
231 ; EQ2ICMP-NEXT: # %bb.1: # %if.end
232 ; EQ2ICMP-NEXT: movl $1, %ecx
233 ; EQ2ICMP-NEXT: cmovlq %rcx, %rax
234 ; EQ2ICMP-NEXT: imulq %rdi, %rax
235 ; EQ2ICMP-NEXT: .LBB4_2: # %return
238 %shl = shl i64 %a, %b
239 %cmp = icmp sgt i64 %shl, 2
240 br i1 %cmp, label %return, label %if.end
242 if.end: ; preds = %entry
243 %cmp2 = icmp eq i64 %shl, 2
244 %mul = select i1 %cmp2, i64 %b, i64 1
245 %spec.select = mul nsw i64 %mul, %a
248 return: ; preds = %entry
252 define i64 @ll_a__2(i64 %a, i64 %b) {
253 ; DEFAULT-LABEL: ll_a__2:
254 ; DEFAULT: # %bb.0: # %entry
255 ; DEFAULT-NEXT: cmpq $-2, %rdi
256 ; DEFAULT-NEXT: jle .LBB5_1
257 ; DEFAULT-NEXT: # %bb.2: # %return
258 ; DEFAULT-NEXT: movq %rsi, %rax
260 ; DEFAULT-NEXT: .LBB5_1: # %if.end
261 ; DEFAULT-NEXT: movl $1, %eax
262 ; DEFAULT-NEXT: cmoveq %rsi, %rax
263 ; DEFAULT-NEXT: imulq %rdi, %rax
266 ; EQ2ICMP-LABEL: ll_a__2:
267 ; EQ2ICMP: # %bb.0: # %entry
268 ; EQ2ICMP-NEXT: movq %rsi, %rax
269 ; EQ2ICMP-NEXT: cmpq $-2, %rdi
270 ; EQ2ICMP-NEXT: jg .LBB5_2
271 ; EQ2ICMP-NEXT: # %bb.1: # %if.end
272 ; EQ2ICMP-NEXT: movl $1, %ecx
273 ; EQ2ICMP-NEXT: cmovlq %rcx, %rax
274 ; EQ2ICMP-NEXT: imulq %rdi, %rax
275 ; EQ2ICMP-NEXT: .LBB5_2: # %return
278 %cmp = icmp sgt i64 %a, -2
279 br i1 %cmp, label %return, label %if.end
281 if.end: ; preds = %entry
282 %cmp1 = icmp eq i64 %a, -2
283 %mul = select i1 %cmp1, i64 %b, i64 1
284 %spec.select = mul nsw i64 %mul, %a
287 return: ; preds = %entry
291 define i64 @ll_a__1(i64 %a, i64 %b) {
292 ; DEFAULT-LABEL: ll_a__1:
293 ; DEFAULT: # %bb.0: # %entry
294 ; DEFAULT-NEXT: testq %rdi, %rdi
295 ; DEFAULT-NEXT: js .LBB6_1
296 ; DEFAULT-NEXT: # %bb.2: # %return
297 ; DEFAULT-NEXT: movq %rsi, %rax
299 ; DEFAULT-NEXT: .LBB6_1: # %if.end
300 ; DEFAULT-NEXT: cmpq $-1, %rdi
301 ; DEFAULT-NEXT: movl $1, %eax
302 ; DEFAULT-NEXT: cmoveq %rsi, %rax
303 ; DEFAULT-NEXT: imulq %rdi, %rax
306 ; EQ2ICMP-LABEL: ll_a__1:
307 ; EQ2ICMP: # %bb.0: # %entry
308 ; EQ2ICMP-NEXT: movq %rsi, %rax
309 ; EQ2ICMP-NEXT: testq %rdi, %rdi
310 ; EQ2ICMP-NEXT: js .LBB6_1
311 ; EQ2ICMP-NEXT: # %bb.2: # %return
313 ; EQ2ICMP-NEXT: .LBB6_1: # %if.end
314 ; EQ2ICMP-NEXT: cmpq $-1, %rdi
315 ; EQ2ICMP-NEXT: movl $1, %ecx
316 ; EQ2ICMP-NEXT: cmovlq %rcx, %rax
317 ; EQ2ICMP-NEXT: imulq %rdi, %rax
320 %cmp = icmp sgt i64 %a, -1
321 br i1 %cmp, label %return, label %if.end
323 if.end: ; preds = %entry
324 %cmp1 = icmp eq i64 %a, -1
325 %mul = select i1 %cmp1, i64 %b, i64 1
326 %spec.select = mul nsw i64 %mul, %a
329 return: ; preds = %entry
333 define i64 @ll_a_0(i64 %a, i64 %b) {
334 ; DEFAULT-LABEL: ll_a_0:
335 ; DEFAULT: # %bb.0: # %entry
336 ; DEFAULT-NEXT: testq %rdi, %rdi
337 ; DEFAULT-NEXT: jle .LBB7_1
338 ; DEFAULT-NEXT: # %bb.2: # %return
339 ; DEFAULT-NEXT: movq %rsi, %rax
341 ; DEFAULT-NEXT: .LBB7_1: # %if.end
342 ; DEFAULT-NEXT: movl $1, %eax
343 ; DEFAULT-NEXT: cmoveq %rsi, %rax
344 ; DEFAULT-NEXT: imulq %rdi, %rax
347 ; EQ2ICMP-LABEL: ll_a_0:
348 ; EQ2ICMP: # %bb.0: # %entry
349 ; EQ2ICMP-NEXT: movq %rsi, %rax
350 ; EQ2ICMP-NEXT: testq %rdi, %rdi
351 ; EQ2ICMP-NEXT: jle .LBB7_1
352 ; EQ2ICMP-NEXT: # %bb.2: # %return
354 ; EQ2ICMP-NEXT: .LBB7_1: # %if.end
355 ; EQ2ICMP-NEXT: movl $1, %ecx
356 ; EQ2ICMP-NEXT: cmovsq %rcx, %rax
357 ; EQ2ICMP-NEXT: imulq %rdi, %rax
360 %cmp = icmp sgt i64 %a, 0
361 br i1 %cmp, label %return, label %if.end
363 if.end: ; preds = %entry
364 %cmp1 = icmp eq i64 %a, 0
365 %mul = select i1 %cmp1, i64 %b, i64 1
366 %spec.select = mul nsw i64 %mul, %a
369 return: ; preds = %entry
373 define i64 @ll_a_1(i64 %a, i64 %b) {
374 ; DEFAULT-LABEL: ll_a_1:
375 ; DEFAULT: # %bb.0: # %entry
376 ; DEFAULT-NEXT: cmpq $1, %rdi
377 ; DEFAULT-NEXT: jle .LBB8_1
378 ; DEFAULT-NEXT: # %bb.2: # %return
379 ; DEFAULT-NEXT: movq %rsi, %rax
381 ; DEFAULT-NEXT: .LBB8_1: # %if.end
382 ; DEFAULT-NEXT: movl $1, %eax
383 ; DEFAULT-NEXT: cmoveq %rsi, %rax
384 ; DEFAULT-NEXT: imulq %rdi, %rax
387 ; EQ2ICMP-LABEL: ll_a_1:
388 ; EQ2ICMP: # %bb.0: # %entry
389 ; EQ2ICMP-NEXT: movq %rsi, %rax
390 ; EQ2ICMP-NEXT: cmpq $1, %rdi
391 ; EQ2ICMP-NEXT: jg .LBB8_2
392 ; EQ2ICMP-NEXT: # %bb.1: # %if.end
393 ; EQ2ICMP-NEXT: movl $1, %ecx
394 ; EQ2ICMP-NEXT: cmovlq %rcx, %rax
395 ; EQ2ICMP-NEXT: imulq %rdi, %rax
396 ; EQ2ICMP-NEXT: .LBB8_2: # %return
399 %cmp = icmp sgt i64 %a, 1
400 br i1 %cmp, label %return, label %if.end
402 if.end: ; preds = %entry
403 %cmp1 = icmp eq i64 %a, 1
404 %mul = select i1 %cmp1, i64 %b, i64 1
405 %spec.select = mul nsw i64 %mul, %a
408 return: ; preds = %entry
412 define i64 @ll_a_2(i64 %a, i64 %b) {
413 ; DEFAULT-LABEL: ll_a_2:
414 ; DEFAULT: # %bb.0: # %entry
415 ; DEFAULT-NEXT: cmpq $2, %rdi
416 ; DEFAULT-NEXT: jle .LBB9_1
417 ; DEFAULT-NEXT: # %bb.2: # %return
418 ; DEFAULT-NEXT: movq %rsi, %rax
420 ; DEFAULT-NEXT: .LBB9_1: # %if.end
421 ; DEFAULT-NEXT: movl $1, %eax
422 ; DEFAULT-NEXT: cmoveq %rsi, %rax
423 ; DEFAULT-NEXT: imulq %rdi, %rax
426 ; EQ2ICMP-LABEL: ll_a_2:
427 ; EQ2ICMP: # %bb.0: # %entry
428 ; EQ2ICMP-NEXT: movq %rsi, %rax
429 ; EQ2ICMP-NEXT: cmpq $2, %rdi
430 ; EQ2ICMP-NEXT: jg .LBB9_2
431 ; EQ2ICMP-NEXT: # %bb.1: # %if.end
432 ; EQ2ICMP-NEXT: movl $1, %ecx
433 ; EQ2ICMP-NEXT: cmovlq %rcx, %rax
434 ; EQ2ICMP-NEXT: imulq %rdi, %rax
435 ; EQ2ICMP-NEXT: .LBB9_2: # %return
438 %cmp = icmp sgt i64 %a, 2
439 br i1 %cmp, label %return, label %if.end
441 if.end: ; preds = %entry
442 %cmp1 = icmp eq i64 %a, 2
443 %mul = select i1 %cmp1, i64 %b, i64 1
444 %spec.select = mul nsw i64 %mul, %a
447 return: ; preds = %entry
451 define i64 @i_a_op_b__2(i32 signext %a, i32 signext %b) {
452 ; DEFAULT-LABEL: i_a_op_b__2:
453 ; DEFAULT: # %bb.0: # %entry
454 ; DEFAULT-NEXT: movl %esi, %ecx
455 ; DEFAULT-NEXT: movl %edi, %eax
456 ; DEFAULT-NEXT: shll %cl, %eax
457 ; DEFAULT-NEXT: cmpl $-2, %eax
458 ; DEFAULT-NEXT: jg .LBB10_2
459 ; DEFAULT-NEXT: # %bb.1: # %if.end
460 ; DEFAULT-NEXT: movl $1, %eax
461 ; DEFAULT-NEXT: cmovel %ecx, %eax
462 ; DEFAULT-NEXT: imull %edi, %eax
463 ; DEFAULT-NEXT: movl %eax, %ecx
464 ; DEFAULT-NEXT: .LBB10_2: # %return
465 ; DEFAULT-NEXT: movslq %ecx, %rax
468 ; EQ2ICMP-LABEL: i_a_op_b__2:
469 ; EQ2ICMP: # %bb.0: # %entry
470 ; EQ2ICMP-NEXT: movl %esi, %ecx
471 ; EQ2ICMP-NEXT: movl %edi, %eax
472 ; EQ2ICMP-NEXT: shll %cl, %eax
473 ; EQ2ICMP-NEXT: cmpl $-2, %eax
474 ; EQ2ICMP-NEXT: jg .LBB10_2
475 ; EQ2ICMP-NEXT: # %bb.1: # %if.end
476 ; EQ2ICMP-NEXT: movl $1, %eax
477 ; EQ2ICMP-NEXT: cmovll %eax, %ecx
478 ; EQ2ICMP-NEXT: imull %edi, %ecx
479 ; EQ2ICMP-NEXT: .LBB10_2: # %return
480 ; EQ2ICMP-NEXT: movslq %ecx, %rax
483 %shl = shl i32 %a, %b
484 %cmp = icmp sgt i32 %shl, -2
485 br i1 %cmp, label %return, label %if.end
487 if.end: ; preds = %entry
488 %cmp2 = icmp eq i32 %shl, -2
489 %mul = select i1 %cmp2, i32 %b, i32 1
490 %spec.select = mul nsw i32 %mul, %a
493 return: ; preds = %if.end, %entry
494 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
495 %retval.0 = sext i32 %retval.0.in to i64
499 define i64 @i_a_op_b__1(i32 signext %a, i32 signext %b) {
500 ; DEFAULT-LABEL: i_a_op_b__1:
501 ; DEFAULT: # %bb.0: # %entry
502 ; DEFAULT-NEXT: movl %esi, %ecx
503 ; DEFAULT-NEXT: movl %edi, %eax
504 ; DEFAULT-NEXT: shll %cl, %eax
505 ; DEFAULT-NEXT: testl %eax, %eax
506 ; DEFAULT-NEXT: js .LBB11_1
507 ; DEFAULT-NEXT: # %bb.2: # %return
508 ; DEFAULT-NEXT: movslq %ecx, %rax
510 ; DEFAULT-NEXT: .LBB11_1: # %if.end
511 ; DEFAULT-NEXT: cmpl $-1, %eax
512 ; DEFAULT-NEXT: movl $1, %eax
513 ; DEFAULT-NEXT: cmovel %ecx, %eax
514 ; DEFAULT-NEXT: imull %edi, %eax
515 ; DEFAULT-NEXT: movl %eax, %ecx
516 ; DEFAULT-NEXT: movslq %ecx, %rax
519 ; EQ2ICMP-LABEL: i_a_op_b__1:
520 ; EQ2ICMP: # %bb.0: # %entry
521 ; EQ2ICMP-NEXT: movl %esi, %ecx
522 ; EQ2ICMP-NEXT: movl %edi, %eax
523 ; EQ2ICMP-NEXT: shll %cl, %eax
524 ; EQ2ICMP-NEXT: testl %eax, %eax
525 ; EQ2ICMP-NEXT: js .LBB11_1
526 ; EQ2ICMP-NEXT: # %bb.2: # %return
527 ; EQ2ICMP-NEXT: movslq %ecx, %rax
529 ; EQ2ICMP-NEXT: .LBB11_1: # %if.end
530 ; EQ2ICMP-NEXT: cmpl $-1, %eax
531 ; EQ2ICMP-NEXT: movl $1, %eax
532 ; EQ2ICMP-NEXT: cmovll %eax, %ecx
533 ; EQ2ICMP-NEXT: imull %edi, %ecx
534 ; EQ2ICMP-NEXT: movslq %ecx, %rax
537 %shl = shl i32 %a, %b
538 %cmp = icmp sgt i32 %shl, -1
539 br i1 %cmp, label %return, label %if.end
541 if.end: ; preds = %entry
542 %cmp2 = icmp eq i32 %shl, -1
543 %mul = select i1 %cmp2, i32 %b, i32 1
544 %spec.select = mul nsw i32 %mul, %a
547 return: ; preds = %if.end, %entry
548 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
549 %retval.0 = sext i32 %retval.0.in to i64
553 define i64 @i_a_op_b_0(i32 signext %a, i32 signext %b) {
554 ; DEFAULT-LABEL: i_a_op_b_0:
555 ; DEFAULT: # %bb.0: # %entry
556 ; DEFAULT-NEXT: movl %esi, %ecx
557 ; DEFAULT-NEXT: movl %edi, %eax
558 ; DEFAULT-NEXT: shll %cl, %eax
559 ; DEFAULT-NEXT: testl %eax, %eax
560 ; DEFAULT-NEXT: jle .LBB12_1
561 ; DEFAULT-NEXT: # %bb.2: # %return
562 ; DEFAULT-NEXT: movslq %ecx, %rax
564 ; DEFAULT-NEXT: .LBB12_1: # %if.end
565 ; DEFAULT-NEXT: movl $1, %eax
566 ; DEFAULT-NEXT: cmovel %ecx, %eax
567 ; DEFAULT-NEXT: imull %edi, %eax
568 ; DEFAULT-NEXT: movl %eax, %ecx
569 ; DEFAULT-NEXT: movslq %ecx, %rax
572 ; EQ2ICMP-LABEL: i_a_op_b_0:
573 ; EQ2ICMP: # %bb.0: # %entry
574 ; EQ2ICMP-NEXT: movl %esi, %ecx
575 ; EQ2ICMP-NEXT: movl %edi, %eax
576 ; EQ2ICMP-NEXT: shll %cl, %eax
577 ; EQ2ICMP-NEXT: testl %eax, %eax
578 ; EQ2ICMP-NEXT: jle .LBB12_1
579 ; EQ2ICMP-NEXT: # %bb.2: # %return
580 ; EQ2ICMP-NEXT: movslq %ecx, %rax
582 ; EQ2ICMP-NEXT: .LBB12_1: # %if.end
583 ; EQ2ICMP-NEXT: movl $1, %eax
584 ; EQ2ICMP-NEXT: cmovsl %eax, %ecx
585 ; EQ2ICMP-NEXT: imull %edi, %ecx
586 ; EQ2ICMP-NEXT: movslq %ecx, %rax
589 %shl = shl i32 %a, %b
590 %cmp = icmp sgt i32 %shl, 0
591 br i1 %cmp, label %return, label %if.end
593 if.end: ; preds = %entry
594 %cmp2 = icmp eq i32 %shl, 0
595 %mul = select i1 %cmp2, i32 %b, i32 1
596 %spec.select = mul nsw i32 %mul, %a
599 return: ; preds = %if.end, %entry
600 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
601 %retval.0 = sext i32 %retval.0.in to i64
605 define i64 @i_a_op_b_1(i32 signext %a, i32 signext %b) {
606 ; DEFAULT-LABEL: i_a_op_b_1:
607 ; DEFAULT: # %bb.0: # %entry
608 ; DEFAULT-NEXT: movl %esi, %ecx
609 ; DEFAULT-NEXT: movl %edi, %eax
610 ; DEFAULT-NEXT: shll %cl, %eax
611 ; DEFAULT-NEXT: cmpl $1, %eax
612 ; DEFAULT-NEXT: jg .LBB13_2
613 ; DEFAULT-NEXT: # %bb.1: # %if.end
614 ; DEFAULT-NEXT: movl $1, %eax
615 ; DEFAULT-NEXT: cmovel %ecx, %eax
616 ; DEFAULT-NEXT: imull %edi, %eax
617 ; DEFAULT-NEXT: movl %eax, %ecx
618 ; DEFAULT-NEXT: .LBB13_2: # %return
619 ; DEFAULT-NEXT: movslq %ecx, %rax
622 ; EQ2ICMP-LABEL: i_a_op_b_1:
623 ; EQ2ICMP: # %bb.0: # %entry
624 ; EQ2ICMP-NEXT: movl %esi, %ecx
625 ; EQ2ICMP-NEXT: movl %edi, %eax
626 ; EQ2ICMP-NEXT: shll %cl, %eax
627 ; EQ2ICMP-NEXT: cmpl $1, %eax
628 ; EQ2ICMP-NEXT: jg .LBB13_2
629 ; EQ2ICMP-NEXT: # %bb.1: # %if.end
630 ; EQ2ICMP-NEXT: movl $1, %eax
631 ; EQ2ICMP-NEXT: cmovll %eax, %ecx
632 ; EQ2ICMP-NEXT: imull %edi, %ecx
633 ; EQ2ICMP-NEXT: .LBB13_2: # %return
634 ; EQ2ICMP-NEXT: movslq %ecx, %rax
637 %shl = shl i32 %a, %b
638 %cmp = icmp sgt i32 %shl, 1
639 br i1 %cmp, label %return, label %if.end
641 if.end: ; preds = %entry
642 %cmp2 = icmp eq i32 %shl, 1
643 %mul = select i1 %cmp2, i32 %b, i32 1
644 %spec.select = mul nsw i32 %mul, %a
647 return: ; preds = %if.end, %entry
648 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
649 %retval.0 = sext i32 %retval.0.in to i64
653 define i64 @i_a_op_b_2(i32 signext %a, i32 signext %b) {
654 ; DEFAULT-LABEL: i_a_op_b_2:
655 ; DEFAULT: # %bb.0: # %entry
656 ; DEFAULT-NEXT: movl %esi, %ecx
657 ; DEFAULT-NEXT: movl %edi, %eax
658 ; DEFAULT-NEXT: shll %cl, %eax
659 ; DEFAULT-NEXT: cmpl $2, %eax
660 ; DEFAULT-NEXT: jg .LBB14_2
661 ; DEFAULT-NEXT: # %bb.1: # %if.end
662 ; DEFAULT-NEXT: movl $1, %eax
663 ; DEFAULT-NEXT: cmovel %ecx, %eax
664 ; DEFAULT-NEXT: imull %edi, %eax
665 ; DEFAULT-NEXT: movl %eax, %ecx
666 ; DEFAULT-NEXT: .LBB14_2: # %return
667 ; DEFAULT-NEXT: movslq %ecx, %rax
670 ; EQ2ICMP-LABEL: i_a_op_b_2:
671 ; EQ2ICMP: # %bb.0: # %entry
672 ; EQ2ICMP-NEXT: movl %esi, %ecx
673 ; EQ2ICMP-NEXT: movl %edi, %eax
674 ; EQ2ICMP-NEXT: shll %cl, %eax
675 ; EQ2ICMP-NEXT: cmpl $2, %eax
676 ; EQ2ICMP-NEXT: jg .LBB14_2
677 ; EQ2ICMP-NEXT: # %bb.1: # %if.end
678 ; EQ2ICMP-NEXT: movl $1, %eax
679 ; EQ2ICMP-NEXT: cmovll %eax, %ecx
680 ; EQ2ICMP-NEXT: imull %edi, %ecx
681 ; EQ2ICMP-NEXT: .LBB14_2: # %return
682 ; EQ2ICMP-NEXT: movslq %ecx, %rax
685 %shl = shl i32 %a, %b
686 %cmp = icmp sgt i32 %shl, 2
687 br i1 %cmp, label %return, label %if.end
689 if.end: ; preds = %entry
690 %cmp2 = icmp eq i32 %shl, 2
691 %mul = select i1 %cmp2, i32 %b, i32 1
692 %spec.select = mul nsw i32 %mul, %a
695 return: ; preds = %if.end, %entry
696 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
697 %retval.0 = sext i32 %retval.0.in to i64
701 define i64 @i_a__2(i32 signext %a, i32 signext %b) {
702 ; DEFAULT-LABEL: i_a__2:
703 ; DEFAULT: # %bb.0: # %entry
704 ; DEFAULT-NEXT: cmpl $-2, %edi
705 ; DEFAULT-NEXT: jg .LBB15_2
706 ; DEFAULT-NEXT: # %bb.1: # %if.end
707 ; DEFAULT-NEXT: movl $1, %eax
708 ; DEFAULT-NEXT: cmovel %esi, %eax
709 ; DEFAULT-NEXT: imull %edi, %eax
710 ; DEFAULT-NEXT: movl %eax, %esi
711 ; DEFAULT-NEXT: .LBB15_2: # %return
712 ; DEFAULT-NEXT: movslq %esi, %rax
715 ; EQ2ICMP-LABEL: i_a__2:
716 ; EQ2ICMP: # %bb.0: # %entry
717 ; EQ2ICMP-NEXT: cmpl $-2, %edi
718 ; EQ2ICMP-NEXT: jg .LBB15_2
719 ; EQ2ICMP-NEXT: # %bb.1: # %if.end
720 ; EQ2ICMP-NEXT: movl $1, %eax
721 ; EQ2ICMP-NEXT: cmovll %eax, %esi
722 ; EQ2ICMP-NEXT: imull %edi, %esi
723 ; EQ2ICMP-NEXT: .LBB15_2: # %return
724 ; EQ2ICMP-NEXT: movslq %esi, %rax
727 %cmp = icmp sgt i32 %a, -2
728 br i1 %cmp, label %return, label %if.end
730 if.end: ; preds = %entry
731 %cmp1 = icmp eq i32 %a, -2
732 %mul = select i1 %cmp1, i32 %b, i32 1
733 %spec.select = mul nsw i32 %mul, %a
736 return: ; preds = %if.end, %entry
737 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
738 %retval.0 = sext i32 %retval.0.in to i64
742 define i64 @i_a__1(i32 signext %a, i32 signext %b) {
743 ; DEFAULT-LABEL: i_a__1:
744 ; DEFAULT: # %bb.0: # %entry
745 ; DEFAULT-NEXT: testl %edi, %edi
746 ; DEFAULT-NEXT: js .LBB16_1
747 ; DEFAULT-NEXT: # %bb.2: # %return
748 ; DEFAULT-NEXT: movslq %esi, %rax
750 ; DEFAULT-NEXT: .LBB16_1: # %if.end
751 ; DEFAULT-NEXT: cmpl $-1, %edi
752 ; DEFAULT-NEXT: movl $1, %eax
753 ; DEFAULT-NEXT: cmovel %esi, %eax
754 ; DEFAULT-NEXT: imull %edi, %eax
755 ; DEFAULT-NEXT: movl %eax, %esi
756 ; DEFAULT-NEXT: movslq %esi, %rax
759 ; EQ2ICMP-LABEL: i_a__1:
760 ; EQ2ICMP: # %bb.0: # %entry
761 ; EQ2ICMP-NEXT: testl %edi, %edi
762 ; EQ2ICMP-NEXT: js .LBB16_1
763 ; EQ2ICMP-NEXT: # %bb.2: # %return
764 ; EQ2ICMP-NEXT: movslq %esi, %rax
766 ; EQ2ICMP-NEXT: .LBB16_1: # %if.end
767 ; EQ2ICMP-NEXT: cmpl $-1, %edi
768 ; EQ2ICMP-NEXT: movl $1, %eax
769 ; EQ2ICMP-NEXT: cmovll %eax, %esi
770 ; EQ2ICMP-NEXT: imull %edi, %esi
771 ; EQ2ICMP-NEXT: movslq %esi, %rax
774 %cmp = icmp sgt i32 %a, -1
775 br i1 %cmp, label %return, label %if.end
777 if.end: ; preds = %entry
778 %cmp1 = icmp eq i32 %a, -1
779 %mul = select i1 %cmp1, i32 %b, i32 1
780 %spec.select = mul nsw i32 %mul, %a
783 return: ; preds = %if.end, %entry
784 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
785 %retval.0 = sext i32 %retval.0.in to i64
789 define i64 @i_a_0(i32 signext %a, i32 signext %b) {
790 ; DEFAULT-LABEL: i_a_0:
791 ; DEFAULT: # %bb.0: # %entry
792 ; DEFAULT-NEXT: testl %edi, %edi
793 ; DEFAULT-NEXT: jle .LBB17_1
794 ; DEFAULT-NEXT: # %bb.2: # %return
795 ; DEFAULT-NEXT: movslq %esi, %rax
797 ; DEFAULT-NEXT: .LBB17_1: # %if.end
798 ; DEFAULT-NEXT: movl $1, %eax
799 ; DEFAULT-NEXT: cmovel %esi, %eax
800 ; DEFAULT-NEXT: imull %edi, %eax
801 ; DEFAULT-NEXT: movl %eax, %esi
802 ; DEFAULT-NEXT: movslq %esi, %rax
805 ; EQ2ICMP-LABEL: i_a_0:
806 ; EQ2ICMP: # %bb.0: # %entry
807 ; EQ2ICMP-NEXT: testl %edi, %edi
808 ; EQ2ICMP-NEXT: jle .LBB17_1
809 ; EQ2ICMP-NEXT: # %bb.2: # %return
810 ; EQ2ICMP-NEXT: movslq %esi, %rax
812 ; EQ2ICMP-NEXT: .LBB17_1: # %if.end
813 ; EQ2ICMP-NEXT: movl $1, %eax
814 ; EQ2ICMP-NEXT: cmovsl %eax, %esi
815 ; EQ2ICMP-NEXT: imull %edi, %esi
816 ; EQ2ICMP-NEXT: movslq %esi, %rax
819 %cmp = icmp sgt i32 %a, 0
820 br i1 %cmp, label %return, label %if.end
822 if.end: ; preds = %entry
823 %cmp1 = icmp eq i32 %a, 0
824 %mul = select i1 %cmp1, i32 %b, i32 1
825 %spec.select = mul nsw i32 %mul, %a
828 return: ; preds = %if.end, %entry
829 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
830 %retval.0 = sext i32 %retval.0.in to i64
834 define i64 @i_a_1(i32 signext %a, i32 signext %b) {
835 ; DEFAULT-LABEL: i_a_1:
836 ; DEFAULT: # %bb.0: # %entry
837 ; DEFAULT-NEXT: cmpl $1, %edi
838 ; DEFAULT-NEXT: jg .LBB18_2
839 ; DEFAULT-NEXT: # %bb.1: # %if.end
840 ; DEFAULT-NEXT: movl $1, %eax
841 ; DEFAULT-NEXT: cmovel %esi, %eax
842 ; DEFAULT-NEXT: imull %edi, %eax
843 ; DEFAULT-NEXT: movl %eax, %esi
844 ; DEFAULT-NEXT: .LBB18_2: # %return
845 ; DEFAULT-NEXT: movslq %esi, %rax
848 ; EQ2ICMP-LABEL: i_a_1:
849 ; EQ2ICMP: # %bb.0: # %entry
850 ; EQ2ICMP-NEXT: cmpl $1, %edi
851 ; EQ2ICMP-NEXT: jg .LBB18_2
852 ; EQ2ICMP-NEXT: # %bb.1: # %if.end
853 ; EQ2ICMP-NEXT: movl $1, %eax
854 ; EQ2ICMP-NEXT: cmovll %eax, %esi
855 ; EQ2ICMP-NEXT: imull %edi, %esi
856 ; EQ2ICMP-NEXT: .LBB18_2: # %return
857 ; EQ2ICMP-NEXT: movslq %esi, %rax
860 %cmp = icmp sgt i32 %a, 1
861 br i1 %cmp, label %return, label %if.end
863 if.end: ; preds = %entry
864 %cmp1 = icmp eq i32 %a, 1
865 %mul = select i1 %cmp1, i32 %b, i32 1
866 %spec.select = mul nsw i32 %mul, %a
869 return: ; preds = %if.end, %entry
870 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
871 %retval.0 = sext i32 %retval.0.in to i64
875 define i64 @i_a_2(i32 signext %a, i32 signext %b) {
876 ; DEFAULT-LABEL: i_a_2:
877 ; DEFAULT: # %bb.0: # %entry
878 ; DEFAULT-NEXT: cmpl $2, %edi
879 ; DEFAULT-NEXT: jg .LBB19_2
880 ; DEFAULT-NEXT: # %bb.1: # %if.end
881 ; DEFAULT-NEXT: movl $1, %eax
882 ; DEFAULT-NEXT: cmovel %esi, %eax
883 ; DEFAULT-NEXT: imull %edi, %eax
884 ; DEFAULT-NEXT: movl %eax, %esi
885 ; DEFAULT-NEXT: .LBB19_2: # %return
886 ; DEFAULT-NEXT: movslq %esi, %rax
889 ; EQ2ICMP-LABEL: i_a_2:
890 ; EQ2ICMP: # %bb.0: # %entry
891 ; EQ2ICMP-NEXT: cmpl $2, %edi
892 ; EQ2ICMP-NEXT: jg .LBB19_2
893 ; EQ2ICMP-NEXT: # %bb.1: # %if.end
894 ; EQ2ICMP-NEXT: movl $1, %eax
895 ; EQ2ICMP-NEXT: cmovll %eax, %esi
896 ; EQ2ICMP-NEXT: imull %edi, %esi
897 ; EQ2ICMP-NEXT: .LBB19_2: # %return
898 ; EQ2ICMP-NEXT: movslq %esi, %rax
901 %cmp = icmp sgt i32 %a, 2
902 br i1 %cmp, label %return, label %if.end
904 if.end: ; preds = %entry
905 %cmp1 = icmp eq i32 %a, 2
906 %mul = select i1 %cmp1, i32 %b, i32 1
907 %spec.select = mul nsw i32 %mul, %a
910 return: ; preds = %if.end, %entry
911 %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ]
912 %retval.0 = sext i32 %retval.0.in to i64