• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i686-unknown                                                  | FileCheck %s --check-prefixes=X86
3; RUN: llc < %s -mtriple=i686-unknown -mul-constant-optimization=false                 | FileCheck %s --check-prefixes=X86-NOOPT
4; RUN: llc < %s -mtriple=x86_64-unknown -mcpu=haswell                                  | FileCheck %s --check-prefixes=X64,X64-OPT,X64-HSW
5; RUN: llc < %s -mtriple=x86_64-unknown -mcpu=btver2                                   | FileCheck %s --check-prefixes=X64,X64-OPT,X64-JAG
6; RUN: llc < %s -mtriple=x86_64-unknown -mcpu=slm                                      | FileCheck %s --check-prefixes=X64,X64-OPT,X64-SLM
7; RUN: llc < %s -mtriple=x86_64-unknown -mul-constant-optimization=false -mcpu=haswell | FileCheck %s --check-prefixes=X64,X64-NOOPT,X64-HSW-NOOPT
8; RUN: llc < %s -mtriple=x86_64-unknown -mul-constant-optimization=false -mcpu=btver2  | FileCheck %s --check-prefixes=X64,X64-NOOPT,X64-JAG-NOOPT
9; RUN: llc < %s -mtriple=x86_64-unknown -mul-constant-optimization=false -mcpu=slm     | FileCheck %s --check-prefixes=X64,X64-NOOPT,X64-SLM-NOOPT
10
11define i64 @test_mul_by_1(i64 %x) nounwind {
12; X86-LABEL: test_mul_by_1:
13; X86:       # %bb.0:
14; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
15; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
16; X86-NEXT:    retl
17;
18; X86-NOOPT-LABEL: test_mul_by_1:
19; X86-NOOPT:       # %bb.0:
20; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %eax
21; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %edx
22; X86-NOOPT-NEXT:    retl
23;
24; X64-LABEL: test_mul_by_1:
25; X64:       # %bb.0:
26; X64-NEXT:    movq %rdi, %rax
27; X64-NEXT:    retq
28  %mul = mul nsw i64 %x, 1
29  ret i64 %mul
30}
31
32define i64 @test_mul_by_2(i64 %x) {
33; X86-LABEL: test_mul_by_2:
34; X86:       # %bb.0:
35; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
36; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
37; X86-NEXT:    shldl $1, %eax, %edx
38; X86-NEXT:    addl %eax, %eax
39; X86-NEXT:    retl
40;
41; X86-NOOPT-LABEL: test_mul_by_2:
42; X86-NOOPT:       # %bb.0:
43; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %eax
44; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %edx
45; X86-NOOPT-NEXT:    shldl $1, %eax, %edx
46; X86-NOOPT-NEXT:    addl %eax, %eax
47; X86-NOOPT-NEXT:    retl
48;
49; X64-LABEL: test_mul_by_2:
50; X64:       # %bb.0:
51; X64-NEXT:    leaq (%rdi,%rdi), %rax
52; X64-NEXT:    retq
53  %mul = mul nsw i64 %x, 2
54  ret i64 %mul
55}
56
57define i64 @test_mul_by_3(i64 %x) {
58; X86-LABEL: test_mul_by_3:
59; X86:       # %bb.0:
60; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
61; X86-NEXT:    leal (%eax,%eax,2), %ecx
62; X86-NEXT:    movl $3, %eax
63; X86-NEXT:    mull {{[0-9]+}}(%esp)
64; X86-NEXT:    addl %ecx, %edx
65; X86-NEXT:    retl
66;
67; X86-NOOPT-LABEL: test_mul_by_3:
68; X86-NOOPT:       # %bb.0:
69; X86-NOOPT-NEXT:    movl $3, %eax
70; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
71; X86-NOOPT-NEXT:    imull $3, {{[0-9]+}}(%esp), %ecx
72; X86-NOOPT-NEXT:    addl %ecx, %edx
73; X86-NOOPT-NEXT:    retl
74;
75; X64-LABEL: test_mul_by_3:
76; X64:       # %bb.0:
77; X64-NEXT:    leaq (%rdi,%rdi,2), %rax
78; X64-NEXT:    retq
79  %mul = mul nsw i64 %x, 3
80  ret i64 %mul
81}
82
83define i64 @test_mul_by_4(i64 %x) {
84; X86-LABEL: test_mul_by_4:
85; X86:       # %bb.0:
86; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
87; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
88; X86-NEXT:    shldl $2, %eax, %edx
89; X86-NEXT:    shll $2, %eax
90; X86-NEXT:    retl
91;
92; X86-NOOPT-LABEL: test_mul_by_4:
93; X86-NOOPT:       # %bb.0:
94; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %eax
95; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %edx
96; X86-NOOPT-NEXT:    shldl $2, %eax, %edx
97; X86-NOOPT-NEXT:    shll $2, %eax
98; X86-NOOPT-NEXT:    retl
99;
100; X64-LABEL: test_mul_by_4:
101; X64:       # %bb.0:
102; X64-NEXT:    leaq (,%rdi,4), %rax
103; X64-NEXT:    retq
104  %mul = mul nsw i64 %x, 4
105  ret i64 %mul
106}
107
108define i64 @test_mul_by_5(i64 %x) {
109; X86-LABEL: test_mul_by_5:
110; X86:       # %bb.0:
111; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
112; X86-NEXT:    leal (%eax,%eax,4), %ecx
113; X86-NEXT:    movl $5, %eax
114; X86-NEXT:    mull {{[0-9]+}}(%esp)
115; X86-NEXT:    addl %ecx, %edx
116; X86-NEXT:    retl
117;
118; X86-NOOPT-LABEL: test_mul_by_5:
119; X86-NOOPT:       # %bb.0:
120; X86-NOOPT-NEXT:    movl $5, %eax
121; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
122; X86-NOOPT-NEXT:    imull $5, {{[0-9]+}}(%esp), %ecx
123; X86-NOOPT-NEXT:    addl %ecx, %edx
124; X86-NOOPT-NEXT:    retl
125;
126; X64-LABEL: test_mul_by_5:
127; X64:       # %bb.0:
128; X64-NEXT:    leaq (%rdi,%rdi,4), %rax
129; X64-NEXT:    retq
130  %mul = mul nsw i64 %x, 5
131  ret i64 %mul
132}
133
134define i64 @test_mul_by_6(i64 %x) {
135; X86-LABEL: test_mul_by_6:
136; X86:       # %bb.0:
137; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
138; X86-NEXT:    leal (%eax,%eax,2), %ecx
139; X86-NEXT:    movl $6, %eax
140; X86-NEXT:    mull {{[0-9]+}}(%esp)
141; X86-NEXT:    leal (%edx,%ecx,2), %edx
142; X86-NEXT:    retl
143;
144; X86-NOOPT-LABEL: test_mul_by_6:
145; X86-NOOPT:       # %bb.0:
146; X86-NOOPT-NEXT:    movl $6, %eax
147; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
148; X86-NOOPT-NEXT:    imull $6, {{[0-9]+}}(%esp), %ecx
149; X86-NOOPT-NEXT:    addl %ecx, %edx
150; X86-NOOPT-NEXT:    retl
151;
152; X64-OPT-LABEL: test_mul_by_6:
153; X64-OPT:       # %bb.0:
154; X64-OPT-NEXT:    addq %rdi, %rdi
155; X64-OPT-NEXT:    leaq (%rdi,%rdi,2), %rax
156; X64-OPT-NEXT:    retq
157;
158; X64-NOOPT-LABEL: test_mul_by_6:
159; X64-NOOPT:       # %bb.0:
160; X64-NOOPT-NEXT:    imulq $6, %rdi, %rax
161; X64-NOOPT-NEXT:    retq
162  %mul = mul nsw i64 %x, 6
163  ret i64 %mul
164}
165
166define i64 @test_mul_by_7(i64 %x) {
167; X86-LABEL: test_mul_by_7:
168; X86:       # %bb.0:
169; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
170; X86-NEXT:    leal (,%eax,8), %ecx
171; X86-NEXT:    subl %eax, %ecx
172; X86-NEXT:    movl $7, %eax
173; X86-NEXT:    mull {{[0-9]+}}(%esp)
174; X86-NEXT:    addl %ecx, %edx
175; X86-NEXT:    retl
176;
177; X86-NOOPT-LABEL: test_mul_by_7:
178; X86-NOOPT:       # %bb.0:
179; X86-NOOPT-NEXT:    movl $7, %eax
180; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
181; X86-NOOPT-NEXT:    imull $7, {{[0-9]+}}(%esp), %ecx
182; X86-NOOPT-NEXT:    addl %ecx, %edx
183; X86-NOOPT-NEXT:    retl
184;
185; X64-OPT-LABEL: test_mul_by_7:
186; X64-OPT:       # %bb.0:
187; X64-OPT-NEXT:    leaq (,%rdi,8), %rax
188; X64-OPT-NEXT:    subq %rdi, %rax
189; X64-OPT-NEXT:    retq
190;
191; X64-NOOPT-LABEL: test_mul_by_7:
192; X64-NOOPT:       # %bb.0:
193; X64-NOOPT-NEXT:    imulq $7, %rdi, %rax
194; X64-NOOPT-NEXT:    retq
195  %mul = mul nsw i64 %x, 7
196  ret i64 %mul
197}
198
199define i64 @test_mul_by_8(i64 %x) {
200; X86-LABEL: test_mul_by_8:
201; X86:       # %bb.0:
202; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
203; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
204; X86-NEXT:    shldl $3, %eax, %edx
205; X86-NEXT:    shll $3, %eax
206; X86-NEXT:    retl
207;
208; X86-NOOPT-LABEL: test_mul_by_8:
209; X86-NOOPT:       # %bb.0:
210; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %eax
211; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %edx
212; X86-NOOPT-NEXT:    shldl $3, %eax, %edx
213; X86-NOOPT-NEXT:    shll $3, %eax
214; X86-NOOPT-NEXT:    retl
215;
216; X64-LABEL: test_mul_by_8:
217; X64:       # %bb.0:
218; X64-NEXT:    leaq (,%rdi,8), %rax
219; X64-NEXT:    retq
220  %mul = mul nsw i64 %x, 8
221  ret i64 %mul
222}
223
224define i64 @test_mul_by_9(i64 %x) {
225; X86-LABEL: test_mul_by_9:
226; X86:       # %bb.0:
227; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
228; X86-NEXT:    leal (%eax,%eax,8), %ecx
229; X86-NEXT:    movl $9, %eax
230; X86-NEXT:    mull {{[0-9]+}}(%esp)
231; X86-NEXT:    addl %ecx, %edx
232; X86-NEXT:    retl
233;
234; X86-NOOPT-LABEL: test_mul_by_9:
235; X86-NOOPT:       # %bb.0:
236; X86-NOOPT-NEXT:    movl $9, %eax
237; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
238; X86-NOOPT-NEXT:    imull $9, {{[0-9]+}}(%esp), %ecx
239; X86-NOOPT-NEXT:    addl %ecx, %edx
240; X86-NOOPT-NEXT:    retl
241;
242; X64-LABEL: test_mul_by_9:
243; X64:       # %bb.0:
244; X64-NEXT:    leaq (%rdi,%rdi,8), %rax
245; X64-NEXT:    retq
246  %mul = mul nsw i64 %x, 9
247  ret i64 %mul
248}
249
250define i64 @test_mul_by_10(i64 %x) {
251; X86-LABEL: test_mul_by_10:
252; X86:       # %bb.0:
253; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
254; X86-NEXT:    leal (%eax,%eax,4), %ecx
255; X86-NEXT:    movl $10, %eax
256; X86-NEXT:    mull {{[0-9]+}}(%esp)
257; X86-NEXT:    leal (%edx,%ecx,2), %edx
258; X86-NEXT:    retl
259;
260; X86-NOOPT-LABEL: test_mul_by_10:
261; X86-NOOPT:       # %bb.0:
262; X86-NOOPT-NEXT:    movl $10, %eax
263; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
264; X86-NOOPT-NEXT:    imull $10, {{[0-9]+}}(%esp), %ecx
265; X86-NOOPT-NEXT:    addl %ecx, %edx
266; X86-NOOPT-NEXT:    retl
267;
268; X64-OPT-LABEL: test_mul_by_10:
269; X64-OPT:       # %bb.0:
270; X64-OPT-NEXT:    addq %rdi, %rdi
271; X64-OPT-NEXT:    leaq (%rdi,%rdi,4), %rax
272; X64-OPT-NEXT:    retq
273;
274; X64-NOOPT-LABEL: test_mul_by_10:
275; X64-NOOPT:       # %bb.0:
276; X64-NOOPT-NEXT:    imulq $10, %rdi, %rax
277; X64-NOOPT-NEXT:    retq
278  %mul = mul nsw i64 %x, 10
279  ret i64 %mul
280}
281
282define i64 @test_mul_by_11(i64 %x) {
283; X86-LABEL: test_mul_by_11:
284; X86:       # %bb.0:
285; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
286; X86-NEXT:    leal (%eax,%eax,4), %ecx
287; X86-NEXT:    leal (%eax,%ecx,2), %ecx
288; X86-NEXT:    movl $11, %eax
289; X86-NEXT:    mull {{[0-9]+}}(%esp)
290; X86-NEXT:    addl %ecx, %edx
291; X86-NEXT:    retl
292;
293; X86-NOOPT-LABEL: test_mul_by_11:
294; X86-NOOPT:       # %bb.0:
295; X86-NOOPT-NEXT:    movl $11, %eax
296; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
297; X86-NOOPT-NEXT:    imull $11, {{[0-9]+}}(%esp), %ecx
298; X86-NOOPT-NEXT:    addl %ecx, %edx
299; X86-NOOPT-NEXT:    retl
300;
301; X64-HSW-LABEL: test_mul_by_11:
302; X64-HSW:       # %bb.0:
303; X64-HSW-NEXT:    leaq (%rdi,%rdi,4), %rax
304; X64-HSW-NEXT:    leaq (%rdi,%rax,2), %rax
305; X64-HSW-NEXT:    retq
306;
307; X64-JAG-LABEL: test_mul_by_11:
308; X64-JAG:       # %bb.0:
309; X64-JAG-NEXT:    leaq (%rdi,%rdi,4), %rax
310; X64-JAG-NEXT:    leaq (%rdi,%rax,2), %rax
311; X64-JAG-NEXT:    retq
312;
313; X64-SLM-LABEL: test_mul_by_11:
314; X64-SLM:       # %bb.0:
315; X64-SLM-NEXT:    imulq $11, %rdi, %rax
316; X64-SLM-NEXT:    retq
317;
318; X64-NOOPT-LABEL: test_mul_by_11:
319; X64-NOOPT:       # %bb.0:
320; X64-NOOPT-NEXT:    imulq $11, %rdi, %rax
321; X64-NOOPT-NEXT:    retq
322  %mul = mul nsw i64 %x, 11
323  ret i64 %mul
324}
325
326define i64 @test_mul_by_12(i64 %x) {
327; X86-LABEL: test_mul_by_12:
328; X86:       # %bb.0:
329; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
330; X86-NEXT:    leal (%eax,%eax,2), %ecx
331; X86-NEXT:    movl $12, %eax
332; X86-NEXT:    mull {{[0-9]+}}(%esp)
333; X86-NEXT:    leal (%edx,%ecx,4), %edx
334; X86-NEXT:    retl
335;
336; X86-NOOPT-LABEL: test_mul_by_12:
337; X86-NOOPT:       # %bb.0:
338; X86-NOOPT-NEXT:    movl $12, %eax
339; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
340; X86-NOOPT-NEXT:    imull $12, {{[0-9]+}}(%esp), %ecx
341; X86-NOOPT-NEXT:    addl %ecx, %edx
342; X86-NOOPT-NEXT:    retl
343;
344; X64-OPT-LABEL: test_mul_by_12:
345; X64-OPT:       # %bb.0:
346; X64-OPT-NEXT:    shlq $2, %rdi
347; X64-OPT-NEXT:    leaq (%rdi,%rdi,2), %rax
348; X64-OPT-NEXT:    retq
349;
350; X64-NOOPT-LABEL: test_mul_by_12:
351; X64-NOOPT:       # %bb.0:
352; X64-NOOPT-NEXT:    imulq $12, %rdi, %rax
353; X64-NOOPT-NEXT:    retq
354  %mul = mul nsw i64 %x, 12
355  ret i64 %mul
356}
357
358define i64 @test_mul_by_13(i64 %x) {
359; X86-LABEL: test_mul_by_13:
360; X86:       # %bb.0:
361; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
362; X86-NEXT:    leal (%eax,%eax,2), %ecx
363; X86-NEXT:    leal (%eax,%ecx,4), %ecx
364; X86-NEXT:    movl $13, %eax
365; X86-NEXT:    mull {{[0-9]+}}(%esp)
366; X86-NEXT:    addl %ecx, %edx
367; X86-NEXT:    retl
368;
369; X86-NOOPT-LABEL: test_mul_by_13:
370; X86-NOOPT:       # %bb.0:
371; X86-NOOPT-NEXT:    movl $13, %eax
372; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
373; X86-NOOPT-NEXT:    imull $13, {{[0-9]+}}(%esp), %ecx
374; X86-NOOPT-NEXT:    addl %ecx, %edx
375; X86-NOOPT-NEXT:    retl
376;
377; X64-HSW-LABEL: test_mul_by_13:
378; X64-HSW:       # %bb.0:
379; X64-HSW-NEXT:    leaq (%rdi,%rdi,2), %rax
380; X64-HSW-NEXT:    leaq (%rdi,%rax,4), %rax
381; X64-HSW-NEXT:    retq
382;
383; X64-JAG-LABEL: test_mul_by_13:
384; X64-JAG:       # %bb.0:
385; X64-JAG-NEXT:    leaq (%rdi,%rdi,2), %rax
386; X64-JAG-NEXT:    leaq (%rdi,%rax,4), %rax
387; X64-JAG-NEXT:    retq
388;
389; X64-SLM-LABEL: test_mul_by_13:
390; X64-SLM:       # %bb.0:
391; X64-SLM-NEXT:    imulq $13, %rdi, %rax
392; X64-SLM-NEXT:    retq
393;
394; X64-NOOPT-LABEL: test_mul_by_13:
395; X64-NOOPT:       # %bb.0:
396; X64-NOOPT-NEXT:    imulq $13, %rdi, %rax
397; X64-NOOPT-NEXT:    retq
398  %mul = mul nsw i64 %x, 13
399  ret i64 %mul
400}
401
402define i64 @test_mul_by_14(i64 %x) {
403; X86-LABEL: test_mul_by_14:
404; X86:       # %bb.0:
405; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
406; X86-NEXT:    movl %eax, %ecx
407; X86-NEXT:    shll $4, %ecx
408; X86-NEXT:    subl %eax, %ecx
409; X86-NEXT:    subl %eax, %ecx
410; X86-NEXT:    movl $14, %eax
411; X86-NEXT:    mull {{[0-9]+}}(%esp)
412; X86-NEXT:    addl %ecx, %edx
413; X86-NEXT:    retl
414;
415; X86-NOOPT-LABEL: test_mul_by_14:
416; X86-NOOPT:       # %bb.0:
417; X86-NOOPT-NEXT:    movl $14, %eax
418; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
419; X86-NOOPT-NEXT:    imull $14, {{[0-9]+}}(%esp), %ecx
420; X86-NOOPT-NEXT:    addl %ecx, %edx
421; X86-NOOPT-NEXT:    retl
422;
423; X64-OPT-LABEL: test_mul_by_14:
424; X64-OPT:       # %bb.0:
425; X64-OPT-NEXT:    movq %rdi, %rax
426; X64-OPT-NEXT:    shlq $4, %rax
427; X64-OPT-NEXT:    subq %rdi, %rax
428; X64-OPT-NEXT:    subq %rdi, %rax
429; X64-OPT-NEXT:    retq
430;
431; X64-NOOPT-LABEL: test_mul_by_14:
432; X64-NOOPT:       # %bb.0:
433; X64-NOOPT-NEXT:    imulq $14, %rdi, %rax
434; X64-NOOPT-NEXT:    retq
435  %mul = mul nsw i64 %x, 14
436  ret i64 %mul
437}
438
439define i64 @test_mul_by_15(i64 %x) {
440; X86-LABEL: test_mul_by_15:
441; X86:       # %bb.0:
442; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
443; X86-NEXT:    movl $15, %eax
444; X86-NEXT:    mull {{[0-9]+}}(%esp)
445; X86-NEXT:    leal (%ecx,%ecx,4), %ecx
446; X86-NEXT:    leal (%ecx,%ecx,2), %ecx
447; X86-NEXT:    addl %ecx, %edx
448; X86-NEXT:    retl
449;
450; X86-NOOPT-LABEL: test_mul_by_15:
451; X86-NOOPT:       # %bb.0:
452; X86-NOOPT-NEXT:    movl $15, %eax
453; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
454; X86-NOOPT-NEXT:    imull $15, {{[0-9]+}}(%esp), %ecx
455; X86-NOOPT-NEXT:    addl %ecx, %edx
456; X86-NOOPT-NEXT:    retl
457;
458; X64-OPT-LABEL: test_mul_by_15:
459; X64-OPT:       # %bb.0:
460; X64-OPT-NEXT:    leaq (%rdi,%rdi,4), %rax
461; X64-OPT-NEXT:    leaq (%rax,%rax,2), %rax
462; X64-OPT-NEXT:    retq
463;
464; X64-NOOPT-LABEL: test_mul_by_15:
465; X64-NOOPT:       # %bb.0:
466; X64-NOOPT-NEXT:    imulq $15, %rdi, %rax
467; X64-NOOPT-NEXT:    retq
468  %mul = mul nsw i64 %x, 15
469  ret i64 %mul
470}
471
472define i64 @test_mul_by_16(i64 %x) {
473; X86-LABEL: test_mul_by_16:
474; X86:       # %bb.0:
475; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
476; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
477; X86-NEXT:    shldl $4, %eax, %edx
478; X86-NEXT:    shll $4, %eax
479; X86-NEXT:    retl
480;
481; X86-NOOPT-LABEL: test_mul_by_16:
482; X86-NOOPT:       # %bb.0:
483; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %eax
484; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %edx
485; X86-NOOPT-NEXT:    shldl $4, %eax, %edx
486; X86-NOOPT-NEXT:    shll $4, %eax
487; X86-NOOPT-NEXT:    retl
488;
489; X64-LABEL: test_mul_by_16:
490; X64:       # %bb.0:
491; X64-NEXT:    movq %rdi, %rax
492; X64-NEXT:    shlq $4, %rax
493; X64-NEXT:    retq
494  %mul = mul nsw i64 %x, 16
495  ret i64 %mul
496}
497
498define i64 @test_mul_by_17(i64 %x) {
499; X86-LABEL: test_mul_by_17:
500; X86:       # %bb.0:
501; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
502; X86-NEXT:    movl %eax, %ecx
503; X86-NEXT:    shll $4, %ecx
504; X86-NEXT:    addl %eax, %ecx
505; X86-NEXT:    movl $17, %eax
506; X86-NEXT:    mull {{[0-9]+}}(%esp)
507; X86-NEXT:    addl %ecx, %edx
508; X86-NEXT:    retl
509;
510; X86-NOOPT-LABEL: test_mul_by_17:
511; X86-NOOPT:       # %bb.0:
512; X86-NOOPT-NEXT:    movl $17, %eax
513; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
514; X86-NOOPT-NEXT:    imull $17, {{[0-9]+}}(%esp), %ecx
515; X86-NOOPT-NEXT:    addl %ecx, %edx
516; X86-NOOPT-NEXT:    retl
517;
518; X64-OPT-LABEL: test_mul_by_17:
519; X64-OPT:       # %bb.0:
520; X64-OPT-NEXT:    movq %rdi, %rax
521; X64-OPT-NEXT:    shlq $4, %rax
522; X64-OPT-NEXT:    addq %rdi, %rax
523; X64-OPT-NEXT:    retq
524;
525; X64-NOOPT-LABEL: test_mul_by_17:
526; X64-NOOPT:       # %bb.0:
527; X64-NOOPT-NEXT:    imulq $17, %rdi, %rax
528; X64-NOOPT-NEXT:    retq
529  %mul = mul nsw i64 %x, 17
530  ret i64 %mul
531}
532
533define i64 @test_mul_by_18(i64 %x) {
534; X86-LABEL: test_mul_by_18:
535; X86:       # %bb.0:
536; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
537; X86-NEXT:    leal (%eax,%eax,8), %ecx
538; X86-NEXT:    movl $18, %eax
539; X86-NEXT:    mull {{[0-9]+}}(%esp)
540; X86-NEXT:    leal (%edx,%ecx,2), %edx
541; X86-NEXT:    retl
542;
543; X86-NOOPT-LABEL: test_mul_by_18:
544; X86-NOOPT:       # %bb.0:
545; X86-NOOPT-NEXT:    movl $18, %eax
546; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
547; X86-NOOPT-NEXT:    imull $18, {{[0-9]+}}(%esp), %ecx
548; X86-NOOPT-NEXT:    addl %ecx, %edx
549; X86-NOOPT-NEXT:    retl
550;
551; X64-OPT-LABEL: test_mul_by_18:
552; X64-OPT:       # %bb.0:
553; X64-OPT-NEXT:    addq %rdi, %rdi
554; X64-OPT-NEXT:    leaq (%rdi,%rdi,8), %rax
555; X64-OPT-NEXT:    retq
556;
557; X64-NOOPT-LABEL: test_mul_by_18:
558; X64-NOOPT:       # %bb.0:
559; X64-NOOPT-NEXT:    imulq $18, %rdi, %rax
560; X64-NOOPT-NEXT:    retq
561  %mul = mul nsw i64 %x, 18
562  ret i64 %mul
563}
564
565define i64 @test_mul_by_19(i64 %x) {
566; X86-LABEL: test_mul_by_19:
567; X86:       # %bb.0:
568; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
569; X86-NEXT:    leal (%eax,%eax,8), %ecx
570; X86-NEXT:    leal (%eax,%ecx,2), %ecx
571; X86-NEXT:    movl $19, %eax
572; X86-NEXT:    mull {{[0-9]+}}(%esp)
573; X86-NEXT:    addl %ecx, %edx
574; X86-NEXT:    retl
575;
576; X86-NOOPT-LABEL: test_mul_by_19:
577; X86-NOOPT:       # %bb.0:
578; X86-NOOPT-NEXT:    movl $19, %eax
579; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
580; X86-NOOPT-NEXT:    imull $19, {{[0-9]+}}(%esp), %ecx
581; X86-NOOPT-NEXT:    addl %ecx, %edx
582; X86-NOOPT-NEXT:    retl
583;
584; X64-HSW-LABEL: test_mul_by_19:
585; X64-HSW:       # %bb.0:
586; X64-HSW-NEXT:    leaq (%rdi,%rdi,8), %rax
587; X64-HSW-NEXT:    leaq (%rdi,%rax,2), %rax
588; X64-HSW-NEXT:    retq
589;
590; X64-JAG-LABEL: test_mul_by_19:
591; X64-JAG:       # %bb.0:
592; X64-JAG-NEXT:    leaq (%rdi,%rdi,8), %rax
593; X64-JAG-NEXT:    leaq (%rdi,%rax,2), %rax
594; X64-JAG-NEXT:    retq
595;
596; X64-SLM-LABEL: test_mul_by_19:
597; X64-SLM:       # %bb.0:
598; X64-SLM-NEXT:    imulq $19, %rdi, %rax
599; X64-SLM-NEXT:    retq
600;
601; X64-NOOPT-LABEL: test_mul_by_19:
602; X64-NOOPT:       # %bb.0:
603; X64-NOOPT-NEXT:    imulq $19, %rdi, %rax
604; X64-NOOPT-NEXT:    retq
605  %mul = mul nsw i64 %x, 19
606  ret i64 %mul
607}
608
609define i64 @test_mul_by_20(i64 %x) {
610; X86-LABEL: test_mul_by_20:
611; X86:       # %bb.0:
612; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
613; X86-NEXT:    leal (%eax,%eax,4), %ecx
614; X86-NEXT:    movl $20, %eax
615; X86-NEXT:    mull {{[0-9]+}}(%esp)
616; X86-NEXT:    leal (%edx,%ecx,4), %edx
617; X86-NEXT:    retl
618;
619; X86-NOOPT-LABEL: test_mul_by_20:
620; X86-NOOPT:       # %bb.0:
621; X86-NOOPT-NEXT:    movl $20, %eax
622; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
623; X86-NOOPT-NEXT:    imull $20, {{[0-9]+}}(%esp), %ecx
624; X86-NOOPT-NEXT:    addl %ecx, %edx
625; X86-NOOPT-NEXT:    retl
626;
627; X64-OPT-LABEL: test_mul_by_20:
628; X64-OPT:       # %bb.0:
629; X64-OPT-NEXT:    shlq $2, %rdi
630; X64-OPT-NEXT:    leaq (%rdi,%rdi,4), %rax
631; X64-OPT-NEXT:    retq
632;
633; X64-NOOPT-LABEL: test_mul_by_20:
634; X64-NOOPT:       # %bb.0:
635; X64-NOOPT-NEXT:    imulq $20, %rdi, %rax
636; X64-NOOPT-NEXT:    retq
637  %mul = mul nsw i64 %x, 20
638  ret i64 %mul
639}
640
641define i64 @test_mul_by_21(i64 %x) {
642; X86-LABEL: test_mul_by_21:
643; X86:       # %bb.0:
644; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
645; X86-NEXT:    leal (%eax,%eax,4), %ecx
646; X86-NEXT:    leal (%eax,%ecx,4), %ecx
647; X86-NEXT:    movl $21, %eax
648; X86-NEXT:    mull {{[0-9]+}}(%esp)
649; X86-NEXT:    addl %ecx, %edx
650; X86-NEXT:    retl
651;
652; X86-NOOPT-LABEL: test_mul_by_21:
653; X86-NOOPT:       # %bb.0:
654; X86-NOOPT-NEXT:    movl $21, %eax
655; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
656; X86-NOOPT-NEXT:    imull $21, {{[0-9]+}}(%esp), %ecx
657; X86-NOOPT-NEXT:    addl %ecx, %edx
658; X86-NOOPT-NEXT:    retl
659;
660; X64-HSW-LABEL: test_mul_by_21:
661; X64-HSW:       # %bb.0:
662; X64-HSW-NEXT:    leaq (%rdi,%rdi,4), %rax
663; X64-HSW-NEXT:    leaq (%rdi,%rax,4), %rax
664; X64-HSW-NEXT:    retq
665;
666; X64-JAG-LABEL: test_mul_by_21:
667; X64-JAG:       # %bb.0:
668; X64-JAG-NEXT:    leaq (%rdi,%rdi,4), %rax
669; X64-JAG-NEXT:    leaq (%rdi,%rax,4), %rax
670; X64-JAG-NEXT:    retq
671;
672; X64-SLM-LABEL: test_mul_by_21:
673; X64-SLM:       # %bb.0:
674; X64-SLM-NEXT:    imulq $21, %rdi, %rax
675; X64-SLM-NEXT:    retq
676;
677; X64-NOOPT-LABEL: test_mul_by_21:
678; X64-NOOPT:       # %bb.0:
679; X64-NOOPT-NEXT:    imulq $21, %rdi, %rax
680; X64-NOOPT-NEXT:    retq
681  %mul = mul nsw i64 %x, 21
682  ret i64 %mul
683}
684
685define i64 @test_mul_by_22(i64 %x) {
686; X86-LABEL: test_mul_by_22:
687; X86:       # %bb.0:
688; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
689; X86-NEXT:    leal (%eax,%eax,4), %ecx
690; X86-NEXT:    leal (%eax,%ecx,4), %ecx
691; X86-NEXT:    addl %eax, %ecx
692; X86-NEXT:    movl $22, %eax
693; X86-NEXT:    mull {{[0-9]+}}(%esp)
694; X86-NEXT:    addl %ecx, %edx
695; X86-NEXT:    retl
696;
697; X86-NOOPT-LABEL: test_mul_by_22:
698; X86-NOOPT:       # %bb.0:
699; X86-NOOPT-NEXT:    movl $22, %eax
700; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
701; X86-NOOPT-NEXT:    imull $22, {{[0-9]+}}(%esp), %ecx
702; X86-NOOPT-NEXT:    addl %ecx, %edx
703; X86-NOOPT-NEXT:    retl
704;
705; X64-HSW-LABEL: test_mul_by_22:
706; X64-HSW:       # %bb.0:
707; X64-HSW-NEXT:    leaq (%rdi,%rdi,4), %rax
708; X64-HSW-NEXT:    leaq (%rdi,%rax,4), %rax
709; X64-HSW-NEXT:    addq %rdi, %rax
710; X64-HSW-NEXT:    retq
711;
712; X64-JAG-LABEL: test_mul_by_22:
713; X64-JAG:       # %bb.0:
714; X64-JAG-NEXT:    leaq (%rdi,%rdi,4), %rax
715; X64-JAG-NEXT:    leaq (%rdi,%rax,4), %rax
716; X64-JAG-NEXT:    addq %rdi, %rax
717; X64-JAG-NEXT:    retq
718;
719; X64-SLM-LABEL: test_mul_by_22:
720; X64-SLM:       # %bb.0:
721; X64-SLM-NEXT:    imulq $22, %rdi, %rax
722; X64-SLM-NEXT:    retq
723;
724; X64-NOOPT-LABEL: test_mul_by_22:
725; X64-NOOPT:       # %bb.0:
726; X64-NOOPT-NEXT:    imulq $22, %rdi, %rax
727; X64-NOOPT-NEXT:    retq
728  %mul = mul nsw i64 %x, 22
729  ret i64 %mul
730}
731
732define i64 @test_mul_by_23(i64 %x) {
733; X86-LABEL: test_mul_by_23:
734; X86:       # %bb.0:
735; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
736; X86-NEXT:    leal (%eax,%eax,2), %ecx
737; X86-NEXT:    shll $3, %ecx
738; X86-NEXT:    subl %eax, %ecx
739; X86-NEXT:    movl $23, %eax
740; X86-NEXT:    mull {{[0-9]+}}(%esp)
741; X86-NEXT:    addl %ecx, %edx
742; X86-NEXT:    retl
743;
744; X86-NOOPT-LABEL: test_mul_by_23:
745; X86-NOOPT:       # %bb.0:
746; X86-NOOPT-NEXT:    movl $23, %eax
747; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
748; X86-NOOPT-NEXT:    imull $23, {{[0-9]+}}(%esp), %ecx
749; X86-NOOPT-NEXT:    addl %ecx, %edx
750; X86-NOOPT-NEXT:    retl
751;
752; X64-HSW-LABEL: test_mul_by_23:
753; X64-HSW:       # %bb.0:
754; X64-HSW-NEXT:    leaq (%rdi,%rdi,2), %rax
755; X64-HSW-NEXT:    shlq $3, %rax
756; X64-HSW-NEXT:    subq %rdi, %rax
757; X64-HSW-NEXT:    retq
758;
759; X64-JAG-LABEL: test_mul_by_23:
760; X64-JAG:       # %bb.0:
761; X64-JAG-NEXT:    leaq (%rdi,%rdi,2), %rax
762; X64-JAG-NEXT:    shlq $3, %rax
763; X64-JAG-NEXT:    subq %rdi, %rax
764; X64-JAG-NEXT:    retq
765;
766; X64-SLM-LABEL: test_mul_by_23:
767; X64-SLM:       # %bb.0:
768; X64-SLM-NEXT:    imulq $23, %rdi, %rax
769; X64-SLM-NEXT:    retq
770;
771; X64-NOOPT-LABEL: test_mul_by_23:
772; X64-NOOPT:       # %bb.0:
773; X64-NOOPT-NEXT:    imulq $23, %rdi, %rax
774; X64-NOOPT-NEXT:    retq
775  %mul = mul nsw i64 %x, 23
776  ret i64 %mul
777}
778
779define i64 @test_mul_by_24(i64 %x) {
780; X86-LABEL: test_mul_by_24:
781; X86:       # %bb.0:
782; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
783; X86-NEXT:    leal (%eax,%eax,2), %ecx
784; X86-NEXT:    movl $24, %eax
785; X86-NEXT:    mull {{[0-9]+}}(%esp)
786; X86-NEXT:    leal (%edx,%ecx,8), %edx
787; X86-NEXT:    retl
788;
789; X86-NOOPT-LABEL: test_mul_by_24:
790; X86-NOOPT:       # %bb.0:
791; X86-NOOPT-NEXT:    movl $24, %eax
792; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
793; X86-NOOPT-NEXT:    imull $24, {{[0-9]+}}(%esp), %ecx
794; X86-NOOPT-NEXT:    addl %ecx, %edx
795; X86-NOOPT-NEXT:    retl
796;
797; X64-OPT-LABEL: test_mul_by_24:
798; X64-OPT:       # %bb.0:
799; X64-OPT-NEXT:    shlq $3, %rdi
800; X64-OPT-NEXT:    leaq (%rdi,%rdi,2), %rax
801; X64-OPT-NEXT:    retq
802;
803; X64-NOOPT-LABEL: test_mul_by_24:
804; X64-NOOPT:       # %bb.0:
805; X64-NOOPT-NEXT:    imulq $24, %rdi, %rax
806; X64-NOOPT-NEXT:    retq
807  %mul = mul nsw i64 %x, 24
808  ret i64 %mul
809}
810
811define i64 @test_mul_by_25(i64 %x) {
812; X86-LABEL: test_mul_by_25:
813; X86:       # %bb.0:
814; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
815; X86-NEXT:    movl $25, %eax
816; X86-NEXT:    mull {{[0-9]+}}(%esp)
817; X86-NEXT:    leal (%ecx,%ecx,4), %ecx
818; X86-NEXT:    leal (%ecx,%ecx,4), %ecx
819; X86-NEXT:    addl %ecx, %edx
820; X86-NEXT:    retl
821;
822; X86-NOOPT-LABEL: test_mul_by_25:
823; X86-NOOPT:       # %bb.0:
824; X86-NOOPT-NEXT:    movl $25, %eax
825; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
826; X86-NOOPT-NEXT:    imull $25, {{[0-9]+}}(%esp), %ecx
827; X86-NOOPT-NEXT:    addl %ecx, %edx
828; X86-NOOPT-NEXT:    retl
829;
830; X64-OPT-LABEL: test_mul_by_25:
831; X64-OPT:       # %bb.0:
832; X64-OPT-NEXT:    leaq (%rdi,%rdi,4), %rax
833; X64-OPT-NEXT:    leaq (%rax,%rax,4), %rax
834; X64-OPT-NEXT:    retq
835;
836; X64-NOOPT-LABEL: test_mul_by_25:
837; X64-NOOPT:       # %bb.0:
838; X64-NOOPT-NEXT:    imulq $25, %rdi, %rax
839; X64-NOOPT-NEXT:    retq
840  %mul = mul nsw i64 %x, 25
841  ret i64 %mul
842}
843
844define i64 @test_mul_by_26(i64 %x) {
845; X86-LABEL: test_mul_by_26:
846; X86:       # %bb.0:
847; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
848; X86-NEXT:    leal (%eax,%eax,4), %ecx
849; X86-NEXT:    leal (%ecx,%ecx,4), %ecx
850; X86-NEXT:    addl %eax, %ecx
851; X86-NEXT:    movl $26, %eax
852; X86-NEXT:    mull {{[0-9]+}}(%esp)
853; X86-NEXT:    addl %ecx, %edx
854; X86-NEXT:    retl
855;
856; X86-NOOPT-LABEL: test_mul_by_26:
857; X86-NOOPT:       # %bb.0:
858; X86-NOOPT-NEXT:    movl $26, %eax
859; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
860; X86-NOOPT-NEXT:    imull $26, {{[0-9]+}}(%esp), %ecx
861; X86-NOOPT-NEXT:    addl %ecx, %edx
862; X86-NOOPT-NEXT:    retl
863;
864; X64-HSW-LABEL: test_mul_by_26:
865; X64-HSW:       # %bb.0:
866; X64-HSW-NEXT:    leaq (%rdi,%rdi,4), %rax
867; X64-HSW-NEXT:    leaq (%rax,%rax,4), %rax
868; X64-HSW-NEXT:    addq %rdi, %rax
869; X64-HSW-NEXT:    retq
870;
871; X64-JAG-LABEL: test_mul_by_26:
872; X64-JAG:       # %bb.0:
873; X64-JAG-NEXT:    leaq (%rdi,%rdi,4), %rax
874; X64-JAG-NEXT:    leaq (%rax,%rax,4), %rax
875; X64-JAG-NEXT:    addq %rdi, %rax
876; X64-JAG-NEXT:    retq
877;
878; X64-SLM-LABEL: test_mul_by_26:
879; X64-SLM:       # %bb.0:
880; X64-SLM-NEXT:    imulq $26, %rdi, %rax
881; X64-SLM-NEXT:    retq
882;
883; X64-NOOPT-LABEL: test_mul_by_26:
884; X64-NOOPT:       # %bb.0:
885; X64-NOOPT-NEXT:    imulq $26, %rdi, %rax
886; X64-NOOPT-NEXT:    retq
887  %mul = mul nsw i64 %x, 26
888  ret i64 %mul
889}
890
891define i64 @test_mul_by_27(i64 %x) {
892; X86-LABEL: test_mul_by_27:
893; X86:       # %bb.0:
894; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
895; X86-NEXT:    movl $27, %eax
896; X86-NEXT:    mull {{[0-9]+}}(%esp)
897; X86-NEXT:    leal (%ecx,%ecx,8), %ecx
898; X86-NEXT:    leal (%ecx,%ecx,2), %ecx
899; X86-NEXT:    addl %ecx, %edx
900; X86-NEXT:    retl
901;
902; X86-NOOPT-LABEL: test_mul_by_27:
903; X86-NOOPT:       # %bb.0:
904; X86-NOOPT-NEXT:    movl $27, %eax
905; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
906; X86-NOOPT-NEXT:    imull $27, {{[0-9]+}}(%esp), %ecx
907; X86-NOOPT-NEXT:    addl %ecx, %edx
908; X86-NOOPT-NEXT:    retl
909;
910; X64-OPT-LABEL: test_mul_by_27:
911; X64-OPT:       # %bb.0:
912; X64-OPT-NEXT:    leaq (%rdi,%rdi,8), %rax
913; X64-OPT-NEXT:    leaq (%rax,%rax,2), %rax
914; X64-OPT-NEXT:    retq
915;
916; X64-NOOPT-LABEL: test_mul_by_27:
917; X64-NOOPT:       # %bb.0:
918; X64-NOOPT-NEXT:    imulq $27, %rdi, %rax
919; X64-NOOPT-NEXT:    retq
920  %mul = mul nsw i64 %x, 27
921  ret i64 %mul
922}
923
924define i64 @test_mul_by_28(i64 %x) {
925; X86-LABEL: test_mul_by_28:
926; X86:       # %bb.0:
927; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
928; X86-NEXT:    leal (%eax,%eax,8), %ecx
929; X86-NEXT:    leal (%ecx,%ecx,2), %ecx
930; X86-NEXT:    addl %eax, %ecx
931; X86-NEXT:    movl $28, %eax
932; X86-NEXT:    mull {{[0-9]+}}(%esp)
933; X86-NEXT:    addl %ecx, %edx
934; X86-NEXT:    retl
935;
936; X86-NOOPT-LABEL: test_mul_by_28:
937; X86-NOOPT:       # %bb.0:
938; X86-NOOPT-NEXT:    movl $28, %eax
939; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
940; X86-NOOPT-NEXT:    imull $28, {{[0-9]+}}(%esp), %ecx
941; X86-NOOPT-NEXT:    addl %ecx, %edx
942; X86-NOOPT-NEXT:    retl
943;
944; X64-HSW-LABEL: test_mul_by_28:
945; X64-HSW:       # %bb.0:
946; X64-HSW-NEXT:    leaq (%rdi,%rdi,8), %rax
947; X64-HSW-NEXT:    leaq (%rax,%rax,2), %rax
948; X64-HSW-NEXT:    addq %rdi, %rax
949; X64-HSW-NEXT:    retq
950;
951; X64-JAG-LABEL: test_mul_by_28:
952; X64-JAG:       # %bb.0:
953; X64-JAG-NEXT:    leaq (%rdi,%rdi,8), %rax
954; X64-JAG-NEXT:    leaq (%rax,%rax,2), %rax
955; X64-JAG-NEXT:    addq %rdi, %rax
956; X64-JAG-NEXT:    retq
957;
958; X64-SLM-LABEL: test_mul_by_28:
959; X64-SLM:       # %bb.0:
960; X64-SLM-NEXT:    imulq $28, %rdi, %rax
961; X64-SLM-NEXT:    retq
962;
963; X64-NOOPT-LABEL: test_mul_by_28:
964; X64-NOOPT:       # %bb.0:
965; X64-NOOPT-NEXT:    imulq $28, %rdi, %rax
966; X64-NOOPT-NEXT:    retq
967  %mul = mul nsw i64 %x, 28
968  ret i64 %mul
969}
970
971define i64 @test_mul_by_29(i64 %x) {
972; X86-LABEL: test_mul_by_29:
973; X86:       # %bb.0:
974; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
975; X86-NEXT:    leal (%eax,%eax,8), %ecx
976; X86-NEXT:    leal (%ecx,%ecx,2), %ecx
977; X86-NEXT:    addl %eax, %ecx
978; X86-NEXT:    addl %eax, %ecx
979; X86-NEXT:    movl $29, %eax
980; X86-NEXT:    mull {{[0-9]+}}(%esp)
981; X86-NEXT:    addl %ecx, %edx
982; X86-NEXT:    retl
983;
984; X86-NOOPT-LABEL: test_mul_by_29:
985; X86-NOOPT:       # %bb.0:
986; X86-NOOPT-NEXT:    movl $29, %eax
987; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
988; X86-NOOPT-NEXT:    imull $29, {{[0-9]+}}(%esp), %ecx
989; X86-NOOPT-NEXT:    addl %ecx, %edx
990; X86-NOOPT-NEXT:    retl
991;
992; X64-HSW-LABEL: test_mul_by_29:
993; X64-HSW:       # %bb.0:
994; X64-HSW-NEXT:    leaq (%rdi,%rdi,8), %rax
995; X64-HSW-NEXT:    leaq (%rax,%rax,2), %rax
996; X64-HSW-NEXT:    addq %rdi, %rax
997; X64-HSW-NEXT:    addq %rdi, %rax
998; X64-HSW-NEXT:    retq
999;
1000; X64-JAG-LABEL: test_mul_by_29:
1001; X64-JAG:       # %bb.0:
1002; X64-JAG-NEXT:    leaq (%rdi,%rdi,8), %rax
1003; X64-JAG-NEXT:    leaq (%rax,%rax,2), %rax
1004; X64-JAG-NEXT:    addq %rdi, %rax
1005; X64-JAG-NEXT:    addq %rdi, %rax
1006; X64-JAG-NEXT:    retq
1007;
1008; X64-SLM-LABEL: test_mul_by_29:
1009; X64-SLM:       # %bb.0:
1010; X64-SLM-NEXT:    imulq $29, %rdi, %rax
1011; X64-SLM-NEXT:    retq
1012;
1013; X64-NOOPT-LABEL: test_mul_by_29:
1014; X64-NOOPT:       # %bb.0:
1015; X64-NOOPT-NEXT:    imulq $29, %rdi, %rax
1016; X64-NOOPT-NEXT:    retq
1017  %mul = mul nsw i64 %x, 29
1018  ret i64 %mul
1019}
1020
1021define i64 @test_mul_by_30(i64 %x) {
1022; X86-LABEL: test_mul_by_30:
1023; X86:       # %bb.0:
1024; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
1025; X86-NEXT:    movl %eax, %ecx
1026; X86-NEXT:    shll $5, %ecx
1027; X86-NEXT:    subl %eax, %ecx
1028; X86-NEXT:    subl %eax, %ecx
1029; X86-NEXT:    movl $30, %eax
1030; X86-NEXT:    mull {{[0-9]+}}(%esp)
1031; X86-NEXT:    addl %ecx, %edx
1032; X86-NEXT:    retl
1033;
1034; X86-NOOPT-LABEL: test_mul_by_30:
1035; X86-NOOPT:       # %bb.0:
1036; X86-NOOPT-NEXT:    movl $30, %eax
1037; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
1038; X86-NOOPT-NEXT:    imull $30, {{[0-9]+}}(%esp), %ecx
1039; X86-NOOPT-NEXT:    addl %ecx, %edx
1040; X86-NOOPT-NEXT:    retl
1041;
1042; X64-OPT-LABEL: test_mul_by_30:
1043; X64-OPT:       # %bb.0:
1044; X64-OPT-NEXT:    movq %rdi, %rax
1045; X64-OPT-NEXT:    shlq $5, %rax
1046; X64-OPT-NEXT:    subq %rdi, %rax
1047; X64-OPT-NEXT:    subq %rdi, %rax
1048; X64-OPT-NEXT:    retq
1049;
1050; X64-NOOPT-LABEL: test_mul_by_30:
1051; X64-NOOPT:       # %bb.0:
1052; X64-NOOPT-NEXT:    imulq $30, %rdi, %rax
1053; X64-NOOPT-NEXT:    retq
1054  %mul = mul nsw i64 %x, 30
1055  ret i64 %mul
1056}
1057
1058define i64 @test_mul_by_31(i64 %x) {
1059; X86-LABEL: test_mul_by_31:
1060; X86:       # %bb.0:
1061; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
1062; X86-NEXT:    movl %eax, %ecx
1063; X86-NEXT:    shll $5, %ecx
1064; X86-NEXT:    subl %eax, %ecx
1065; X86-NEXT:    movl $31, %eax
1066; X86-NEXT:    mull {{[0-9]+}}(%esp)
1067; X86-NEXT:    addl %ecx, %edx
1068; X86-NEXT:    retl
1069;
1070; X86-NOOPT-LABEL: test_mul_by_31:
1071; X86-NOOPT:       # %bb.0:
1072; X86-NOOPT-NEXT:    movl $31, %eax
1073; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
1074; X86-NOOPT-NEXT:    imull $31, {{[0-9]+}}(%esp), %ecx
1075; X86-NOOPT-NEXT:    addl %ecx, %edx
1076; X86-NOOPT-NEXT:    retl
1077;
1078; X64-OPT-LABEL: test_mul_by_31:
1079; X64-OPT:       # %bb.0:
1080; X64-OPT-NEXT:    movq %rdi, %rax
1081; X64-OPT-NEXT:    shlq $5, %rax
1082; X64-OPT-NEXT:    subq %rdi, %rax
1083; X64-OPT-NEXT:    retq
1084;
1085; X64-NOOPT-LABEL: test_mul_by_31:
1086; X64-NOOPT:       # %bb.0:
1087; X64-NOOPT-NEXT:    imulq $31, %rdi, %rax
1088; X64-NOOPT-NEXT:    retq
1089  %mul = mul nsw i64 %x, 31
1090  ret i64 %mul
1091}
1092
1093define i64 @test_mul_by_32(i64 %x) {
1094; X86-LABEL: test_mul_by_32:
1095; X86:       # %bb.0:
1096; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
1097; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
1098; X86-NEXT:    shldl $5, %eax, %edx
1099; X86-NEXT:    shll $5, %eax
1100; X86-NEXT:    retl
1101;
1102; X86-NOOPT-LABEL: test_mul_by_32:
1103; X86-NOOPT:       # %bb.0:
1104; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %eax
1105; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %edx
1106; X86-NOOPT-NEXT:    shldl $5, %eax, %edx
1107; X86-NOOPT-NEXT:    shll $5, %eax
1108; X86-NOOPT-NEXT:    retl
1109;
1110; X64-LABEL: test_mul_by_32:
1111; X64:       # %bb.0:
1112; X64-NEXT:    movq %rdi, %rax
1113; X64-NEXT:    shlq $5, %rax
1114; X64-NEXT:    retq
1115  %mul = mul nsw i64 %x, 32
1116  ret i64 %mul
1117}
1118
1119define i64 @test_mul_by_37(i64 %x) {
1120; X86-LABEL: test_mul_by_37:
1121; X86:       # %bb.0:
1122; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
1123; X86-NEXT:    leal (%eax,%eax,8), %ecx
1124; X86-NEXT:    leal (%eax,%ecx,4), %ecx
1125; X86-NEXT:    movl $37, %eax
1126; X86-NEXT:    mull {{[0-9]+}}(%esp)
1127; X86-NEXT:    addl %ecx, %edx
1128; X86-NEXT:    retl
1129;
1130; X86-NOOPT-LABEL: test_mul_by_37:
1131; X86-NOOPT:       # %bb.0:
1132; X86-NOOPT-NEXT:    movl $37, %eax
1133; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
1134; X86-NOOPT-NEXT:    imull $37, {{[0-9]+}}(%esp), %ecx
1135; X86-NOOPT-NEXT:    addl %ecx, %edx
1136; X86-NOOPT-NEXT:    retl
1137;
1138; X64-HSW-LABEL: test_mul_by_37:
1139; X64-HSW:       # %bb.0:
1140; X64-HSW-NEXT:    leaq (%rdi,%rdi,8), %rax
1141; X64-HSW-NEXT:    leaq (%rdi,%rax,4), %rax
1142; X64-HSW-NEXT:    retq
1143;
1144; X64-JAG-LABEL: test_mul_by_37:
1145; X64-JAG:       # %bb.0:
1146; X64-JAG-NEXT:    leaq (%rdi,%rdi,8), %rax
1147; X64-JAG-NEXT:    leaq (%rdi,%rax,4), %rax
1148; X64-JAG-NEXT:    retq
1149;
1150; X64-SLM-LABEL: test_mul_by_37:
1151; X64-SLM:       # %bb.0:
1152; X64-SLM-NEXT:    imulq $37, %rdi, %rax
1153; X64-SLM-NEXT:    retq
1154;
1155; X64-NOOPT-LABEL: test_mul_by_37:
1156; X64-NOOPT:       # %bb.0:
1157; X64-NOOPT-NEXT:    imulq $37, %rdi, %rax
1158; X64-NOOPT-NEXT:    retq
1159  %mul = mul nsw i64 %x, 37
1160  ret i64 %mul
1161}
1162
1163define i64 @test_mul_by_41(i64 %x) {
1164; X86-LABEL: test_mul_by_41:
1165; X86:       # %bb.0:
1166; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
1167; X86-NEXT:    leal (%eax,%eax,4), %ecx
1168; X86-NEXT:    leal (%eax,%ecx,8), %ecx
1169; X86-NEXT:    movl $41, %eax
1170; X86-NEXT:    mull {{[0-9]+}}(%esp)
1171; X86-NEXT:    addl %ecx, %edx
1172; X86-NEXT:    retl
1173;
1174; X86-NOOPT-LABEL: test_mul_by_41:
1175; X86-NOOPT:       # %bb.0:
1176; X86-NOOPT-NEXT:    movl $41, %eax
1177; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
1178; X86-NOOPT-NEXT:    imull $41, {{[0-9]+}}(%esp), %ecx
1179; X86-NOOPT-NEXT:    addl %ecx, %edx
1180; X86-NOOPT-NEXT:    retl
1181;
1182; X64-HSW-LABEL: test_mul_by_41:
1183; X64-HSW:       # %bb.0:
1184; X64-HSW-NEXT:    leaq (%rdi,%rdi,4), %rax
1185; X64-HSW-NEXT:    leaq (%rdi,%rax,8), %rax
1186; X64-HSW-NEXT:    retq
1187;
1188; X64-JAG-LABEL: test_mul_by_41:
1189; X64-JAG:       # %bb.0:
1190; X64-JAG-NEXT:    leaq (%rdi,%rdi,4), %rax
1191; X64-JAG-NEXT:    leaq (%rdi,%rax,8), %rax
1192; X64-JAG-NEXT:    retq
1193;
1194; X64-SLM-LABEL: test_mul_by_41:
1195; X64-SLM:       # %bb.0:
1196; X64-SLM-NEXT:    imulq $41, %rdi, %rax
1197; X64-SLM-NEXT:    retq
1198;
1199; X64-NOOPT-LABEL: test_mul_by_41:
1200; X64-NOOPT:       # %bb.0:
1201; X64-NOOPT-NEXT:    imulq $41, %rdi, %rax
1202; X64-NOOPT-NEXT:    retq
1203  %mul = mul nsw i64 %x, 41
1204  ret i64 %mul
1205}
1206
1207define i64 @test_mul_by_62(i64 %x) {
1208; X86-LABEL: test_mul_by_62:
1209; X86:       # %bb.0:
1210; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
1211; X86-NEXT:    movl %eax, %ecx
1212; X86-NEXT:    shll $6, %ecx
1213; X86-NEXT:    subl %eax, %ecx
1214; X86-NEXT:    subl %eax, %ecx
1215; X86-NEXT:    movl $62, %eax
1216; X86-NEXT:    mull {{[0-9]+}}(%esp)
1217; X86-NEXT:    addl %ecx, %edx
1218; X86-NEXT:    retl
1219;
1220; X86-NOOPT-LABEL: test_mul_by_62:
1221; X86-NOOPT:       # %bb.0:
1222; X86-NOOPT-NEXT:    movl $62, %eax
1223; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
1224; X86-NOOPT-NEXT:    imull $62, {{[0-9]+}}(%esp), %ecx
1225; X86-NOOPT-NEXT:    addl %ecx, %edx
1226; X86-NOOPT-NEXT:    retl
1227;
1228; X64-OPT-LABEL: test_mul_by_62:
1229; X64-OPT:       # %bb.0:
1230; X64-OPT-NEXT:    movq %rdi, %rax
1231; X64-OPT-NEXT:    shlq $6, %rax
1232; X64-OPT-NEXT:    subq %rdi, %rax
1233; X64-OPT-NEXT:    subq %rdi, %rax
1234; X64-OPT-NEXT:    retq
1235;
1236; X64-NOOPT-LABEL: test_mul_by_62:
1237; X64-NOOPT:       # %bb.0:
1238; X64-NOOPT-NEXT:    imulq $62, %rdi, %rax
1239; X64-NOOPT-NEXT:    retq
1240  %mul = mul nsw i64 %x, 62
1241  ret i64 %mul
1242}
1243
1244define i64 @test_mul_by_66(i64 %x) {
1245; X86-LABEL: test_mul_by_66:
1246; X86:       # %bb.0:
1247; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
1248; X86-NEXT:    movl %eax, %ecx
1249; X86-NEXT:    shll $6, %ecx
1250; X86-NEXT:    leal (%ecx,%eax,2), %ecx
1251; X86-NEXT:    movl $66, %eax
1252; X86-NEXT:    mull {{[0-9]+}}(%esp)
1253; X86-NEXT:    addl %ecx, %edx
1254; X86-NEXT:    retl
1255;
1256; X86-NOOPT-LABEL: test_mul_by_66:
1257; X86-NOOPT:       # %bb.0:
1258; X86-NOOPT-NEXT:    movl $66, %eax
1259; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
1260; X86-NOOPT-NEXT:    imull $66, {{[0-9]+}}(%esp), %ecx
1261; X86-NOOPT-NEXT:    addl %ecx, %edx
1262; X86-NOOPT-NEXT:    retl
1263;
1264; X64-HSW-LABEL: test_mul_by_66:
1265; X64-HSW:       # %bb.0:
1266; X64-HSW-NEXT:    movq %rdi, %rax
1267; X64-HSW-NEXT:    shlq $6, %rax
1268; X64-HSW-NEXT:    leaq (%rax,%rdi,2), %rax
1269; X64-HSW-NEXT:    retq
1270;
1271; X64-JAG-LABEL: test_mul_by_66:
1272; X64-JAG:       # %bb.0:
1273; X64-JAG-NEXT:    movq %rdi, %rax
1274; X64-JAG-NEXT:    shlq $6, %rax
1275; X64-JAG-NEXT:    leaq (%rax,%rdi,2), %rax
1276; X64-JAG-NEXT:    retq
1277;
1278; X64-SLM-LABEL: test_mul_by_66:
1279; X64-SLM:       # %bb.0:
1280; X64-SLM-NEXT:    movq %rdi, %rax
1281; X64-SLM-NEXT:    shlq $6, %rax
1282; X64-SLM-NEXT:    addq %rdi, %rax
1283; X64-SLM-NEXT:    addq %rdi, %rax
1284; X64-SLM-NEXT:    retq
1285;
1286; X64-NOOPT-LABEL: test_mul_by_66:
1287; X64-NOOPT:       # %bb.0:
1288; X64-NOOPT-NEXT:    imulq $66, %rdi, %rax
1289; X64-NOOPT-NEXT:    retq
1290  %mul = mul nsw i64 %x, 66
1291  ret i64 %mul
1292}
1293
1294define i64 @test_mul_by_73(i64 %x) {
1295; X86-LABEL: test_mul_by_73:
1296; X86:       # %bb.0:
1297; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
1298; X86-NEXT:    leal (%eax,%eax,8), %ecx
1299; X86-NEXT:    leal (%eax,%ecx,8), %ecx
1300; X86-NEXT:    movl $73, %eax
1301; X86-NEXT:    mull {{[0-9]+}}(%esp)
1302; X86-NEXT:    addl %ecx, %edx
1303; X86-NEXT:    retl
1304;
1305; X86-NOOPT-LABEL: test_mul_by_73:
1306; X86-NOOPT:       # %bb.0:
1307; X86-NOOPT-NEXT:    movl $73, %eax
1308; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
1309; X86-NOOPT-NEXT:    imull $73, {{[0-9]+}}(%esp), %ecx
1310; X86-NOOPT-NEXT:    addl %ecx, %edx
1311; X86-NOOPT-NEXT:    retl
1312;
1313; X64-HSW-LABEL: test_mul_by_73:
1314; X64-HSW:       # %bb.0:
1315; X64-HSW-NEXT:    leaq (%rdi,%rdi,8), %rax
1316; X64-HSW-NEXT:    leaq (%rdi,%rax,8), %rax
1317; X64-HSW-NEXT:    retq
1318;
1319; X64-JAG-LABEL: test_mul_by_73:
1320; X64-JAG:       # %bb.0:
1321; X64-JAG-NEXT:    leaq (%rdi,%rdi,8), %rax
1322; X64-JAG-NEXT:    leaq (%rdi,%rax,8), %rax
1323; X64-JAG-NEXT:    retq
1324;
1325; X64-SLM-LABEL: test_mul_by_73:
1326; X64-SLM:       # %bb.0:
1327; X64-SLM-NEXT:    imulq $73, %rdi, %rax
1328; X64-SLM-NEXT:    retq
1329;
1330; X64-NOOPT-LABEL: test_mul_by_73:
1331; X64-NOOPT:       # %bb.0:
1332; X64-NOOPT-NEXT:    imulq $73, %rdi, %rax
1333; X64-NOOPT-NEXT:    retq
1334  %mul = mul nsw i64 %x, 73
1335  ret i64 %mul
1336}
1337
1338define i64 @test_mul_by_520(i64 %x) {
1339; X86-LABEL: test_mul_by_520:
1340; X86:       # %bb.0:
1341; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
1342; X86-NEXT:    movl %eax, %ecx
1343; X86-NEXT:    shll $9, %ecx
1344; X86-NEXT:    leal (%ecx,%eax,8), %ecx
1345; X86-NEXT:    movl $520, %eax # imm = 0x208
1346; X86-NEXT:    mull {{[0-9]+}}(%esp)
1347; X86-NEXT:    addl %ecx, %edx
1348; X86-NEXT:    retl
1349;
1350; X86-NOOPT-LABEL: test_mul_by_520:
1351; X86-NOOPT:       # %bb.0:
1352; X86-NOOPT-NEXT:    movl $520, %eax # imm = 0x208
1353; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
1354; X86-NOOPT-NEXT:    imull $520, {{[0-9]+}}(%esp), %ecx # imm = 0x208
1355; X86-NOOPT-NEXT:    addl %ecx, %edx
1356; X86-NOOPT-NEXT:    retl
1357;
1358; X64-HSW-LABEL: test_mul_by_520:
1359; X64-HSW:       # %bb.0:
1360; X64-HSW-NEXT:    movq %rdi, %rax
1361; X64-HSW-NEXT:    shlq $9, %rax
1362; X64-HSW-NEXT:    leaq (%rax,%rdi,8), %rax
1363; X64-HSW-NEXT:    retq
1364;
1365; X64-JAG-LABEL: test_mul_by_520:
1366; X64-JAG:       # %bb.0:
1367; X64-JAG-NEXT:    movq %rdi, %rax
1368; X64-JAG-NEXT:    shlq $9, %rax
1369; X64-JAG-NEXT:    leaq (%rax,%rdi,8), %rax
1370; X64-JAG-NEXT:    retq
1371;
1372; X64-SLM-LABEL: test_mul_by_520:
1373; X64-SLM:       # %bb.0:
1374; X64-SLM-NEXT:    imulq $520, %rdi, %rax # imm = 0x208
1375; X64-SLM-NEXT:    retq
1376;
1377; X64-NOOPT-LABEL: test_mul_by_520:
1378; X64-NOOPT:       # %bb.0:
1379; X64-NOOPT-NEXT:    imulq $520, %rdi, %rax # imm = 0x208
1380; X64-NOOPT-NEXT:    retq
1381  %mul = mul nsw i64 %x, 520
1382  ret i64 %mul
1383}
1384
1385define i64 @test_mul_by_neg10(i64 %x) {
1386; X86-LABEL: test_mul_by_neg10:
1387; X86:       # %bb.0:
1388; X86-NEXT:    pushl %esi
1389; X86-NEXT:    .cfi_def_cfa_offset 8
1390; X86-NEXT:    .cfi_offset %esi, -8
1391; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
1392; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
1393; X86-NEXT:    movl $-10, %edx
1394; X86-NEXT:    movl %ecx, %eax
1395; X86-NEXT:    mull %edx
1396; X86-NEXT:    subl %ecx, %edx
1397; X86-NEXT:    addl %esi, %esi
1398; X86-NEXT:    leal (%esi,%esi,4), %ecx
1399; X86-NEXT:    subl %ecx, %edx
1400; X86-NEXT:    popl %esi
1401; X86-NEXT:    .cfi_def_cfa_offset 4
1402; X86-NEXT:    retl
1403;
1404; X86-NOOPT-LABEL: test_mul_by_neg10:
1405; X86-NOOPT:       # %bb.0:
1406; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %ecx
1407; X86-NOOPT-NEXT:    movl $-10, %edx
1408; X86-NOOPT-NEXT:    movl %ecx, %eax
1409; X86-NOOPT-NEXT:    mull %edx
1410; X86-NOOPT-NEXT:    subl %ecx, %edx
1411; X86-NOOPT-NEXT:    imull $-10, {{[0-9]+}}(%esp), %ecx
1412; X86-NOOPT-NEXT:    addl %ecx, %edx
1413; X86-NOOPT-NEXT:    retl
1414;
1415; X64-OPT-LABEL: test_mul_by_neg10:
1416; X64-OPT:       # %bb.0:
1417; X64-OPT-NEXT:    addq %rdi, %rdi
1418; X64-OPT-NEXT:    leaq (%rdi,%rdi,4), %rax
1419; X64-OPT-NEXT:    negq %rax
1420; X64-OPT-NEXT:    retq
1421;
1422; X64-NOOPT-LABEL: test_mul_by_neg10:
1423; X64-NOOPT:       # %bb.0:
1424; X64-NOOPT-NEXT:    imulq $-10, %rdi, %rax
1425; X64-NOOPT-NEXT:    retq
1426  %mul = mul nsw i64 %x, -10
1427  ret i64 %mul
1428}
1429
1430define i64 @test_mul_by_neg36(i64 %x) {
1431; X86-LABEL: test_mul_by_neg36:
1432; X86:       # %bb.0:
1433; X86-NEXT:    pushl %esi
1434; X86-NEXT:    .cfi_def_cfa_offset 8
1435; X86-NEXT:    .cfi_offset %esi, -8
1436; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
1437; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
1438; X86-NEXT:    movl $-36, %edx
1439; X86-NEXT:    movl %ecx, %eax
1440; X86-NEXT:    mull %edx
1441; X86-NEXT:    subl %ecx, %edx
1442; X86-NEXT:    shll $2, %esi
1443; X86-NEXT:    leal (%esi,%esi,8), %ecx
1444; X86-NEXT:    subl %ecx, %edx
1445; X86-NEXT:    popl %esi
1446; X86-NEXT:    .cfi_def_cfa_offset 4
1447; X86-NEXT:    retl
1448;
1449; X86-NOOPT-LABEL: test_mul_by_neg36:
1450; X86-NOOPT:       # %bb.0:
1451; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %ecx
1452; X86-NOOPT-NEXT:    movl $-36, %edx
1453; X86-NOOPT-NEXT:    movl %ecx, %eax
1454; X86-NOOPT-NEXT:    mull %edx
1455; X86-NOOPT-NEXT:    subl %ecx, %edx
1456; X86-NOOPT-NEXT:    imull $-36, {{[0-9]+}}(%esp), %ecx
1457; X86-NOOPT-NEXT:    addl %ecx, %edx
1458; X86-NOOPT-NEXT:    retl
1459;
1460; X64-OPT-LABEL: test_mul_by_neg36:
1461; X64-OPT:       # %bb.0:
1462; X64-OPT-NEXT:    shlq $2, %rdi
1463; X64-OPT-NEXT:    leaq (%rdi,%rdi,8), %rax
1464; X64-OPT-NEXT:    negq %rax
1465; X64-OPT-NEXT:    retq
1466;
1467; X64-NOOPT-LABEL: test_mul_by_neg36:
1468; X64-NOOPT:       # %bb.0:
1469; X64-NOOPT-NEXT:    imulq $-36, %rdi, %rax
1470; X64-NOOPT-NEXT:    retq
1471  %mul = mul nsw i64 %x, -36
1472  ret i64 %mul
1473}
1474
1475; (x*9+42)*(x*5+2)
1476define i64 @test_mul_spec(i64 %x) nounwind {
1477; X86-LABEL: test_mul_spec:
1478; X86:       # %bb.0:
1479; X86-NEXT:    pushl %ebx
1480; X86-NEXT:    pushl %edi
1481; X86-NEXT:    pushl %esi
1482; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
1483; X86-NEXT:    movl {{[0-9]+}}(%esp), %edi
1484; X86-NEXT:    movl $9, %edx
1485; X86-NEXT:    movl %ecx, %eax
1486; X86-NEXT:    mull %edx
1487; X86-NEXT:    movl %eax, %esi
1488; X86-NEXT:    leal (%edi,%edi,8), %ebx
1489; X86-NEXT:    addl $42, %esi
1490; X86-NEXT:    adcl %edx, %ebx
1491; X86-NEXT:    movl $5, %edx
1492; X86-NEXT:    movl %ecx, %eax
1493; X86-NEXT:    mull %edx
1494; X86-NEXT:    movl %eax, %ecx
1495; X86-NEXT:    leal (%edi,%edi,4), %edi
1496; X86-NEXT:    addl $2, %ecx
1497; X86-NEXT:    adcl %edx, %edi
1498; X86-NEXT:    movl %esi, %eax
1499; X86-NEXT:    mull %ecx
1500; X86-NEXT:    imull %esi, %edi
1501; X86-NEXT:    addl %edi, %edx
1502; X86-NEXT:    imull %ebx, %ecx
1503; X86-NEXT:    addl %ecx, %edx
1504; X86-NEXT:    popl %esi
1505; X86-NEXT:    popl %edi
1506; X86-NEXT:    popl %ebx
1507; X86-NEXT:    retl
1508;
1509; X86-NOOPT-LABEL: test_mul_spec:
1510; X86-NOOPT:       # %bb.0:
1511; X86-NOOPT-NEXT:    pushl %ebx
1512; X86-NOOPT-NEXT:    pushl %edi
1513; X86-NOOPT-NEXT:    pushl %esi
1514; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %ecx
1515; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %edi
1516; X86-NOOPT-NEXT:    movl $9, %edx
1517; X86-NOOPT-NEXT:    movl %ecx, %eax
1518; X86-NOOPT-NEXT:    mull %edx
1519; X86-NOOPT-NEXT:    movl %eax, %esi
1520; X86-NOOPT-NEXT:    leal (%edi,%edi,8), %ebx
1521; X86-NOOPT-NEXT:    addl $42, %esi
1522; X86-NOOPT-NEXT:    adcl %edx, %ebx
1523; X86-NOOPT-NEXT:    movl $5, %edx
1524; X86-NOOPT-NEXT:    movl %ecx, %eax
1525; X86-NOOPT-NEXT:    mull %edx
1526; X86-NOOPT-NEXT:    movl %eax, %ecx
1527; X86-NOOPT-NEXT:    leal (%edi,%edi,4), %edi
1528; X86-NOOPT-NEXT:    addl $2, %ecx
1529; X86-NOOPT-NEXT:    adcl %edx, %edi
1530; X86-NOOPT-NEXT:    movl %esi, %eax
1531; X86-NOOPT-NEXT:    mull %ecx
1532; X86-NOOPT-NEXT:    imull %esi, %edi
1533; X86-NOOPT-NEXT:    addl %edi, %edx
1534; X86-NOOPT-NEXT:    imull %ebx, %ecx
1535; X86-NOOPT-NEXT:    addl %ecx, %edx
1536; X86-NOOPT-NEXT:    popl %esi
1537; X86-NOOPT-NEXT:    popl %edi
1538; X86-NOOPT-NEXT:    popl %ebx
1539; X86-NOOPT-NEXT:    retl
1540;
1541; X64-HSW-LABEL: test_mul_spec:
1542; X64-HSW:       # %bb.0:
1543; X64-HSW-NEXT:    leaq (%rdi,%rdi,8), %rcx
1544; X64-HSW-NEXT:    addq $42, %rcx
1545; X64-HSW-NEXT:    leaq (%rdi,%rdi,4), %rax
1546; X64-HSW-NEXT:    addq $2, %rax
1547; X64-HSW-NEXT:    imulq %rcx, %rax
1548; X64-HSW-NEXT:    retq
1549;
1550; X64-JAG-LABEL: test_mul_spec:
1551; X64-JAG:       # %bb.0:
1552; X64-JAG-NEXT:    leaq 42(%rdi,%rdi,8), %rcx
1553; X64-JAG-NEXT:    leaq 2(%rdi,%rdi,4), %rax
1554; X64-JAG-NEXT:    imulq %rcx, %rax
1555; X64-JAG-NEXT:    retq
1556;
1557; X64-SLM-LABEL: test_mul_spec:
1558; X64-SLM:       # %bb.0:
1559; X64-SLM-NEXT:    leaq 42(%rdi,%rdi,8), %rcx
1560; X64-SLM-NEXT:    leaq 2(%rdi,%rdi,4), %rax
1561; X64-SLM-NEXT:    imulq %rcx, %rax
1562; X64-SLM-NEXT:    retq
1563;
1564; X64-HSW-NOOPT-LABEL: test_mul_spec:
1565; X64-HSW-NOOPT:       # %bb.0:
1566; X64-HSW-NOOPT-NEXT:    leaq (%rdi,%rdi,8), %rcx
1567; X64-HSW-NOOPT-NEXT:    addq $42, %rcx
1568; X64-HSW-NOOPT-NEXT:    leaq (%rdi,%rdi,4), %rax
1569; X64-HSW-NOOPT-NEXT:    addq $2, %rax
1570; X64-HSW-NOOPT-NEXT:    imulq %rcx, %rax
1571; X64-HSW-NOOPT-NEXT:    retq
1572;
1573; X64-JAG-NOOPT-LABEL: test_mul_spec:
1574; X64-JAG-NOOPT:       # %bb.0:
1575; X64-JAG-NOOPT-NEXT:    leaq 42(%rdi,%rdi,8), %rcx
1576; X64-JAG-NOOPT-NEXT:    leaq 2(%rdi,%rdi,4), %rax
1577; X64-JAG-NOOPT-NEXT:    imulq %rcx, %rax
1578; X64-JAG-NOOPT-NEXT:    retq
1579;
1580; X64-SLM-NOOPT-LABEL: test_mul_spec:
1581; X64-SLM-NOOPT:       # %bb.0:
1582; X64-SLM-NOOPT-NEXT:    leaq 42(%rdi,%rdi,8), %rcx
1583; X64-SLM-NOOPT-NEXT:    leaq 2(%rdi,%rdi,4), %rax
1584; X64-SLM-NOOPT-NEXT:    imulq %rcx, %rax
1585; X64-SLM-NOOPT-NEXT:    retq
1586  %mul = mul nsw i64 %x, 9
1587  %add = add nsw i64 %mul, 42
1588  %mul2 = mul nsw i64 %x, 5
1589  %add2 = add nsw i64 %mul2, 2
1590  %mul3 = mul nsw i64 %add, %add2
1591  ret i64 %mul3
1592}
1593