1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown | FileCheck %s --check-prefix=X86
3 ; RUN: llc < %s -mtriple=x86_64-unknown -mcpu=haswell | FileCheck %s --check-prefixes=X64,X64-HSW
4 ; RUN: llc < %s -mtriple=x86_64-unknown -mcpu=btver2 | FileCheck %s --check-prefixes=X64,X64-JAG
5 ; RUN: llc < %s -mtriple=i686-unknown -mul-constant-optimization=false | FileCheck %s --check-prefix=X86-NOOPT
6 ; RUN: llc < %s -mtriple=x86_64-unknown -mul-constant-optimization=false -mcpu=haswell | FileCheck %s --check-prefixes=X64-NOOPT,HSW-NOOPT
7 ; RUN: llc < %s -mtriple=x86_64-unknown -mul-constant-optimization=false -mcpu=btver2 | FileCheck %s --check-prefixes=X64-NOOPT,JAG-NOOPT
8 ; RUN: llc < %s -mtriple=x86_64-unknown -mcpu=slm | FileCheck %s --check-prefixes=X64,X64-SLM
9 ; RUN: llc < %s -mtriple=x86_64-unknown -mul-constant-optimization=false -mcpu=slm | FileCheck %s --check-prefixes=X64-NOOPT,SLM-NOOPT
11 define i32 @test_mul_by_1(i32 %x) {
12 ; X86-LABEL: test_mul_by_1:
14 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
17 ; X64-LABEL: test_mul_by_1:
19 ; X64-NEXT: movl %edi, %eax
22 ; X86-NOOPT-LABEL: test_mul_by_1:
24 ; X86-NOOPT-NEXT: movl {{[0-9]+}}(%esp), %eax
25 ; X86-NOOPT-NEXT: retl
27 ; X64-NOOPT-LABEL: test_mul_by_1:
29 ; X64-NOOPT-NEXT: movl %edi, %eax
30 ; X64-NOOPT-NEXT: retq
31 %mul = mul nsw i32 %x, 1
35 define i32 @test_mul_by_2(i32 %x) {
36 ; X86-LABEL: test_mul_by_2:
38 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
39 ; X86-NEXT: addl %eax, %eax
42 ; X64-LABEL: test_mul_by_2:
44 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
45 ; X64-NEXT: leal (%rdi,%rdi), %eax
48 ; X86-NOOPT-LABEL: test_mul_by_2:
50 ; X86-NOOPT-NEXT: movl {{[0-9]+}}(%esp), %eax
51 ; X86-NOOPT-NEXT: addl %eax, %eax
52 ; X86-NOOPT-NEXT: retl
54 ; X64-NOOPT-LABEL: test_mul_by_2:
56 ; X64-NOOPT-NEXT: # kill: def $edi killed $edi def $rdi
57 ; X64-NOOPT-NEXT: leal (%rdi,%rdi), %eax
58 ; X64-NOOPT-NEXT: retq
59 %mul = mul nsw i32 %x, 2
63 define i32 @test_mul_by_3(i32 %x) {
64 ; X86-LABEL: test_mul_by_3:
66 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
67 ; X86-NEXT: leal (%eax,%eax,2), %eax
70 ; X64-LABEL: test_mul_by_3:
72 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
73 ; X64-NEXT: leal (%rdi,%rdi,2), %eax
76 ; X86-NOOPT-LABEL: test_mul_by_3:
78 ; X86-NOOPT-NEXT: imull $3, {{[0-9]+}}(%esp), %eax
79 ; X86-NOOPT-NEXT: retl
81 ; X64-NOOPT-LABEL: test_mul_by_3:
83 ; X64-NOOPT-NEXT: # kill: def $edi killed $edi def $rdi
84 ; X64-NOOPT-NEXT: leal (%rdi,%rdi,2), %eax
85 ; X64-NOOPT-NEXT: retq
86 %mul = mul nsw i32 %x, 3
90 define i32 @test_mul_by_4(i32 %x) {
91 ; X86-LABEL: test_mul_by_4:
93 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
94 ; X86-NEXT: shll $2, %eax
97 ; X64-LABEL: test_mul_by_4:
99 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
100 ; X64-NEXT: leal (,%rdi,4), %eax
103 ; X86-NOOPT-LABEL: test_mul_by_4:
104 ; X86-NOOPT: # %bb.0:
105 ; X86-NOOPT-NEXT: movl {{[0-9]+}}(%esp), %eax
106 ; X86-NOOPT-NEXT: shll $2, %eax
107 ; X86-NOOPT-NEXT: retl
109 ; X64-NOOPT-LABEL: test_mul_by_4:
110 ; X64-NOOPT: # %bb.0:
111 ; X64-NOOPT-NEXT: # kill: def $edi killed $edi def $rdi
112 ; X64-NOOPT-NEXT: leal (,%rdi,4), %eax
113 ; X64-NOOPT-NEXT: retq
114 %mul = mul nsw i32 %x, 4
118 define i32 @test_mul_by_5(i32 %x) {
119 ; X86-LABEL: test_mul_by_5:
121 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
122 ; X86-NEXT: leal (%eax,%eax,4), %eax
125 ; X64-LABEL: test_mul_by_5:
127 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
128 ; X64-NEXT: leal (%rdi,%rdi,4), %eax
131 ; X86-NOOPT-LABEL: test_mul_by_5:
132 ; X86-NOOPT: # %bb.0:
133 ; X86-NOOPT-NEXT: imull $5, {{[0-9]+}}(%esp), %eax
134 ; X86-NOOPT-NEXT: retl
136 ; X64-NOOPT-LABEL: test_mul_by_5:
137 ; X64-NOOPT: # %bb.0:
138 ; X64-NOOPT-NEXT: # kill: def $edi killed $edi def $rdi
139 ; X64-NOOPT-NEXT: leal (%rdi,%rdi,4), %eax
140 ; X64-NOOPT-NEXT: retq
141 %mul = mul nsw i32 %x, 5
145 define i32 @test_mul_by_6(i32 %x) {
146 ; X86-LABEL: test_mul_by_6:
148 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
149 ; X86-NEXT: addl %eax, %eax
150 ; X86-NEXT: leal (%eax,%eax,2), %eax
153 ; X64-LABEL: test_mul_by_6:
155 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
156 ; X64-NEXT: addl %edi, %edi
157 ; X64-NEXT: leal (%rdi,%rdi,2), %eax
160 ; X86-NOOPT-LABEL: test_mul_by_6:
161 ; X86-NOOPT: # %bb.0:
162 ; X86-NOOPT-NEXT: imull $6, {{[0-9]+}}(%esp), %eax
163 ; X86-NOOPT-NEXT: retl
165 ; X64-NOOPT-LABEL: test_mul_by_6:
166 ; X64-NOOPT: # %bb.0:
167 ; X64-NOOPT-NEXT: imull $6, %edi, %eax
168 ; X64-NOOPT-NEXT: retq
169 %mul = mul nsw i32 %x, 6
173 define i32 @test_mul_by_7(i32 %x) {
174 ; X86-LABEL: test_mul_by_7:
176 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
177 ; X86-NEXT: leal (,%ecx,8), %eax
178 ; X86-NEXT: subl %ecx, %eax
181 ; X64-LABEL: test_mul_by_7:
183 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
184 ; X64-NEXT: leal (,%rdi,8), %eax
185 ; X64-NEXT: subl %edi, %eax
188 ; X86-NOOPT-LABEL: test_mul_by_7:
189 ; X86-NOOPT: # %bb.0:
190 ; X86-NOOPT-NEXT: imull $7, {{[0-9]+}}(%esp), %eax
191 ; X86-NOOPT-NEXT: retl
193 ; X64-NOOPT-LABEL: test_mul_by_7:
194 ; X64-NOOPT: # %bb.0:
195 ; X64-NOOPT-NEXT: imull $7, %edi, %eax
196 ; X64-NOOPT-NEXT: retq
197 %mul = mul nsw i32 %x, 7
201 define i32 @test_mul_by_8(i32 %x) {
202 ; X86-LABEL: test_mul_by_8:
204 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
205 ; X86-NEXT: shll $3, %eax
208 ; X64-LABEL: test_mul_by_8:
210 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
211 ; X64-NEXT: leal (,%rdi,8), %eax
214 ; X86-NOOPT-LABEL: test_mul_by_8:
215 ; X86-NOOPT: # %bb.0:
216 ; X86-NOOPT-NEXT: movl {{[0-9]+}}(%esp), %eax
217 ; X86-NOOPT-NEXT: shll $3, %eax
218 ; X86-NOOPT-NEXT: retl
220 ; X64-NOOPT-LABEL: test_mul_by_8:
221 ; X64-NOOPT: # %bb.0:
222 ; X64-NOOPT-NEXT: # kill: def $edi killed $edi def $rdi
223 ; X64-NOOPT-NEXT: leal (,%rdi,8), %eax
224 ; X64-NOOPT-NEXT: retq
225 %mul = mul nsw i32 %x, 8
229 define i32 @test_mul_by_9(i32 %x) {
230 ; X86-LABEL: test_mul_by_9:
232 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
233 ; X86-NEXT: leal (%eax,%eax,8), %eax
236 ; X64-LABEL: test_mul_by_9:
238 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
239 ; X64-NEXT: leal (%rdi,%rdi,8), %eax
242 ; X86-NOOPT-LABEL: test_mul_by_9:
243 ; X86-NOOPT: # %bb.0:
244 ; X86-NOOPT-NEXT: imull $9, {{[0-9]+}}(%esp), %eax
245 ; X86-NOOPT-NEXT: retl
247 ; X64-NOOPT-LABEL: test_mul_by_9:
248 ; X64-NOOPT: # %bb.0:
249 ; X64-NOOPT-NEXT: # kill: def $edi killed $edi def $rdi
250 ; X64-NOOPT-NEXT: leal (%rdi,%rdi,8), %eax
251 ; X64-NOOPT-NEXT: retq
252 %mul = mul nsw i32 %x, 9
256 define i32 @test_mul_by_10(i32 %x) {
257 ; X86-LABEL: test_mul_by_10:
259 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
260 ; X86-NEXT: addl %eax, %eax
261 ; X86-NEXT: leal (%eax,%eax,4), %eax
264 ; X64-LABEL: test_mul_by_10:
266 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
267 ; X64-NEXT: addl %edi, %edi
268 ; X64-NEXT: leal (%rdi,%rdi,4), %eax
271 ; X86-NOOPT-LABEL: test_mul_by_10:
272 ; X86-NOOPT: # %bb.0:
273 ; X86-NOOPT-NEXT: imull $10, {{[0-9]+}}(%esp), %eax
274 ; X86-NOOPT-NEXT: retl
276 ; X64-NOOPT-LABEL: test_mul_by_10:
277 ; X64-NOOPT: # %bb.0:
278 ; X64-NOOPT-NEXT: imull $10, %edi, %eax
279 ; X64-NOOPT-NEXT: retq
280 %mul = mul nsw i32 %x, 10
284 define i32 @test_mul_by_11(i32 %x) {
285 ; X86-LABEL: test_mul_by_11:
287 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
288 ; X86-NEXT: leal (%eax,%eax,4), %ecx
289 ; X86-NEXT: leal (%eax,%ecx,2), %eax
292 ; X64-HSW-LABEL: test_mul_by_11:
294 ; X64-HSW-NEXT: # kill: def $edi killed $edi def $rdi
295 ; X64-HSW-NEXT: leal (%rdi,%rdi,4), %eax
296 ; X64-HSW-NEXT: leal (%rdi,%rax,2), %eax
299 ; X64-JAG-LABEL: test_mul_by_11:
301 ; X64-JAG-NEXT: # kill: def $edi killed $edi def $rdi
302 ; X64-JAG-NEXT: leal (%rdi,%rdi,4), %eax
303 ; X64-JAG-NEXT: leal (%rdi,%rax,2), %eax
306 ; X86-NOOPT-LABEL: test_mul_by_11:
307 ; X86-NOOPT: # %bb.0:
308 ; X86-NOOPT-NEXT: imull $11, {{[0-9]+}}(%esp), %eax
309 ; X86-NOOPT-NEXT: retl
311 ; X64-NOOPT-LABEL: test_mul_by_11:
312 ; X64-NOOPT: # %bb.0:
313 ; X64-NOOPT-NEXT: imull $11, %edi, %eax
314 ; X64-NOOPT-NEXT: retq
316 ; X64-SLM-LABEL: test_mul_by_11:
318 ; X64-SLM-NEXT: imull $11, %edi, %eax
320 %mul = mul nsw i32 %x, 11
324 define i32 @test_mul_by_12(i32 %x) {
325 ; X86-LABEL: test_mul_by_12:
327 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
328 ; X86-NEXT: shll $2, %eax
329 ; X86-NEXT: leal (%eax,%eax,2), %eax
332 ; X64-LABEL: test_mul_by_12:
334 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
335 ; X64-NEXT: shll $2, %edi
336 ; X64-NEXT: leal (%rdi,%rdi,2), %eax
339 ; X86-NOOPT-LABEL: test_mul_by_12:
340 ; X86-NOOPT: # %bb.0:
341 ; X86-NOOPT-NEXT: imull $12, {{[0-9]+}}(%esp), %eax
342 ; X86-NOOPT-NEXT: retl
344 ; X64-NOOPT-LABEL: test_mul_by_12:
345 ; X64-NOOPT: # %bb.0:
346 ; X64-NOOPT-NEXT: imull $12, %edi, %eax
347 ; X64-NOOPT-NEXT: retq
348 %mul = mul nsw i32 %x, 12
352 define i32 @test_mul_by_13(i32 %x) {
353 ; X86-LABEL: test_mul_by_13:
355 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
356 ; X86-NEXT: leal (%eax,%eax,2), %ecx
357 ; X86-NEXT: leal (%eax,%ecx,4), %eax
360 ; X64-HSW-LABEL: test_mul_by_13:
362 ; X64-HSW-NEXT: # kill: def $edi killed $edi def $rdi
363 ; X64-HSW-NEXT: leal (%rdi,%rdi,2), %eax
364 ; X64-HSW-NEXT: leal (%rdi,%rax,4), %eax
367 ; X64-JAG-LABEL: test_mul_by_13:
369 ; X64-JAG-NEXT: # kill: def $edi killed $edi def $rdi
370 ; X64-JAG-NEXT: leal (%rdi,%rdi,2), %eax
371 ; X64-JAG-NEXT: leal (%rdi,%rax,4), %eax
374 ; X86-NOOPT-LABEL: test_mul_by_13:
375 ; X86-NOOPT: # %bb.0:
376 ; X86-NOOPT-NEXT: imull $13, {{[0-9]+}}(%esp), %eax
377 ; X86-NOOPT-NEXT: retl
379 ; X64-NOOPT-LABEL: test_mul_by_13:
380 ; X64-NOOPT: # %bb.0:
381 ; X64-NOOPT-NEXT: imull $13, %edi, %eax
382 ; X64-NOOPT-NEXT: retq
384 ; X64-SLM-LABEL: test_mul_by_13:
386 ; X64-SLM-NEXT: imull $13, %edi, %eax
388 %mul = mul nsw i32 %x, 13
392 define i32 @test_mul_by_14(i32 %x) {
393 ; X86-LABEL: test_mul_by_14:
395 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
396 ; X86-NEXT: movl %ecx, %eax
397 ; X86-NEXT: shll $4, %eax
398 ; X86-NEXT: subl %ecx, %eax
399 ; X86-NEXT: subl %ecx, %eax
402 ; X64-LABEL: test_mul_by_14:
404 ; X64-NEXT: movl %edi, %eax
405 ; X64-NEXT: shll $4, %eax
406 ; X64-NEXT: subl %edi, %eax
407 ; X64-NEXT: subl %edi, %eax
410 ; X86-NOOPT-LABEL: test_mul_by_14:
411 ; X86-NOOPT: # %bb.0:
412 ; X86-NOOPT-NEXT: imull $14, {{[0-9]+}}(%esp), %eax
413 ; X86-NOOPT-NEXT: retl
415 ; X64-NOOPT-LABEL: test_mul_by_14:
416 ; X64-NOOPT: # %bb.0:
417 ; X64-NOOPT-NEXT: imull $14, %edi, %eax
418 ; X64-NOOPT-NEXT: retq
419 %mul = mul nsw i32 %x, 14
423 define i32 @test_mul_by_15(i32 %x) {
424 ; X86-LABEL: test_mul_by_15:
426 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
427 ; X86-NEXT: leal (%eax,%eax,4), %eax
428 ; X86-NEXT: leal (%eax,%eax,2), %eax
431 ; X64-LABEL: test_mul_by_15:
433 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
434 ; X64-NEXT: leal (%rdi,%rdi,4), %eax
435 ; X64-NEXT: leal (%rax,%rax,2), %eax
438 ; X86-NOOPT-LABEL: test_mul_by_15:
439 ; X86-NOOPT: # %bb.0:
440 ; X86-NOOPT-NEXT: imull $15, {{[0-9]+}}(%esp), %eax
441 ; X86-NOOPT-NEXT: retl
443 ; X64-NOOPT-LABEL: test_mul_by_15:
444 ; X64-NOOPT: # %bb.0:
445 ; X64-NOOPT-NEXT: imull $15, %edi, %eax
446 ; X64-NOOPT-NEXT: retq
447 %mul = mul nsw i32 %x, 15
451 define i32 @test_mul_by_16(i32 %x) {
452 ; X86-LABEL: test_mul_by_16:
454 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
455 ; X86-NEXT: shll $4, %eax
458 ; X64-LABEL: test_mul_by_16:
460 ; X64-NEXT: movl %edi, %eax
461 ; X64-NEXT: shll $4, %eax
464 ; X86-NOOPT-LABEL: test_mul_by_16:
465 ; X86-NOOPT: # %bb.0:
466 ; X86-NOOPT-NEXT: movl {{[0-9]+}}(%esp), %eax
467 ; X86-NOOPT-NEXT: shll $4, %eax
468 ; X86-NOOPT-NEXT: retl
470 ; X64-NOOPT-LABEL: test_mul_by_16:
471 ; X64-NOOPT: # %bb.0:
472 ; X64-NOOPT-NEXT: movl %edi, %eax
473 ; X64-NOOPT-NEXT: shll $4, %eax
474 ; X64-NOOPT-NEXT: retq
475 %mul = mul nsw i32 %x, 16
479 define i32 @test_mul_by_17(i32 %x) {
480 ; X86-LABEL: test_mul_by_17:
482 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
483 ; X86-NEXT: movl %ecx, %eax
484 ; X86-NEXT: shll $4, %eax
485 ; X86-NEXT: addl %ecx, %eax
488 ; X64-LABEL: test_mul_by_17:
490 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
491 ; X64-NEXT: movl %edi, %eax
492 ; X64-NEXT: shll $4, %eax
493 ; X64-NEXT: addl %edi, %eax
496 ; X86-NOOPT-LABEL: test_mul_by_17:
497 ; X86-NOOPT: # %bb.0:
498 ; X86-NOOPT-NEXT: imull $17, {{[0-9]+}}(%esp), %eax
499 ; X86-NOOPT-NEXT: retl
501 ; X64-NOOPT-LABEL: test_mul_by_17:
502 ; X64-NOOPT: # %bb.0:
503 ; X64-NOOPT-NEXT: imull $17, %edi, %eax
504 ; X64-NOOPT-NEXT: retq
505 %mul = mul nsw i32 %x, 17
509 define i32 @test_mul_by_18(i32 %x) {
510 ; X86-LABEL: test_mul_by_18:
512 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
513 ; X86-NEXT: addl %eax, %eax
514 ; X86-NEXT: leal (%eax,%eax,8), %eax
517 ; X64-LABEL: test_mul_by_18:
519 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
520 ; X64-NEXT: addl %edi, %edi
521 ; X64-NEXT: leal (%rdi,%rdi,8), %eax
524 ; X86-NOOPT-LABEL: test_mul_by_18:
525 ; X86-NOOPT: # %bb.0:
526 ; X86-NOOPT-NEXT: imull $18, {{[0-9]+}}(%esp), %eax
527 ; X86-NOOPT-NEXT: retl
529 ; X64-NOOPT-LABEL: test_mul_by_18:
530 ; X64-NOOPT: # %bb.0:
531 ; X64-NOOPT-NEXT: imull $18, %edi, %eax
532 ; X64-NOOPT-NEXT: retq
533 %mul = mul nsw i32 %x, 18
537 define i32 @test_mul_by_19(i32 %x) {
538 ; X86-LABEL: test_mul_by_19:
540 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
541 ; X86-NEXT: leal (%eax,%eax,8), %ecx
542 ; X86-NEXT: leal (%eax,%ecx,2), %eax
545 ; X64-HSW-LABEL: test_mul_by_19:
547 ; X64-HSW-NEXT: # kill: def $edi killed $edi def $rdi
548 ; X64-HSW-NEXT: leal (%rdi,%rdi,8), %eax
549 ; X64-HSW-NEXT: leal (%rdi,%rax,2), %eax
552 ; X64-JAG-LABEL: test_mul_by_19:
554 ; X64-JAG-NEXT: # kill: def $edi killed $edi def $rdi
555 ; X64-JAG-NEXT: leal (%rdi,%rdi,8), %eax
556 ; X64-JAG-NEXT: leal (%rdi,%rax,2), %eax
559 ; X86-NOOPT-LABEL: test_mul_by_19:
560 ; X86-NOOPT: # %bb.0:
561 ; X86-NOOPT-NEXT: imull $19, {{[0-9]+}}(%esp), %eax
562 ; X86-NOOPT-NEXT: retl
564 ; X64-NOOPT-LABEL: test_mul_by_19:
565 ; X64-NOOPT: # %bb.0:
566 ; X64-NOOPT-NEXT: imull $19, %edi, %eax
567 ; X64-NOOPT-NEXT: retq
569 ; X64-SLM-LABEL: test_mul_by_19:
571 ; X64-SLM-NEXT: imull $19, %edi, %eax
573 %mul = mul nsw i32 %x, 19
577 define i32 @test_mul_by_20(i32 %x) {
578 ; X86-LABEL: test_mul_by_20:
580 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
581 ; X86-NEXT: shll $2, %eax
582 ; X86-NEXT: leal (%eax,%eax,4), %eax
585 ; X64-LABEL: test_mul_by_20:
587 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
588 ; X64-NEXT: shll $2, %edi
589 ; X64-NEXT: leal (%rdi,%rdi,4), %eax
592 ; X86-NOOPT-LABEL: test_mul_by_20:
593 ; X86-NOOPT: # %bb.0:
594 ; X86-NOOPT-NEXT: imull $20, {{[0-9]+}}(%esp), %eax
595 ; X86-NOOPT-NEXT: retl
597 ; X64-NOOPT-LABEL: test_mul_by_20:
598 ; X64-NOOPT: # %bb.0:
599 ; X64-NOOPT-NEXT: imull $20, %edi, %eax
600 ; X64-NOOPT-NEXT: retq
601 %mul = mul nsw i32 %x, 20
605 define i32 @test_mul_by_21(i32 %x) {
606 ; X86-LABEL: test_mul_by_21:
608 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
609 ; X86-NEXT: leal (%eax,%eax,4), %ecx
610 ; X86-NEXT: leal (%eax,%ecx,4), %eax
613 ; X64-HSW-LABEL: test_mul_by_21:
615 ; X64-HSW-NEXT: # kill: def $edi killed $edi def $rdi
616 ; X64-HSW-NEXT: leal (%rdi,%rdi,4), %eax
617 ; X64-HSW-NEXT: leal (%rdi,%rax,4), %eax
620 ; X64-JAG-LABEL: test_mul_by_21:
622 ; X64-JAG-NEXT: # kill: def $edi killed $edi def $rdi
623 ; X64-JAG-NEXT: leal (%rdi,%rdi,4), %eax
624 ; X64-JAG-NEXT: leal (%rdi,%rax,4), %eax
627 ; X86-NOOPT-LABEL: test_mul_by_21:
628 ; X86-NOOPT: # %bb.0:
629 ; X86-NOOPT-NEXT: imull $21, {{[0-9]+}}(%esp), %eax
630 ; X86-NOOPT-NEXT: retl
632 ; X64-NOOPT-LABEL: test_mul_by_21:
633 ; X64-NOOPT: # %bb.0:
634 ; X64-NOOPT-NEXT: imull $21, %edi, %eax
635 ; X64-NOOPT-NEXT: retq
637 ; X64-SLM-LABEL: test_mul_by_21:
639 ; X64-SLM-NEXT: imull $21, %edi, %eax
641 %mul = mul nsw i32 %x, 21
645 define i32 @test_mul_by_22(i32 %x) {
646 ; X86-LABEL: test_mul_by_22:
648 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
649 ; X86-NEXT: leal (%ecx,%ecx,4), %eax
650 ; X86-NEXT: leal (%ecx,%eax,4), %eax
651 ; X86-NEXT: addl %ecx, %eax
654 ; X64-HSW-LABEL: test_mul_by_22:
656 ; X64-HSW-NEXT: # kill: def $edi killed $edi def $rdi
657 ; X64-HSW-NEXT: leal (%rdi,%rdi,4), %eax
658 ; X64-HSW-NEXT: leal (%rdi,%rax,4), %eax
659 ; X64-HSW-NEXT: addl %edi, %eax
662 ; X64-JAG-LABEL: test_mul_by_22:
664 ; X64-JAG-NEXT: # kill: def $edi killed $edi def $rdi
665 ; X64-JAG-NEXT: leal (%rdi,%rdi,4), %eax
666 ; X64-JAG-NEXT: leal (%rdi,%rax,4), %eax
667 ; X64-JAG-NEXT: addl %edi, %eax
670 ; X86-NOOPT-LABEL: test_mul_by_22:
671 ; X86-NOOPT: # %bb.0:
672 ; X86-NOOPT-NEXT: imull $22, {{[0-9]+}}(%esp), %eax
673 ; X86-NOOPT-NEXT: retl
675 ; X64-NOOPT-LABEL: test_mul_by_22:
676 ; X64-NOOPT: # %bb.0:
677 ; X64-NOOPT-NEXT: imull $22, %edi, %eax
678 ; X64-NOOPT-NEXT: retq
680 ; X64-SLM-LABEL: test_mul_by_22:
682 ; X64-SLM-NEXT: imull $22, %edi, %eax
684 %mul = mul nsw i32 %x, 22
688 define i32 @test_mul_by_23(i32 %x) {
689 ; X86-LABEL: test_mul_by_23:
691 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
692 ; X86-NEXT: leal (%ecx,%ecx,2), %eax
693 ; X86-NEXT: shll $3, %eax
694 ; X86-NEXT: subl %ecx, %eax
697 ; X64-HSW-LABEL: test_mul_by_23:
699 ; X64-HSW-NEXT: # kill: def $edi killed $edi def $rdi
700 ; X64-HSW-NEXT: leal (%rdi,%rdi,2), %eax
701 ; X64-HSW-NEXT: shll $3, %eax
702 ; X64-HSW-NEXT: subl %edi, %eax
705 ; X64-JAG-LABEL: test_mul_by_23:
707 ; X64-JAG-NEXT: # kill: def $edi killed $edi def $rdi
708 ; X64-JAG-NEXT: leal (%rdi,%rdi,2), %eax
709 ; X64-JAG-NEXT: shll $3, %eax
710 ; X64-JAG-NEXT: subl %edi, %eax
713 ; X86-NOOPT-LABEL: test_mul_by_23:
714 ; X86-NOOPT: # %bb.0:
715 ; X86-NOOPT-NEXT: imull $23, {{[0-9]+}}(%esp), %eax
716 ; X86-NOOPT-NEXT: retl
718 ; X64-NOOPT-LABEL: test_mul_by_23:
719 ; X64-NOOPT: # %bb.0:
720 ; X64-NOOPT-NEXT: imull $23, %edi, %eax
721 ; X64-NOOPT-NEXT: retq
723 ; X64-SLM-LABEL: test_mul_by_23:
725 ; X64-SLM-NEXT: imull $23, %edi, %eax
727 %mul = mul nsw i32 %x, 23
731 define i32 @test_mul_by_24(i32 %x) {
732 ; X86-LABEL: test_mul_by_24:
734 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
735 ; X86-NEXT: shll $3, %eax
736 ; X86-NEXT: leal (%eax,%eax,2), %eax
739 ; X64-LABEL: test_mul_by_24:
741 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
742 ; X64-NEXT: shll $3, %edi
743 ; X64-NEXT: leal (%rdi,%rdi,2), %eax
746 ; X86-NOOPT-LABEL: test_mul_by_24:
747 ; X86-NOOPT: # %bb.0:
748 ; X86-NOOPT-NEXT: imull $24, {{[0-9]+}}(%esp), %eax
749 ; X86-NOOPT-NEXT: retl
751 ; X64-NOOPT-LABEL: test_mul_by_24:
752 ; X64-NOOPT: # %bb.0:
753 ; X64-NOOPT-NEXT: imull $24, %edi, %eax
754 ; X64-NOOPT-NEXT: retq
755 %mul = mul nsw i32 %x, 24
759 define i32 @test_mul_by_25(i32 %x) {
760 ; X86-LABEL: test_mul_by_25:
762 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
763 ; X86-NEXT: leal (%eax,%eax,4), %eax
764 ; X86-NEXT: leal (%eax,%eax,4), %eax
767 ; X64-LABEL: test_mul_by_25:
769 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
770 ; X64-NEXT: leal (%rdi,%rdi,4), %eax
771 ; X64-NEXT: leal (%rax,%rax,4), %eax
774 ; X86-NOOPT-LABEL: test_mul_by_25:
775 ; X86-NOOPT: # %bb.0:
776 ; X86-NOOPT-NEXT: imull $25, {{[0-9]+}}(%esp), %eax
777 ; X86-NOOPT-NEXT: retl
779 ; X64-NOOPT-LABEL: test_mul_by_25:
780 ; X64-NOOPT: # %bb.0:
781 ; X64-NOOPT-NEXT: imull $25, %edi, %eax
782 ; X64-NOOPT-NEXT: retq
783 %mul = mul nsw i32 %x, 25
787 define i32 @test_mul_by_26(i32 %x) {
788 ; X86-LABEL: test_mul_by_26:
790 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
791 ; X86-NEXT: leal (%ecx,%ecx,4), %eax
792 ; X86-NEXT: leal (%eax,%eax,4), %eax
793 ; X86-NEXT: addl %ecx, %eax
796 ; X64-HSW-LABEL: test_mul_by_26:
798 ; X64-HSW-NEXT: # kill: def $edi killed $edi def $rdi
799 ; X64-HSW-NEXT: leal (%rdi,%rdi,4), %eax
800 ; X64-HSW-NEXT: leal (%rax,%rax,4), %eax
801 ; X64-HSW-NEXT: addl %edi, %eax
804 ; X64-JAG-LABEL: test_mul_by_26:
806 ; X64-JAG-NEXT: # kill: def $edi killed $edi def $rdi
807 ; X64-JAG-NEXT: leal (%rdi,%rdi,4), %eax
808 ; X64-JAG-NEXT: leal (%rax,%rax,4), %eax
809 ; X64-JAG-NEXT: addl %edi, %eax
812 ; X86-NOOPT-LABEL: test_mul_by_26:
813 ; X86-NOOPT: # %bb.0:
814 ; X86-NOOPT-NEXT: imull $26, {{[0-9]+}}(%esp), %eax
815 ; X86-NOOPT-NEXT: retl
817 ; X64-NOOPT-LABEL: test_mul_by_26:
818 ; X64-NOOPT: # %bb.0:
819 ; X64-NOOPT-NEXT: imull $26, %edi, %eax
820 ; X64-NOOPT-NEXT: retq
822 ; X64-SLM-LABEL: test_mul_by_26:
824 ; X64-SLM-NEXT: imull $26, %edi, %eax
826 %mul = mul nsw i32 %x, 26
830 define i32 @test_mul_by_27(i32 %x) {
831 ; X86-LABEL: test_mul_by_27:
833 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
834 ; X86-NEXT: leal (%eax,%eax,8), %eax
835 ; X86-NEXT: leal (%eax,%eax,2), %eax
838 ; X64-LABEL: test_mul_by_27:
840 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
841 ; X64-NEXT: leal (%rdi,%rdi,8), %eax
842 ; X64-NEXT: leal (%rax,%rax,2), %eax
845 ; X86-NOOPT-LABEL: test_mul_by_27:
846 ; X86-NOOPT: # %bb.0:
847 ; X86-NOOPT-NEXT: imull $27, {{[0-9]+}}(%esp), %eax
848 ; X86-NOOPT-NEXT: retl
850 ; X64-NOOPT-LABEL: test_mul_by_27:
851 ; X64-NOOPT: # %bb.0:
852 ; X64-NOOPT-NEXT: imull $27, %edi, %eax
853 ; X64-NOOPT-NEXT: retq
854 %mul = mul nsw i32 %x, 27
858 define i32 @test_mul_by_28(i32 %x) {
859 ; X86-LABEL: test_mul_by_28:
861 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
862 ; X86-NEXT: leal (%ecx,%ecx,8), %eax
863 ; X86-NEXT: leal (%eax,%eax,2), %eax
864 ; X86-NEXT: addl %ecx, %eax
867 ; X64-HSW-LABEL: test_mul_by_28:
869 ; X64-HSW-NEXT: # kill: def $edi killed $edi def $rdi
870 ; X64-HSW-NEXT: leal (%rdi,%rdi,8), %eax
871 ; X64-HSW-NEXT: leal (%rax,%rax,2), %eax
872 ; X64-HSW-NEXT: addl %edi, %eax
875 ; X64-JAG-LABEL: test_mul_by_28:
877 ; X64-JAG-NEXT: # kill: def $edi killed $edi def $rdi
878 ; X64-JAG-NEXT: leal (%rdi,%rdi,8), %eax
879 ; X64-JAG-NEXT: leal (%rax,%rax,2), %eax
880 ; X64-JAG-NEXT: addl %edi, %eax
883 ; X86-NOOPT-LABEL: test_mul_by_28:
884 ; X86-NOOPT: # %bb.0:
885 ; X86-NOOPT-NEXT: imull $28, {{[0-9]+}}(%esp), %eax
886 ; X86-NOOPT-NEXT: retl
888 ; X64-NOOPT-LABEL: test_mul_by_28:
889 ; X64-NOOPT: # %bb.0:
890 ; X64-NOOPT-NEXT: imull $28, %edi, %eax
891 ; X64-NOOPT-NEXT: retq
893 ; X64-SLM-LABEL: test_mul_by_28:
895 ; X64-SLM-NEXT: imull $28, %edi, %eax
897 %mul = mul nsw i32 %x, 28
901 define i32 @test_mul_by_29(i32 %x) {
902 ; X86-LABEL: test_mul_by_29:
904 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
905 ; X86-NEXT: leal (%ecx,%ecx,8), %eax
906 ; X86-NEXT: leal (%eax,%eax,2), %eax
907 ; X86-NEXT: addl %ecx, %eax
908 ; X86-NEXT: addl %ecx, %eax
911 ; X64-HSW-LABEL: test_mul_by_29:
913 ; X64-HSW-NEXT: # kill: def $edi killed $edi def $rdi
914 ; X64-HSW-NEXT: leal (%rdi,%rdi,8), %eax
915 ; X64-HSW-NEXT: leal (%rax,%rax,2), %eax
916 ; X64-HSW-NEXT: addl %edi, %eax
917 ; X64-HSW-NEXT: addl %edi, %eax
920 ; X64-JAG-LABEL: test_mul_by_29:
922 ; X64-JAG-NEXT: # kill: def $edi killed $edi def $rdi
923 ; X64-JAG-NEXT: leal (%rdi,%rdi,8), %eax
924 ; X64-JAG-NEXT: leal (%rax,%rax,2), %eax
925 ; X64-JAG-NEXT: addl %edi, %eax
926 ; X64-JAG-NEXT: addl %edi, %eax
929 ; X86-NOOPT-LABEL: test_mul_by_29:
930 ; X86-NOOPT: # %bb.0:
931 ; X86-NOOPT-NEXT: imull $29, {{[0-9]+}}(%esp), %eax
932 ; X86-NOOPT-NEXT: retl
934 ; X64-NOOPT-LABEL: test_mul_by_29:
935 ; X64-NOOPT: # %bb.0:
936 ; X64-NOOPT-NEXT: imull $29, %edi, %eax
937 ; X64-NOOPT-NEXT: retq
939 ; X64-SLM-LABEL: test_mul_by_29:
941 ; X64-SLM-NEXT: imull $29, %edi, %eax
943 %mul = mul nsw i32 %x, 29
947 define i32 @test_mul_by_30(i32 %x) {
948 ; X86-LABEL: test_mul_by_30:
950 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
951 ; X86-NEXT: movl %ecx, %eax
952 ; X86-NEXT: shll $5, %eax
953 ; X86-NEXT: subl %ecx, %eax
954 ; X86-NEXT: subl %ecx, %eax
957 ; X64-LABEL: test_mul_by_30:
959 ; X64-NEXT: movl %edi, %eax
960 ; X64-NEXT: shll $5, %eax
961 ; X64-NEXT: subl %edi, %eax
962 ; X64-NEXT: subl %edi, %eax
965 ; X86-NOOPT-LABEL: test_mul_by_30:
966 ; X86-NOOPT: # %bb.0:
967 ; X86-NOOPT-NEXT: imull $30, {{[0-9]+}}(%esp), %eax
968 ; X86-NOOPT-NEXT: retl
970 ; X64-NOOPT-LABEL: test_mul_by_30:
971 ; X64-NOOPT: # %bb.0:
972 ; X64-NOOPT-NEXT: imull $30, %edi, %eax
973 ; X64-NOOPT-NEXT: retq
974 %mul = mul nsw i32 %x, 30
978 define i32 @test_mul_by_31(i32 %x) {
979 ; X86-LABEL: test_mul_by_31:
981 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
982 ; X86-NEXT: movl %ecx, %eax
983 ; X86-NEXT: shll $5, %eax
984 ; X86-NEXT: subl %ecx, %eax
987 ; X64-LABEL: test_mul_by_31:
989 ; X64-NEXT: movl %edi, %eax
990 ; X64-NEXT: shll $5, %eax
991 ; X64-NEXT: subl %edi, %eax
994 ; X86-NOOPT-LABEL: test_mul_by_31:
995 ; X86-NOOPT: # %bb.0:
996 ; X86-NOOPT-NEXT: imull $31, {{[0-9]+}}(%esp), %eax
997 ; X86-NOOPT-NEXT: retl
999 ; X64-NOOPT-LABEL: test_mul_by_31:
1000 ; X64-NOOPT: # %bb.0:
1001 ; X64-NOOPT-NEXT: imull $31, %edi, %eax
1002 ; X64-NOOPT-NEXT: retq
1003 %mul = mul nsw i32 %x, 31
1007 define i32 @test_mul_by_32(i32 %x) {
1008 ; X86-LABEL: test_mul_by_32:
1010 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1011 ; X86-NEXT: shll $5, %eax
1014 ; X64-LABEL: test_mul_by_32:
1016 ; X64-NEXT: movl %edi, %eax
1017 ; X64-NEXT: shll $5, %eax
1020 ; X86-NOOPT-LABEL: test_mul_by_32:
1021 ; X86-NOOPT: # %bb.0:
1022 ; X86-NOOPT-NEXT: movl {{[0-9]+}}(%esp), %eax
1023 ; X86-NOOPT-NEXT: shll $5, %eax
1024 ; X86-NOOPT-NEXT: retl
1026 ; X64-NOOPT-LABEL: test_mul_by_32:
1027 ; X64-NOOPT: # %bb.0:
1028 ; X64-NOOPT-NEXT: movl %edi, %eax
1029 ; X64-NOOPT-NEXT: shll $5, %eax
1030 ; X64-NOOPT-NEXT: retq
1031 %mul = mul nsw i32 %x, 32
1035 define i32 @test_mul_by_37(i32 %x) {
1036 ; X86-LABEL: test_mul_by_37:
1038 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1039 ; X86-NEXT: leal (%eax,%eax,8), %ecx
1040 ; X86-NEXT: leal (%eax,%ecx,4), %eax
1043 ; X64-HSW-LABEL: test_mul_by_37:
1045 ; X64-HSW-NEXT: # kill: def $edi killed $edi def $rdi
1046 ; X64-HSW-NEXT: leal (%rdi,%rdi,8), %eax
1047 ; X64-HSW-NEXT: leal (%rdi,%rax,4), %eax
1048 ; X64-HSW-NEXT: retq
1050 ; X64-JAG-LABEL: test_mul_by_37:
1052 ; X64-JAG-NEXT: # kill: def $edi killed $edi def $rdi
1053 ; X64-JAG-NEXT: leal (%rdi,%rdi,8), %eax
1054 ; X64-JAG-NEXT: leal (%rdi,%rax,4), %eax
1055 ; X64-JAG-NEXT: retq
1057 ; X86-NOOPT-LABEL: test_mul_by_37:
1058 ; X86-NOOPT: # %bb.0:
1059 ; X86-NOOPT-NEXT: imull $37, {{[0-9]+}}(%esp), %eax
1060 ; X86-NOOPT-NEXT: retl
1062 ; X64-NOOPT-LABEL: test_mul_by_37:
1063 ; X64-NOOPT: # %bb.0:
1064 ; X64-NOOPT-NEXT: imull $37, %edi, %eax
1065 ; X64-NOOPT-NEXT: retq
1067 ; X64-SLM-LABEL: test_mul_by_37:
1069 ; X64-SLM-NEXT: imull $37, %edi, %eax
1070 ; X64-SLM-NEXT: retq
1071 %mul = mul nsw i32 %x, 37
1075 define i32 @test_mul_by_41(i32 %x) {
1076 ; X86-LABEL: test_mul_by_41:
1078 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1079 ; X86-NEXT: leal (%eax,%eax,4), %ecx
1080 ; X86-NEXT: leal (%eax,%ecx,8), %eax
1083 ; X64-HSW-LABEL: test_mul_by_41:
1085 ; X64-HSW-NEXT: # kill: def $edi killed $edi def $rdi
1086 ; X64-HSW-NEXT: leal (%rdi,%rdi,4), %eax
1087 ; X64-HSW-NEXT: leal (%rdi,%rax,8), %eax
1088 ; X64-HSW-NEXT: retq
1090 ; X64-JAG-LABEL: test_mul_by_41:
1092 ; X64-JAG-NEXT: # kill: def $edi killed $edi def $rdi
1093 ; X64-JAG-NEXT: leal (%rdi,%rdi,4), %eax
1094 ; X64-JAG-NEXT: leal (%rdi,%rax,8), %eax
1095 ; X64-JAG-NEXT: retq
1097 ; X86-NOOPT-LABEL: test_mul_by_41:
1098 ; X86-NOOPT: # %bb.0:
1099 ; X86-NOOPT-NEXT: imull $41, {{[0-9]+}}(%esp), %eax
1100 ; X86-NOOPT-NEXT: retl
1102 ; X64-NOOPT-LABEL: test_mul_by_41:
1103 ; X64-NOOPT: # %bb.0:
1104 ; X64-NOOPT-NEXT: imull $41, %edi, %eax
1105 ; X64-NOOPT-NEXT: retq
1107 ; X64-SLM-LABEL: test_mul_by_41:
1109 ; X64-SLM-NEXT: imull $41, %edi, %eax
1110 ; X64-SLM-NEXT: retq
1111 %mul = mul nsw i32 %x, 41
1115 define i32 @test_mul_by_62(i32 %x) {
1116 ; X86-LABEL: test_mul_by_62:
1118 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1119 ; X86-NEXT: movl %ecx, %eax
1120 ; X86-NEXT: shll $6, %eax
1121 ; X86-NEXT: subl %ecx, %eax
1122 ; X86-NEXT: subl %ecx, %eax
1125 ; X64-LABEL: test_mul_by_62:
1127 ; X64-NEXT: movl %edi, %eax
1128 ; X64-NEXT: shll $6, %eax
1129 ; X64-NEXT: subl %edi, %eax
1130 ; X64-NEXT: subl %edi, %eax
1133 ; X86-NOOPT-LABEL: test_mul_by_62:
1134 ; X86-NOOPT: # %bb.0:
1135 ; X86-NOOPT-NEXT: imull $62, {{[0-9]+}}(%esp), %eax
1136 ; X86-NOOPT-NEXT: retl
1138 ; X64-NOOPT-LABEL: test_mul_by_62:
1139 ; X64-NOOPT: # %bb.0:
1140 ; X64-NOOPT-NEXT: imull $62, %edi, %eax
1141 ; X64-NOOPT-NEXT: retq
1142 %mul = mul nsw i32 %x, 62
1146 define i32 @test_mul_by_66(i32 %x) {
1147 ; X86-LABEL: test_mul_by_66:
1149 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1150 ; X86-NEXT: movl %eax, %ecx
1151 ; X86-NEXT: shll $6, %ecx
1152 ; X86-NEXT: leal (%ecx,%eax,2), %eax
1155 ; X64-HSW-LABEL: test_mul_by_66:
1157 ; X64-HSW-NEXT: # kill: def $edi killed $edi def $rdi
1158 ; X64-HSW-NEXT: movl %edi, %eax
1159 ; X64-HSW-NEXT: shll $6, %eax
1160 ; X64-HSW-NEXT: leal (%rax,%rdi,2), %eax
1161 ; X64-HSW-NEXT: retq
1163 ; X64-JAG-LABEL: test_mul_by_66:
1165 ; X64-JAG-NEXT: # kill: def $edi killed $edi def $rdi
1166 ; X64-JAG-NEXT: movl %edi, %eax
1167 ; X64-JAG-NEXT: shll $6, %eax
1168 ; X64-JAG-NEXT: leal (%rax,%rdi,2), %eax
1169 ; X64-JAG-NEXT: retq
1171 ; X86-NOOPT-LABEL: test_mul_by_66:
1172 ; X86-NOOPT: # %bb.0:
1173 ; X86-NOOPT-NEXT: imull $66, {{[0-9]+}}(%esp), %eax
1174 ; X86-NOOPT-NEXT: retl
1176 ; X64-NOOPT-LABEL: test_mul_by_66:
1177 ; X64-NOOPT: # %bb.0:
1178 ; X64-NOOPT-NEXT: imull $66, %edi, %eax
1179 ; X64-NOOPT-NEXT: retq
1181 ; X64-SLM-LABEL: test_mul_by_66:
1183 ; X64-SLM-NEXT: # kill: def $edi killed $edi def $rdi
1184 ; X64-SLM-NEXT: movl %edi, %eax
1185 ; X64-SLM-NEXT: shll $6, %eax
1186 ; X64-SLM-NEXT: addl %edi, %eax
1187 ; X64-SLM-NEXT: addl %edi, %eax
1188 ; X64-SLM-NEXT: retq
1189 %mul = mul nsw i32 %x, 66
1193 define i32 @test_mul_by_73(i32 %x) {
1194 ; X86-LABEL: test_mul_by_73:
1196 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1197 ; X86-NEXT: leal (%eax,%eax,8), %ecx
1198 ; X86-NEXT: leal (%eax,%ecx,8), %eax
1201 ; X64-HSW-LABEL: test_mul_by_73:
1203 ; X64-HSW-NEXT: # kill: def $edi killed $edi def $rdi
1204 ; X64-HSW-NEXT: leal (%rdi,%rdi,8), %eax
1205 ; X64-HSW-NEXT: leal (%rdi,%rax,8), %eax
1206 ; X64-HSW-NEXT: retq
1208 ; X64-JAG-LABEL: test_mul_by_73:
1210 ; X64-JAG-NEXT: # kill: def $edi killed $edi def $rdi
1211 ; X64-JAG-NEXT: leal (%rdi,%rdi,8), %eax
1212 ; X64-JAG-NEXT: leal (%rdi,%rax,8), %eax
1213 ; X64-JAG-NEXT: retq
1215 ; X86-NOOPT-LABEL: test_mul_by_73:
1216 ; X86-NOOPT: # %bb.0:
1217 ; X86-NOOPT-NEXT: imull $73, {{[0-9]+}}(%esp), %eax
1218 ; X86-NOOPT-NEXT: retl
1220 ; X64-NOOPT-LABEL: test_mul_by_73:
1221 ; X64-NOOPT: # %bb.0:
1222 ; X64-NOOPT-NEXT: imull $73, %edi, %eax
1223 ; X64-NOOPT-NEXT: retq
1225 ; X64-SLM-LABEL: test_mul_by_73:
1227 ; X64-SLM-NEXT: imull $73, %edi, %eax
1228 ; X64-SLM-NEXT: retq
1229 %mul = mul nsw i32 %x, 73
1233 define i32 @test_mul_by_520(i32 %x) {
1234 ; X86-LABEL: test_mul_by_520:
1236 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1237 ; X86-NEXT: movl %eax, %ecx
1238 ; X86-NEXT: shll $9, %ecx
1239 ; X86-NEXT: leal (%ecx,%eax,8), %eax
1242 ; X64-HSW-LABEL: test_mul_by_520:
1244 ; X64-HSW-NEXT: # kill: def $edi killed $edi def $rdi
1245 ; X64-HSW-NEXT: movl %edi, %eax
1246 ; X64-HSW-NEXT: shll $9, %eax
1247 ; X64-HSW-NEXT: leal (%rax,%rdi,8), %eax
1248 ; X64-HSW-NEXT: retq
1250 ; X64-JAG-LABEL: test_mul_by_520:
1252 ; X64-JAG-NEXT: # kill: def $edi killed $edi def $rdi
1253 ; X64-JAG-NEXT: movl %edi, %eax
1254 ; X64-JAG-NEXT: shll $9, %eax
1255 ; X64-JAG-NEXT: leal (%rax,%rdi,8), %eax
1256 ; X64-JAG-NEXT: retq
1258 ; X86-NOOPT-LABEL: test_mul_by_520:
1259 ; X86-NOOPT: # %bb.0:
1260 ; X86-NOOPT-NEXT: imull $520, {{[0-9]+}}(%esp), %eax # imm = 0x208
1261 ; X86-NOOPT-NEXT: retl
1263 ; X64-NOOPT-LABEL: test_mul_by_520:
1264 ; X64-NOOPT: # %bb.0:
1265 ; X64-NOOPT-NEXT: imull $520, %edi, %eax # imm = 0x208
1266 ; X64-NOOPT-NEXT: retq
1268 ; X64-SLM-LABEL: test_mul_by_520:
1270 ; X64-SLM-NEXT: imull $520, %edi, %eax # imm = 0x208
1271 ; X64-SLM-NEXT: retq
1272 %mul = mul nsw i32 %x, 520
1276 define i32 @test_mul_by_neg10(i32 %x) {
1277 ; X86-LABEL: test_mul_by_neg10:
1279 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1280 ; X86-NEXT: addl %eax, %eax
1281 ; X86-NEXT: leal (%eax,%eax,4), %eax
1282 ; X86-NEXT: negl %eax
1285 ; X64-LABEL: test_mul_by_neg10:
1287 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
1288 ; X64-NEXT: addl %edi, %edi
1289 ; X64-NEXT: leal (%rdi,%rdi,4), %eax
1290 ; X64-NEXT: negl %eax
1293 ; X86-NOOPT-LABEL: test_mul_by_neg10:
1294 ; X86-NOOPT: # %bb.0:
1295 ; X86-NOOPT-NEXT: imull $-10, {{[0-9]+}}(%esp), %eax
1296 ; X86-NOOPT-NEXT: retl
1298 ; X64-NOOPT-LABEL: test_mul_by_neg10:
1299 ; X64-NOOPT: # %bb.0:
1300 ; X64-NOOPT-NEXT: imull $-10, %edi, %eax
1301 ; X64-NOOPT-NEXT: retq
1302 %mul = mul nsw i32 %x, -10
1306 define i32 @test_mul_by_neg36(i32 %x) {
1307 ; X86-LABEL: test_mul_by_neg36:
1309 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1310 ; X86-NEXT: shll $2, %eax
1311 ; X86-NEXT: leal (%eax,%eax,8), %eax
1312 ; X86-NEXT: negl %eax
1315 ; X64-LABEL: test_mul_by_neg36:
1317 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
1318 ; X64-NEXT: shll $2, %edi
1319 ; X64-NEXT: leal (%rdi,%rdi,8), %eax
1320 ; X64-NEXT: negl %eax
1323 ; X86-NOOPT-LABEL: test_mul_by_neg36:
1324 ; X86-NOOPT: # %bb.0:
1325 ; X86-NOOPT-NEXT: imull $-36, {{[0-9]+}}(%esp), %eax
1326 ; X86-NOOPT-NEXT: retl
1328 ; X64-NOOPT-LABEL: test_mul_by_neg36:
1329 ; X64-NOOPT: # %bb.0:
1330 ; X64-NOOPT-NEXT: imull $-36, %edi, %eax
1331 ; X64-NOOPT-NEXT: retq
1332 %mul = mul nsw i32 %x, -36
1337 define i32 @test_mul_spec(i32 %x) nounwind {
1338 ; X86-LABEL: test_mul_spec:
1340 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1341 ; X86-NEXT: leal 42(%eax,%eax,8), %ecx
1342 ; X86-NEXT: leal 2(%eax,%eax,4), %eax
1343 ; X86-NEXT: imull %ecx, %eax
1346 ; X64-HSW-LABEL: test_mul_spec:
1348 ; X64-HSW-NEXT: # kill: def $edi killed $edi def $rdi
1349 ; X64-HSW-NEXT: leal (%rdi,%rdi,8), %ecx
1350 ; X64-HSW-NEXT: addl $42, %ecx
1351 ; X64-HSW-NEXT: leal (%rdi,%rdi,4), %eax
1352 ; X64-HSW-NEXT: addl $2, %eax
1353 ; X64-HSW-NEXT: imull %ecx, %eax
1354 ; X64-HSW-NEXT: retq
1356 ; X64-JAG-LABEL: test_mul_spec:
1358 ; X64-JAG-NEXT: # kill: def $edi killed $edi def $rdi
1359 ; X64-JAG-NEXT: leal 42(%rdi,%rdi,8), %ecx
1360 ; X64-JAG-NEXT: leal 2(%rdi,%rdi,4), %eax
1361 ; X64-JAG-NEXT: imull %ecx, %eax
1362 ; X64-JAG-NEXT: retq
1364 ; X86-NOOPT-LABEL: test_mul_spec:
1365 ; X86-NOOPT: # %bb.0:
1366 ; X86-NOOPT-NEXT: movl {{[0-9]+}}(%esp), %eax
1367 ; X86-NOOPT-NEXT: leal 42(%eax,%eax,8), %ecx
1368 ; X86-NOOPT-NEXT: leal 2(%eax,%eax,4), %eax
1369 ; X86-NOOPT-NEXT: imull %ecx, %eax
1370 ; X86-NOOPT-NEXT: retl
1372 ; HSW-NOOPT-LABEL: test_mul_spec:
1373 ; HSW-NOOPT: # %bb.0:
1374 ; HSW-NOOPT-NEXT: # kill: def $edi killed $edi def $rdi
1375 ; HSW-NOOPT-NEXT: leal (%rdi,%rdi,8), %ecx
1376 ; HSW-NOOPT-NEXT: addl $42, %ecx
1377 ; HSW-NOOPT-NEXT: leal (%rdi,%rdi,4), %eax
1378 ; HSW-NOOPT-NEXT: addl $2, %eax
1379 ; HSW-NOOPT-NEXT: imull %ecx, %eax
1380 ; HSW-NOOPT-NEXT: retq
1382 ; JAG-NOOPT-LABEL: test_mul_spec:
1383 ; JAG-NOOPT: # %bb.0:
1384 ; JAG-NOOPT-NEXT: # kill: def $edi killed $edi def $rdi
1385 ; JAG-NOOPT-NEXT: leal 42(%rdi,%rdi,8), %ecx
1386 ; JAG-NOOPT-NEXT: leal 2(%rdi,%rdi,4), %eax
1387 ; JAG-NOOPT-NEXT: imull %ecx, %eax
1388 ; JAG-NOOPT-NEXT: retq
1390 ; X64-SLM-LABEL: test_mul_spec:
1392 ; X64-SLM-NEXT: # kill: def $edi killed $edi def $rdi
1393 ; X64-SLM-NEXT: leal 42(%rdi,%rdi,8), %ecx
1394 ; X64-SLM-NEXT: leal 2(%rdi,%rdi,4), %eax
1395 ; X64-SLM-NEXT: imull %ecx, %eax
1396 ; X64-SLM-NEXT: retq
1398 ; SLM-NOOPT-LABEL: test_mul_spec:
1399 ; SLM-NOOPT: # %bb.0:
1400 ; SLM-NOOPT-NEXT: # kill: def $edi killed $edi def $rdi
1401 ; SLM-NOOPT-NEXT: leal 42(%rdi,%rdi,8), %ecx
1402 ; SLM-NOOPT-NEXT: leal 2(%rdi,%rdi,4), %eax
1403 ; SLM-NOOPT-NEXT: imull %ecx, %eax
1404 ; SLM-NOOPT-NEXT: retq
1405 %mul = mul nsw i32 %x, 9
1406 %add = add nsw i32 %mul, 42
1407 %mul2 = mul nsw i32 %x, 5
1408 %add2 = add nsw i32 %mul2, 2
1409 %mul3 = mul nsw i32 %add, %add2
1413 ; This makes sure we are able to fold the negate generated by the mul expansion
1414 ; into the next instruction.
1415 ; FIXME: We make this work.
1416 define i32 @mul_neg_fold(i32 %a, i32 %b) {
1417 ; X86-LABEL: mul_neg_fold:
1419 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1420 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1421 ; X86-NEXT: leal (%ecx,%ecx,8), %ecx
1422 ; X86-NEXT: subl %ecx, %eax
1425 ; X64-HSW-LABEL: mul_neg_fold:
1427 ; X64-HSW-NEXT: movl %esi, %eax
1428 ; X64-HSW-NEXT: # kill: def $edi killed $edi def $rdi
1429 ; X64-HSW-NEXT: leal (%rdi,%rdi,8), %ecx
1430 ; X64-HSW-NEXT: subl %ecx, %eax
1431 ; X64-HSW-NEXT: retq
1433 ; X64-JAG-LABEL: mul_neg_fold:
1435 ; X64-JAG-NEXT: # kill: def $edi killed $edi def $rdi
1436 ; X64-JAG-NEXT: leal (%rdi,%rdi,8), %ecx
1437 ; X64-JAG-NEXT: movl %esi, %eax
1438 ; X64-JAG-NEXT: subl %ecx, %eax
1439 ; X64-JAG-NEXT: retq
1441 ; X86-NOOPT-LABEL: mul_neg_fold:
1442 ; X86-NOOPT: # %bb.0:
1443 ; X86-NOOPT-NEXT: imull $-9, {{[0-9]+}}(%esp), %eax
1444 ; X86-NOOPT-NEXT: addl {{[0-9]+}}(%esp), %eax
1445 ; X86-NOOPT-NEXT: retl
1447 ; X64-NOOPT-LABEL: mul_neg_fold:
1448 ; X64-NOOPT: # %bb.0:
1449 ; X64-NOOPT-NEXT: imull $-9, %edi, %eax
1450 ; X64-NOOPT-NEXT: addl %esi, %eax
1451 ; X64-NOOPT-NEXT: retq
1453 ; X64-SLM-LABEL: mul_neg_fold:
1455 ; X64-SLM-NEXT: # kill: def $edi killed $edi def $rdi
1456 ; X64-SLM-NEXT: movl %esi, %eax
1457 ; X64-SLM-NEXT: leal (%rdi,%rdi,8), %ecx
1458 ; X64-SLM-NEXT: subl %ecx, %eax
1459 ; X64-SLM-NEXT: retq