xref: /llvm-project/llvm/test/CodeGen/X86/mul-constant-i64.ll (revision db1340412e167d828ae406975265529d95da7ef0)
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), %ecx
406; X86-NEXT:    leal (%ecx,%ecx), %eax
407; X86-NEXT:    shll $4, %ecx
408; X86-NEXT:    subl %eax, %ecx
409; X86-NEXT:    movl $14, %eax
410; X86-NEXT:    mull {{[0-9]+}}(%esp)
411; X86-NEXT:    addl %ecx, %edx
412; X86-NEXT:    retl
413;
414; X86-NOOPT-LABEL: test_mul_by_14:
415; X86-NOOPT:       # %bb.0:
416; X86-NOOPT-NEXT:    movl $14, %eax
417; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
418; X86-NOOPT-NEXT:    imull $14, {{[0-9]+}}(%esp), %ecx
419; X86-NOOPT-NEXT:    addl %ecx, %edx
420; X86-NOOPT-NEXT:    retl
421;
422; X64-OPT-LABEL: test_mul_by_14:
423; X64-OPT:       # %bb.0:
424; X64-OPT-NEXT:    movq %rdi, %rax
425; X64-OPT-NEXT:    shlq $4, %rax
426; X64-OPT-NEXT:    subq %rdi, %rax
427; X64-OPT-NEXT:    subq %rdi, %rax
428; X64-OPT-NEXT:    retq
429;
430; X64-NOOPT-LABEL: test_mul_by_14:
431; X64-NOOPT:       # %bb.0:
432; X64-NOOPT-NEXT:    imulq $14, %rdi, %rax
433; X64-NOOPT-NEXT:    retq
434  %mul = mul nsw i64 %x, 14
435  ret i64 %mul
436}
437
438define i64 @test_mul_by_15(i64 %x) {
439; X86-LABEL: test_mul_by_15:
440; X86:       # %bb.0:
441; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
442; X86-NEXT:    movl $15, %eax
443; X86-NEXT:    mull {{[0-9]+}}(%esp)
444; X86-NEXT:    leal (%ecx,%ecx,4), %ecx
445; X86-NEXT:    leal (%ecx,%ecx,2), %ecx
446; X86-NEXT:    addl %ecx, %edx
447; X86-NEXT:    retl
448;
449; X86-NOOPT-LABEL: test_mul_by_15:
450; X86-NOOPT:       # %bb.0:
451; X86-NOOPT-NEXT:    movl $15, %eax
452; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
453; X86-NOOPT-NEXT:    imull $15, {{[0-9]+}}(%esp), %ecx
454; X86-NOOPT-NEXT:    addl %ecx, %edx
455; X86-NOOPT-NEXT:    retl
456;
457; X64-OPT-LABEL: test_mul_by_15:
458; X64-OPT:       # %bb.0:
459; X64-OPT-NEXT:    leaq (%rdi,%rdi,4), %rax
460; X64-OPT-NEXT:    leaq (%rax,%rax,2), %rax
461; X64-OPT-NEXT:    retq
462;
463; X64-NOOPT-LABEL: test_mul_by_15:
464; X64-NOOPT:       # %bb.0:
465; X64-NOOPT-NEXT:    imulq $15, %rdi, %rax
466; X64-NOOPT-NEXT:    retq
467  %mul = mul nsw i64 %x, 15
468  ret i64 %mul
469}
470
471define i64 @test_mul_by_16(i64 %x) {
472; X86-LABEL: test_mul_by_16:
473; X86:       # %bb.0:
474; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
475; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
476; X86-NEXT:    shldl $4, %eax, %edx
477; X86-NEXT:    shll $4, %eax
478; X86-NEXT:    retl
479;
480; X86-NOOPT-LABEL: test_mul_by_16:
481; X86-NOOPT:       # %bb.0:
482; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %eax
483; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %edx
484; X86-NOOPT-NEXT:    shldl $4, %eax, %edx
485; X86-NOOPT-NEXT:    shll $4, %eax
486; X86-NOOPT-NEXT:    retl
487;
488; X64-LABEL: test_mul_by_16:
489; X64:       # %bb.0:
490; X64-NEXT:    movq %rdi, %rax
491; X64-NEXT:    shlq $4, %rax
492; X64-NEXT:    retq
493  %mul = mul nsw i64 %x, 16
494  ret i64 %mul
495}
496
497define i64 @test_mul_by_17(i64 %x) {
498; X86-LABEL: test_mul_by_17:
499; X86:       # %bb.0:
500; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
501; X86-NEXT:    movl %eax, %ecx
502; X86-NEXT:    shll $4, %ecx
503; X86-NEXT:    addl %eax, %ecx
504; X86-NEXT:    movl $17, %eax
505; X86-NEXT:    mull {{[0-9]+}}(%esp)
506; X86-NEXT:    addl %ecx, %edx
507; X86-NEXT:    retl
508;
509; X86-NOOPT-LABEL: test_mul_by_17:
510; X86-NOOPT:       # %bb.0:
511; X86-NOOPT-NEXT:    movl $17, %eax
512; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
513; X86-NOOPT-NEXT:    imull $17, {{[0-9]+}}(%esp), %ecx
514; X86-NOOPT-NEXT:    addl %ecx, %edx
515; X86-NOOPT-NEXT:    retl
516;
517; X64-OPT-LABEL: test_mul_by_17:
518; X64-OPT:       # %bb.0:
519; X64-OPT-NEXT:    movq %rdi, %rax
520; X64-OPT-NEXT:    shlq $4, %rax
521; X64-OPT-NEXT:    addq %rdi, %rax
522; X64-OPT-NEXT:    retq
523;
524; X64-NOOPT-LABEL: test_mul_by_17:
525; X64-NOOPT:       # %bb.0:
526; X64-NOOPT-NEXT:    imulq $17, %rdi, %rax
527; X64-NOOPT-NEXT:    retq
528  %mul = mul nsw i64 %x, 17
529  ret i64 %mul
530}
531
532define i64 @test_mul_by_18(i64 %x) {
533; X86-LABEL: test_mul_by_18:
534; X86:       # %bb.0:
535; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
536; X86-NEXT:    leal (%eax,%eax,8), %ecx
537; X86-NEXT:    movl $18, %eax
538; X86-NEXT:    mull {{[0-9]+}}(%esp)
539; X86-NEXT:    leal (%edx,%ecx,2), %edx
540; X86-NEXT:    retl
541;
542; X86-NOOPT-LABEL: test_mul_by_18:
543; X86-NOOPT:       # %bb.0:
544; X86-NOOPT-NEXT:    movl $18, %eax
545; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
546; X86-NOOPT-NEXT:    imull $18, {{[0-9]+}}(%esp), %ecx
547; X86-NOOPT-NEXT:    addl %ecx, %edx
548; X86-NOOPT-NEXT:    retl
549;
550; X64-OPT-LABEL: test_mul_by_18:
551; X64-OPT:       # %bb.0:
552; X64-OPT-NEXT:    addq %rdi, %rdi
553; X64-OPT-NEXT:    leaq (%rdi,%rdi,8), %rax
554; X64-OPT-NEXT:    retq
555;
556; X64-NOOPT-LABEL: test_mul_by_18:
557; X64-NOOPT:       # %bb.0:
558; X64-NOOPT-NEXT:    imulq $18, %rdi, %rax
559; X64-NOOPT-NEXT:    retq
560  %mul = mul nsw i64 %x, 18
561  ret i64 %mul
562}
563
564define i64 @test_mul_by_19(i64 %x) {
565; X86-LABEL: test_mul_by_19:
566; X86:       # %bb.0:
567; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
568; X86-NEXT:    leal (%eax,%eax,8), %ecx
569; X86-NEXT:    leal (%eax,%ecx,2), %ecx
570; X86-NEXT:    movl $19, %eax
571; X86-NEXT:    mull {{[0-9]+}}(%esp)
572; X86-NEXT:    addl %ecx, %edx
573; X86-NEXT:    retl
574;
575; X86-NOOPT-LABEL: test_mul_by_19:
576; X86-NOOPT:       # %bb.0:
577; X86-NOOPT-NEXT:    movl $19, %eax
578; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
579; X86-NOOPT-NEXT:    imull $19, {{[0-9]+}}(%esp), %ecx
580; X86-NOOPT-NEXT:    addl %ecx, %edx
581; X86-NOOPT-NEXT:    retl
582;
583; X64-HSW-LABEL: test_mul_by_19:
584; X64-HSW:       # %bb.0:
585; X64-HSW-NEXT:    leaq (%rdi,%rdi,8), %rax
586; X64-HSW-NEXT:    leaq (%rdi,%rax,2), %rax
587; X64-HSW-NEXT:    retq
588;
589; X64-JAG-LABEL: test_mul_by_19:
590; X64-JAG:       # %bb.0:
591; X64-JAG-NEXT:    leaq (%rdi,%rdi,8), %rax
592; X64-JAG-NEXT:    leaq (%rdi,%rax,2), %rax
593; X64-JAG-NEXT:    retq
594;
595; X64-SLM-LABEL: test_mul_by_19:
596; X64-SLM:       # %bb.0:
597; X64-SLM-NEXT:    imulq $19, %rdi, %rax
598; X64-SLM-NEXT:    retq
599;
600; X64-NOOPT-LABEL: test_mul_by_19:
601; X64-NOOPT:       # %bb.0:
602; X64-NOOPT-NEXT:    imulq $19, %rdi, %rax
603; X64-NOOPT-NEXT:    retq
604  %mul = mul nsw i64 %x, 19
605  ret i64 %mul
606}
607
608define i64 @test_mul_by_20(i64 %x) {
609; X86-LABEL: test_mul_by_20:
610; X86:       # %bb.0:
611; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
612; X86-NEXT:    leal (%eax,%eax,4), %ecx
613; X86-NEXT:    movl $20, %eax
614; X86-NEXT:    mull {{[0-9]+}}(%esp)
615; X86-NEXT:    leal (%edx,%ecx,4), %edx
616; X86-NEXT:    retl
617;
618; X86-NOOPT-LABEL: test_mul_by_20:
619; X86-NOOPT:       # %bb.0:
620; X86-NOOPT-NEXT:    movl $20, %eax
621; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
622; X86-NOOPT-NEXT:    imull $20, {{[0-9]+}}(%esp), %ecx
623; X86-NOOPT-NEXT:    addl %ecx, %edx
624; X86-NOOPT-NEXT:    retl
625;
626; X64-OPT-LABEL: test_mul_by_20:
627; X64-OPT:       # %bb.0:
628; X64-OPT-NEXT:    shlq $2, %rdi
629; X64-OPT-NEXT:    leaq (%rdi,%rdi,4), %rax
630; X64-OPT-NEXT:    retq
631;
632; X64-NOOPT-LABEL: test_mul_by_20:
633; X64-NOOPT:       # %bb.0:
634; X64-NOOPT-NEXT:    imulq $20, %rdi, %rax
635; X64-NOOPT-NEXT:    retq
636  %mul = mul nsw i64 %x, 20
637  ret i64 %mul
638}
639
640define i64 @test_mul_by_21(i64 %x) {
641; X86-LABEL: test_mul_by_21:
642; X86:       # %bb.0:
643; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
644; X86-NEXT:    leal (%eax,%eax,4), %ecx
645; X86-NEXT:    leal (%eax,%ecx,4), %ecx
646; X86-NEXT:    movl $21, %eax
647; X86-NEXT:    mull {{[0-9]+}}(%esp)
648; X86-NEXT:    addl %ecx, %edx
649; X86-NEXT:    retl
650;
651; X86-NOOPT-LABEL: test_mul_by_21:
652; X86-NOOPT:       # %bb.0:
653; X86-NOOPT-NEXT:    movl $21, %eax
654; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
655; X86-NOOPT-NEXT:    imull $21, {{[0-9]+}}(%esp), %ecx
656; X86-NOOPT-NEXT:    addl %ecx, %edx
657; X86-NOOPT-NEXT:    retl
658;
659; X64-HSW-LABEL: test_mul_by_21:
660; X64-HSW:       # %bb.0:
661; X64-HSW-NEXT:    leaq (%rdi,%rdi,4), %rax
662; X64-HSW-NEXT:    leaq (%rdi,%rax,4), %rax
663; X64-HSW-NEXT:    retq
664;
665; X64-JAG-LABEL: test_mul_by_21:
666; X64-JAG:       # %bb.0:
667; X64-JAG-NEXT:    leaq (%rdi,%rdi,4), %rax
668; X64-JAG-NEXT:    leaq (%rdi,%rax,4), %rax
669; X64-JAG-NEXT:    retq
670;
671; X64-SLM-LABEL: test_mul_by_21:
672; X64-SLM:       # %bb.0:
673; X64-SLM-NEXT:    imulq $21, %rdi, %rax
674; X64-SLM-NEXT:    retq
675;
676; X64-NOOPT-LABEL: test_mul_by_21:
677; X64-NOOPT:       # %bb.0:
678; X64-NOOPT-NEXT:    imulq $21, %rdi, %rax
679; X64-NOOPT-NEXT:    retq
680  %mul = mul nsw i64 %x, 21
681  ret i64 %mul
682}
683
684define i64 @test_mul_by_22(i64 %x) {
685; X86-LABEL: test_mul_by_22:
686; X86:       # %bb.0:
687; X86-NEXT:    pushl %esi
688; X86-NEXT:    .cfi_def_cfa_offset 8
689; X86-NEXT:    .cfi_offset %esi, -8
690; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
691; X86-NEXT:    leal (%ecx,%ecx,4), %eax
692; X86-NEXT:    leal (%ecx,%eax,4), %esi
693; X86-NEXT:    movl $22, %eax
694; X86-NEXT:    mull {{[0-9]+}}(%esp)
695; X86-NEXT:    addl %ecx, %edx
696; X86-NEXT:    addl %esi, %edx
697; X86-NEXT:    popl %esi
698; X86-NEXT:    .cfi_def_cfa_offset 4
699; X86-NEXT:    retl
700;
701; X86-NOOPT-LABEL: test_mul_by_22:
702; X86-NOOPT:       # %bb.0:
703; X86-NOOPT-NEXT:    movl $22, %eax
704; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
705; X86-NOOPT-NEXT:    imull $22, {{[0-9]+}}(%esp), %ecx
706; X86-NOOPT-NEXT:    addl %ecx, %edx
707; X86-NOOPT-NEXT:    retl
708;
709; X64-HSW-LABEL: test_mul_by_22:
710; X64-HSW:       # %bb.0:
711; X64-HSW-NEXT:    leaq (%rdi,%rdi,4), %rax
712; X64-HSW-NEXT:    leaq (%rdi,%rax,4), %rax
713; X64-HSW-NEXT:    addq %rdi, %rax
714; X64-HSW-NEXT:    retq
715;
716; X64-JAG-LABEL: test_mul_by_22:
717; X64-JAG:       # %bb.0:
718; X64-JAG-NEXT:    leaq (%rdi,%rdi,4), %rax
719; X64-JAG-NEXT:    leaq (%rdi,%rax,4), %rax
720; X64-JAG-NEXT:    addq %rdi, %rax
721; X64-JAG-NEXT:    retq
722;
723; X64-SLM-LABEL: test_mul_by_22:
724; X64-SLM:       # %bb.0:
725; X64-SLM-NEXT:    imulq $22, %rdi, %rax
726; X64-SLM-NEXT:    retq
727;
728; X64-NOOPT-LABEL: test_mul_by_22:
729; X64-NOOPT:       # %bb.0:
730; X64-NOOPT-NEXT:    imulq $22, %rdi, %rax
731; X64-NOOPT-NEXT:    retq
732  %mul = mul nsw i64 %x, 22
733  ret i64 %mul
734}
735
736define i64 @test_mul_by_23(i64 %x) {
737; X86-LABEL: test_mul_by_23:
738; X86:       # %bb.0:
739; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
740; X86-NEXT:    leal (%eax,%eax,2), %ecx
741; X86-NEXT:    shll $3, %ecx
742; X86-NEXT:    subl %eax, %ecx
743; X86-NEXT:    movl $23, %eax
744; X86-NEXT:    mull {{[0-9]+}}(%esp)
745; X86-NEXT:    addl %ecx, %edx
746; X86-NEXT:    retl
747;
748; X86-NOOPT-LABEL: test_mul_by_23:
749; X86-NOOPT:       # %bb.0:
750; X86-NOOPT-NEXT:    movl $23, %eax
751; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
752; X86-NOOPT-NEXT:    imull $23, {{[0-9]+}}(%esp), %ecx
753; X86-NOOPT-NEXT:    addl %ecx, %edx
754; X86-NOOPT-NEXT:    retl
755;
756; X64-HSW-LABEL: test_mul_by_23:
757; X64-HSW:       # %bb.0:
758; X64-HSW-NEXT:    leaq (%rdi,%rdi,2), %rax
759; X64-HSW-NEXT:    shlq $3, %rax
760; X64-HSW-NEXT:    subq %rdi, %rax
761; X64-HSW-NEXT:    retq
762;
763; X64-JAG-LABEL: test_mul_by_23:
764; X64-JAG:       # %bb.0:
765; X64-JAG-NEXT:    leaq (%rdi,%rdi,2), %rax
766; X64-JAG-NEXT:    shlq $3, %rax
767; X64-JAG-NEXT:    subq %rdi, %rax
768; X64-JAG-NEXT:    retq
769;
770; X64-SLM-LABEL: test_mul_by_23:
771; X64-SLM:       # %bb.0:
772; X64-SLM-NEXT:    imulq $23, %rdi, %rax
773; X64-SLM-NEXT:    retq
774;
775; X64-NOOPT-LABEL: test_mul_by_23:
776; X64-NOOPT:       # %bb.0:
777; X64-NOOPT-NEXT:    imulq $23, %rdi, %rax
778; X64-NOOPT-NEXT:    retq
779  %mul = mul nsw i64 %x, 23
780  ret i64 %mul
781}
782
783define i64 @test_mul_by_24(i64 %x) {
784; X86-LABEL: test_mul_by_24:
785; X86:       # %bb.0:
786; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
787; X86-NEXT:    leal (%eax,%eax,2), %ecx
788; X86-NEXT:    movl $24, %eax
789; X86-NEXT:    mull {{[0-9]+}}(%esp)
790; X86-NEXT:    leal (%edx,%ecx,8), %edx
791; X86-NEXT:    retl
792;
793; X86-NOOPT-LABEL: test_mul_by_24:
794; X86-NOOPT:       # %bb.0:
795; X86-NOOPT-NEXT:    movl $24, %eax
796; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
797; X86-NOOPT-NEXT:    imull $24, {{[0-9]+}}(%esp), %ecx
798; X86-NOOPT-NEXT:    addl %ecx, %edx
799; X86-NOOPT-NEXT:    retl
800;
801; X64-OPT-LABEL: test_mul_by_24:
802; X64-OPT:       # %bb.0:
803; X64-OPT-NEXT:    shlq $3, %rdi
804; X64-OPT-NEXT:    leaq (%rdi,%rdi,2), %rax
805; X64-OPT-NEXT:    retq
806;
807; X64-NOOPT-LABEL: test_mul_by_24:
808; X64-NOOPT:       # %bb.0:
809; X64-NOOPT-NEXT:    imulq $24, %rdi, %rax
810; X64-NOOPT-NEXT:    retq
811  %mul = mul nsw i64 %x, 24
812  ret i64 %mul
813}
814
815define i64 @test_mul_by_25(i64 %x) {
816; X86-LABEL: test_mul_by_25:
817; X86:       # %bb.0:
818; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
819; X86-NEXT:    movl $25, %eax
820; X86-NEXT:    mull {{[0-9]+}}(%esp)
821; X86-NEXT:    leal (%ecx,%ecx,4), %ecx
822; X86-NEXT:    leal (%ecx,%ecx,4), %ecx
823; X86-NEXT:    addl %ecx, %edx
824; X86-NEXT:    retl
825;
826; X86-NOOPT-LABEL: test_mul_by_25:
827; X86-NOOPT:       # %bb.0:
828; X86-NOOPT-NEXT:    movl $25, %eax
829; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
830; X86-NOOPT-NEXT:    imull $25, {{[0-9]+}}(%esp), %ecx
831; X86-NOOPT-NEXT:    addl %ecx, %edx
832; X86-NOOPT-NEXT:    retl
833;
834; X64-OPT-LABEL: test_mul_by_25:
835; X64-OPT:       # %bb.0:
836; X64-OPT-NEXT:    leaq (%rdi,%rdi,4), %rax
837; X64-OPT-NEXT:    leaq (%rax,%rax,4), %rax
838; X64-OPT-NEXT:    retq
839;
840; X64-NOOPT-LABEL: test_mul_by_25:
841; X64-NOOPT:       # %bb.0:
842; X64-NOOPT-NEXT:    imulq $25, %rdi, %rax
843; X64-NOOPT-NEXT:    retq
844  %mul = mul nsw i64 %x, 25
845  ret i64 %mul
846}
847
848define i64 @test_mul_by_26(i64 %x) {
849; X86-LABEL: test_mul_by_26:
850; X86:       # %bb.0:
851; X86-NEXT:    pushl %esi
852; X86-NEXT:    .cfi_def_cfa_offset 8
853; X86-NEXT:    .cfi_offset %esi, -8
854; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
855; X86-NEXT:    leal (%ecx,%ecx,4), %eax
856; X86-NEXT:    leal (%eax,%eax,4), %esi
857; X86-NEXT:    movl $26, %eax
858; X86-NEXT:    mull {{[0-9]+}}(%esp)
859; X86-NEXT:    addl %ecx, %edx
860; X86-NEXT:    addl %esi, %edx
861; X86-NEXT:    popl %esi
862; X86-NEXT:    .cfi_def_cfa_offset 4
863; X86-NEXT:    retl
864;
865; X86-NOOPT-LABEL: test_mul_by_26:
866; X86-NOOPT:       # %bb.0:
867; X86-NOOPT-NEXT:    movl $26, %eax
868; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
869; X86-NOOPT-NEXT:    imull $26, {{[0-9]+}}(%esp), %ecx
870; X86-NOOPT-NEXT:    addl %ecx, %edx
871; X86-NOOPT-NEXT:    retl
872;
873; X64-HSW-LABEL: test_mul_by_26:
874; X64-HSW:       # %bb.0:
875; X64-HSW-NEXT:    leaq (%rdi,%rdi,4), %rax
876; X64-HSW-NEXT:    leaq (%rax,%rax,4), %rax
877; X64-HSW-NEXT:    addq %rdi, %rax
878; X64-HSW-NEXT:    retq
879;
880; X64-JAG-LABEL: test_mul_by_26:
881; X64-JAG:       # %bb.0:
882; X64-JAG-NEXT:    leaq (%rdi,%rdi,4), %rax
883; X64-JAG-NEXT:    leaq (%rax,%rax,4), %rax
884; X64-JAG-NEXT:    addq %rdi, %rax
885; X64-JAG-NEXT:    retq
886;
887; X64-SLM-LABEL: test_mul_by_26:
888; X64-SLM:       # %bb.0:
889; X64-SLM-NEXT:    imulq $26, %rdi, %rax
890; X64-SLM-NEXT:    retq
891;
892; X64-NOOPT-LABEL: test_mul_by_26:
893; X64-NOOPT:       # %bb.0:
894; X64-NOOPT-NEXT:    imulq $26, %rdi, %rax
895; X64-NOOPT-NEXT:    retq
896  %mul = mul nsw i64 %x, 26
897  ret i64 %mul
898}
899
900define i64 @test_mul_by_27(i64 %x) {
901; X86-LABEL: test_mul_by_27:
902; X86:       # %bb.0:
903; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
904; X86-NEXT:    movl $27, %eax
905; X86-NEXT:    mull {{[0-9]+}}(%esp)
906; X86-NEXT:    leal (%ecx,%ecx,8), %ecx
907; X86-NEXT:    leal (%ecx,%ecx,2), %ecx
908; X86-NEXT:    addl %ecx, %edx
909; X86-NEXT:    retl
910;
911; X86-NOOPT-LABEL: test_mul_by_27:
912; X86-NOOPT:       # %bb.0:
913; X86-NOOPT-NEXT:    movl $27, %eax
914; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
915; X86-NOOPT-NEXT:    imull $27, {{[0-9]+}}(%esp), %ecx
916; X86-NOOPT-NEXT:    addl %ecx, %edx
917; X86-NOOPT-NEXT:    retl
918;
919; X64-OPT-LABEL: test_mul_by_27:
920; X64-OPT:       # %bb.0:
921; X64-OPT-NEXT:    leaq (%rdi,%rdi,8), %rax
922; X64-OPT-NEXT:    leaq (%rax,%rax,2), %rax
923; X64-OPT-NEXT:    retq
924;
925; X64-NOOPT-LABEL: test_mul_by_27:
926; X64-NOOPT:       # %bb.0:
927; X64-NOOPT-NEXT:    imulq $27, %rdi, %rax
928; X64-NOOPT-NEXT:    retq
929  %mul = mul nsw i64 %x, 27
930  ret i64 %mul
931}
932
933define i64 @test_mul_by_28(i64 %x) {
934; X86-LABEL: test_mul_by_28:
935; X86:       # %bb.0:
936; X86-NEXT:    pushl %esi
937; X86-NEXT:    .cfi_def_cfa_offset 8
938; X86-NEXT:    .cfi_offset %esi, -8
939; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
940; X86-NEXT:    leal (%ecx,%ecx,8), %eax
941; X86-NEXT:    leal (%eax,%eax,2), %esi
942; X86-NEXT:    movl $28, %eax
943; X86-NEXT:    mull {{[0-9]+}}(%esp)
944; X86-NEXT:    addl %ecx, %edx
945; X86-NEXT:    addl %esi, %edx
946; X86-NEXT:    popl %esi
947; X86-NEXT:    .cfi_def_cfa_offset 4
948; X86-NEXT:    retl
949;
950; X86-NOOPT-LABEL: test_mul_by_28:
951; X86-NOOPT:       # %bb.0:
952; X86-NOOPT-NEXT:    movl $28, %eax
953; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
954; X86-NOOPT-NEXT:    imull $28, {{[0-9]+}}(%esp), %ecx
955; X86-NOOPT-NEXT:    addl %ecx, %edx
956; X86-NOOPT-NEXT:    retl
957;
958; X64-HSW-LABEL: test_mul_by_28:
959; X64-HSW:       # %bb.0:
960; X64-HSW-NEXT:    leaq (%rdi,%rdi,8), %rax
961; X64-HSW-NEXT:    leaq (%rax,%rax,2), %rax
962; X64-HSW-NEXT:    addq %rdi, %rax
963; X64-HSW-NEXT:    retq
964;
965; X64-JAG-LABEL: test_mul_by_28:
966; X64-JAG:       # %bb.0:
967; X64-JAG-NEXT:    leaq (%rdi,%rdi,8), %rax
968; X64-JAG-NEXT:    leaq (%rax,%rax,2), %rax
969; X64-JAG-NEXT:    addq %rdi, %rax
970; X64-JAG-NEXT:    retq
971;
972; X64-SLM-LABEL: test_mul_by_28:
973; X64-SLM:       # %bb.0:
974; X64-SLM-NEXT:    imulq $28, %rdi, %rax
975; X64-SLM-NEXT:    retq
976;
977; X64-NOOPT-LABEL: test_mul_by_28:
978; X64-NOOPT:       # %bb.0:
979; X64-NOOPT-NEXT:    imulq $28, %rdi, %rax
980; X64-NOOPT-NEXT:    retq
981  %mul = mul nsw i64 %x, 28
982  ret i64 %mul
983}
984
985define i64 @test_mul_by_29(i64 %x) {
986; X86-LABEL: test_mul_by_29:
987; X86:       # %bb.0:
988; X86-NEXT:    pushl %esi
989; X86-NEXT:    .cfi_def_cfa_offset 8
990; X86-NEXT:    .cfi_offset %esi, -8
991; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
992; X86-NEXT:    leal (%ecx,%ecx,8), %eax
993; X86-NEXT:    leal (%eax,%eax,2), %esi
994; X86-NEXT:    addl %ecx, %ecx
995; X86-NEXT:    movl $29, %eax
996; X86-NEXT:    mull {{[0-9]+}}(%esp)
997; X86-NEXT:    addl %ecx, %edx
998; X86-NEXT:    addl %esi, %edx
999; X86-NEXT:    popl %esi
1000; X86-NEXT:    .cfi_def_cfa_offset 4
1001; X86-NEXT:    retl
1002;
1003; X86-NOOPT-LABEL: test_mul_by_29:
1004; X86-NOOPT:       # %bb.0:
1005; X86-NOOPT-NEXT:    movl $29, %eax
1006; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
1007; X86-NOOPT-NEXT:    imull $29, {{[0-9]+}}(%esp), %ecx
1008; X86-NOOPT-NEXT:    addl %ecx, %edx
1009; X86-NOOPT-NEXT:    retl
1010;
1011; X64-HSW-LABEL: test_mul_by_29:
1012; X64-HSW:       # %bb.0:
1013; X64-HSW-NEXT:    leaq (%rdi,%rdi,8), %rax
1014; X64-HSW-NEXT:    leaq (%rax,%rax,2), %rax
1015; X64-HSW-NEXT:    addq %rdi, %rax
1016; X64-HSW-NEXT:    addq %rdi, %rax
1017; X64-HSW-NEXT:    retq
1018;
1019; X64-JAG-LABEL: test_mul_by_29:
1020; X64-JAG:       # %bb.0:
1021; X64-JAG-NEXT:    leaq (%rdi,%rdi,8), %rax
1022; X64-JAG-NEXT:    leaq (%rax,%rax,2), %rax
1023; X64-JAG-NEXT:    addq %rdi, %rax
1024; X64-JAG-NEXT:    addq %rdi, %rax
1025; X64-JAG-NEXT:    retq
1026;
1027; X64-SLM-LABEL: test_mul_by_29:
1028; X64-SLM:       # %bb.0:
1029; X64-SLM-NEXT:    imulq $29, %rdi, %rax
1030; X64-SLM-NEXT:    retq
1031;
1032; X64-NOOPT-LABEL: test_mul_by_29:
1033; X64-NOOPT:       # %bb.0:
1034; X64-NOOPT-NEXT:    imulq $29, %rdi, %rax
1035; X64-NOOPT-NEXT:    retq
1036  %mul = mul nsw i64 %x, 29
1037  ret i64 %mul
1038}
1039
1040define i64 @test_mul_by_30(i64 %x) {
1041; X86-LABEL: test_mul_by_30:
1042; X86:       # %bb.0:
1043; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
1044; X86-NEXT:    leal (%ecx,%ecx), %eax
1045; X86-NEXT:    shll $5, %ecx
1046; X86-NEXT:    subl %eax, %ecx
1047; X86-NEXT:    movl $30, %eax
1048; X86-NEXT:    mull {{[0-9]+}}(%esp)
1049; X86-NEXT:    addl %ecx, %edx
1050; X86-NEXT:    retl
1051;
1052; X86-NOOPT-LABEL: test_mul_by_30:
1053; X86-NOOPT:       # %bb.0:
1054; X86-NOOPT-NEXT:    movl $30, %eax
1055; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
1056; X86-NOOPT-NEXT:    imull $30, {{[0-9]+}}(%esp), %ecx
1057; X86-NOOPT-NEXT:    addl %ecx, %edx
1058; X86-NOOPT-NEXT:    retl
1059;
1060; X64-OPT-LABEL: test_mul_by_30:
1061; X64-OPT:       # %bb.0:
1062; X64-OPT-NEXT:    movq %rdi, %rax
1063; X64-OPT-NEXT:    shlq $5, %rax
1064; X64-OPT-NEXT:    subq %rdi, %rax
1065; X64-OPT-NEXT:    subq %rdi, %rax
1066; X64-OPT-NEXT:    retq
1067;
1068; X64-NOOPT-LABEL: test_mul_by_30:
1069; X64-NOOPT:       # %bb.0:
1070; X64-NOOPT-NEXT:    imulq $30, %rdi, %rax
1071; X64-NOOPT-NEXT:    retq
1072  %mul = mul nsw i64 %x, 30
1073  ret i64 %mul
1074}
1075
1076define i64 @test_mul_by_31(i64 %x) {
1077; X86-LABEL: test_mul_by_31:
1078; X86:       # %bb.0:
1079; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
1080; X86-NEXT:    movl %eax, %ecx
1081; X86-NEXT:    shll $5, %ecx
1082; X86-NEXT:    subl %eax, %ecx
1083; X86-NEXT:    movl $31, %eax
1084; X86-NEXT:    mull {{[0-9]+}}(%esp)
1085; X86-NEXT:    addl %ecx, %edx
1086; X86-NEXT:    retl
1087;
1088; X86-NOOPT-LABEL: test_mul_by_31:
1089; X86-NOOPT:       # %bb.0:
1090; X86-NOOPT-NEXT:    movl $31, %eax
1091; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
1092; X86-NOOPT-NEXT:    imull $31, {{[0-9]+}}(%esp), %ecx
1093; X86-NOOPT-NEXT:    addl %ecx, %edx
1094; X86-NOOPT-NEXT:    retl
1095;
1096; X64-OPT-LABEL: test_mul_by_31:
1097; X64-OPT:       # %bb.0:
1098; X64-OPT-NEXT:    movq %rdi, %rax
1099; X64-OPT-NEXT:    shlq $5, %rax
1100; X64-OPT-NEXT:    subq %rdi, %rax
1101; X64-OPT-NEXT:    retq
1102;
1103; X64-NOOPT-LABEL: test_mul_by_31:
1104; X64-NOOPT:       # %bb.0:
1105; X64-NOOPT-NEXT:    imulq $31, %rdi, %rax
1106; X64-NOOPT-NEXT:    retq
1107  %mul = mul nsw i64 %x, 31
1108  ret i64 %mul
1109}
1110
1111define i64 @test_mul_by_32(i64 %x) {
1112; X86-LABEL: test_mul_by_32:
1113; X86:       # %bb.0:
1114; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
1115; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
1116; X86-NEXT:    shldl $5, %eax, %edx
1117; X86-NEXT:    shll $5, %eax
1118; X86-NEXT:    retl
1119;
1120; X86-NOOPT-LABEL: test_mul_by_32:
1121; X86-NOOPT:       # %bb.0:
1122; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %eax
1123; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %edx
1124; X86-NOOPT-NEXT:    shldl $5, %eax, %edx
1125; X86-NOOPT-NEXT:    shll $5, %eax
1126; X86-NOOPT-NEXT:    retl
1127;
1128; X64-LABEL: test_mul_by_32:
1129; X64:       # %bb.0:
1130; X64-NEXT:    movq %rdi, %rax
1131; X64-NEXT:    shlq $5, %rax
1132; X64-NEXT:    retq
1133  %mul = mul nsw i64 %x, 32
1134  ret i64 %mul
1135}
1136
1137define i64 @test_mul_by_37(i64 %x) {
1138; X86-LABEL: test_mul_by_37:
1139; X86:       # %bb.0:
1140; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
1141; X86-NEXT:    leal (%eax,%eax,8), %ecx
1142; X86-NEXT:    leal (%eax,%ecx,4), %ecx
1143; X86-NEXT:    movl $37, %eax
1144; X86-NEXT:    mull {{[0-9]+}}(%esp)
1145; X86-NEXT:    addl %ecx, %edx
1146; X86-NEXT:    retl
1147;
1148; X86-NOOPT-LABEL: test_mul_by_37:
1149; X86-NOOPT:       # %bb.0:
1150; X86-NOOPT-NEXT:    movl $37, %eax
1151; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
1152; X86-NOOPT-NEXT:    imull $37, {{[0-9]+}}(%esp), %ecx
1153; X86-NOOPT-NEXT:    addl %ecx, %edx
1154; X86-NOOPT-NEXT:    retl
1155;
1156; X64-HSW-LABEL: test_mul_by_37:
1157; X64-HSW:       # %bb.0:
1158; X64-HSW-NEXT:    leaq (%rdi,%rdi,8), %rax
1159; X64-HSW-NEXT:    leaq (%rdi,%rax,4), %rax
1160; X64-HSW-NEXT:    retq
1161;
1162; X64-JAG-LABEL: test_mul_by_37:
1163; X64-JAG:       # %bb.0:
1164; X64-JAG-NEXT:    leaq (%rdi,%rdi,8), %rax
1165; X64-JAG-NEXT:    leaq (%rdi,%rax,4), %rax
1166; X64-JAG-NEXT:    retq
1167;
1168; X64-SLM-LABEL: test_mul_by_37:
1169; X64-SLM:       # %bb.0:
1170; X64-SLM-NEXT:    imulq $37, %rdi, %rax
1171; X64-SLM-NEXT:    retq
1172;
1173; X64-NOOPT-LABEL: test_mul_by_37:
1174; X64-NOOPT:       # %bb.0:
1175; X64-NOOPT-NEXT:    imulq $37, %rdi, %rax
1176; X64-NOOPT-NEXT:    retq
1177  %mul = mul nsw i64 %x, 37
1178  ret i64 %mul
1179}
1180
1181define i64 @test_mul_by_41(i64 %x) {
1182; X86-LABEL: test_mul_by_41:
1183; X86:       # %bb.0:
1184; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
1185; X86-NEXT:    leal (%eax,%eax,4), %ecx
1186; X86-NEXT:    leal (%eax,%ecx,8), %ecx
1187; X86-NEXT:    movl $41, %eax
1188; X86-NEXT:    mull {{[0-9]+}}(%esp)
1189; X86-NEXT:    addl %ecx, %edx
1190; X86-NEXT:    retl
1191;
1192; X86-NOOPT-LABEL: test_mul_by_41:
1193; X86-NOOPT:       # %bb.0:
1194; X86-NOOPT-NEXT:    movl $41, %eax
1195; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
1196; X86-NOOPT-NEXT:    imull $41, {{[0-9]+}}(%esp), %ecx
1197; X86-NOOPT-NEXT:    addl %ecx, %edx
1198; X86-NOOPT-NEXT:    retl
1199;
1200; X64-HSW-LABEL: test_mul_by_41:
1201; X64-HSW:       # %bb.0:
1202; X64-HSW-NEXT:    leaq (%rdi,%rdi,4), %rax
1203; X64-HSW-NEXT:    leaq (%rdi,%rax,8), %rax
1204; X64-HSW-NEXT:    retq
1205;
1206; X64-JAG-LABEL: test_mul_by_41:
1207; X64-JAG:       # %bb.0:
1208; X64-JAG-NEXT:    leaq (%rdi,%rdi,4), %rax
1209; X64-JAG-NEXT:    leaq (%rdi,%rax,8), %rax
1210; X64-JAG-NEXT:    retq
1211;
1212; X64-SLM-LABEL: test_mul_by_41:
1213; X64-SLM:       # %bb.0:
1214; X64-SLM-NEXT:    imulq $41, %rdi, %rax
1215; X64-SLM-NEXT:    retq
1216;
1217; X64-NOOPT-LABEL: test_mul_by_41:
1218; X64-NOOPT:       # %bb.0:
1219; X64-NOOPT-NEXT:    imulq $41, %rdi, %rax
1220; X64-NOOPT-NEXT:    retq
1221  %mul = mul nsw i64 %x, 41
1222  ret i64 %mul
1223}
1224
1225define i64 @test_mul_by_62(i64 %x) {
1226; X86-LABEL: test_mul_by_62:
1227; X86:       # %bb.0:
1228; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
1229; X86-NEXT:    leal (%ecx,%ecx), %eax
1230; X86-NEXT:    shll $6, %ecx
1231; X86-NEXT:    subl %eax, %ecx
1232; X86-NEXT:    movl $62, %eax
1233; X86-NEXT:    mull {{[0-9]+}}(%esp)
1234; X86-NEXT:    addl %ecx, %edx
1235; X86-NEXT:    retl
1236;
1237; X86-NOOPT-LABEL: test_mul_by_62:
1238; X86-NOOPT:       # %bb.0:
1239; X86-NOOPT-NEXT:    movl $62, %eax
1240; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
1241; X86-NOOPT-NEXT:    imull $62, {{[0-9]+}}(%esp), %ecx
1242; X86-NOOPT-NEXT:    addl %ecx, %edx
1243; X86-NOOPT-NEXT:    retl
1244;
1245; X64-OPT-LABEL: test_mul_by_62:
1246; X64-OPT:       # %bb.0:
1247; X64-OPT-NEXT:    movq %rdi, %rax
1248; X64-OPT-NEXT:    shlq $6, %rax
1249; X64-OPT-NEXT:    subq %rdi, %rax
1250; X64-OPT-NEXT:    subq %rdi, %rax
1251; X64-OPT-NEXT:    retq
1252;
1253; X64-NOOPT-LABEL: test_mul_by_62:
1254; X64-NOOPT:       # %bb.0:
1255; X64-NOOPT-NEXT:    imulq $62, %rdi, %rax
1256; X64-NOOPT-NEXT:    retq
1257  %mul = mul nsw i64 %x, 62
1258  ret i64 %mul
1259}
1260
1261define i64 @test_mul_by_66(i64 %x) {
1262; X86-LABEL: test_mul_by_66:
1263; X86:       # %bb.0:
1264; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
1265; X86-NEXT:    movl %eax, %ecx
1266; X86-NEXT:    shll $6, %ecx
1267; X86-NEXT:    leal (%ecx,%eax,2), %ecx
1268; X86-NEXT:    movl $66, %eax
1269; X86-NEXT:    mull {{[0-9]+}}(%esp)
1270; X86-NEXT:    addl %ecx, %edx
1271; X86-NEXT:    retl
1272;
1273; X86-NOOPT-LABEL: test_mul_by_66:
1274; X86-NOOPT:       # %bb.0:
1275; X86-NOOPT-NEXT:    movl $66, %eax
1276; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
1277; X86-NOOPT-NEXT:    imull $66, {{[0-9]+}}(%esp), %ecx
1278; X86-NOOPT-NEXT:    addl %ecx, %edx
1279; X86-NOOPT-NEXT:    retl
1280;
1281; X64-HSW-LABEL: test_mul_by_66:
1282; X64-HSW:       # %bb.0:
1283; X64-HSW-NEXT:    movq %rdi, %rax
1284; X64-HSW-NEXT:    shlq $6, %rax
1285; X64-HSW-NEXT:    leaq (%rax,%rdi,2), %rax
1286; X64-HSW-NEXT:    retq
1287;
1288; X64-JAG-LABEL: test_mul_by_66:
1289; X64-JAG:       # %bb.0:
1290; X64-JAG-NEXT:    movq %rdi, %rax
1291; X64-JAG-NEXT:    shlq $6, %rax
1292; X64-JAG-NEXT:    leaq (%rax,%rdi,2), %rax
1293; X64-JAG-NEXT:    retq
1294;
1295; X64-SLM-LABEL: test_mul_by_66:
1296; X64-SLM:       # %bb.0:
1297; X64-SLM-NEXT:    leaq (%rdi,%rdi), %rax
1298; X64-SLM-NEXT:    shlq $6, %rdi
1299; X64-SLM-NEXT:    addq %rdi, %rax
1300; X64-SLM-NEXT:    retq
1301;
1302; X64-NOOPT-LABEL: test_mul_by_66:
1303; X64-NOOPT:       # %bb.0:
1304; X64-NOOPT-NEXT:    imulq $66, %rdi, %rax
1305; X64-NOOPT-NEXT:    retq
1306  %mul = mul nsw i64 %x, 66
1307  ret i64 %mul
1308}
1309
1310define i64 @test_mul_by_73(i64 %x) {
1311; X86-LABEL: test_mul_by_73:
1312; X86:       # %bb.0:
1313; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
1314; X86-NEXT:    leal (%eax,%eax,8), %ecx
1315; X86-NEXT:    leal (%eax,%ecx,8), %ecx
1316; X86-NEXT:    movl $73, %eax
1317; X86-NEXT:    mull {{[0-9]+}}(%esp)
1318; X86-NEXT:    addl %ecx, %edx
1319; X86-NEXT:    retl
1320;
1321; X86-NOOPT-LABEL: test_mul_by_73:
1322; X86-NOOPT:       # %bb.0:
1323; X86-NOOPT-NEXT:    movl $73, %eax
1324; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
1325; X86-NOOPT-NEXT:    imull $73, {{[0-9]+}}(%esp), %ecx
1326; X86-NOOPT-NEXT:    addl %ecx, %edx
1327; X86-NOOPT-NEXT:    retl
1328;
1329; X64-HSW-LABEL: test_mul_by_73:
1330; X64-HSW:       # %bb.0:
1331; X64-HSW-NEXT:    leaq (%rdi,%rdi,8), %rax
1332; X64-HSW-NEXT:    leaq (%rdi,%rax,8), %rax
1333; X64-HSW-NEXT:    retq
1334;
1335; X64-JAG-LABEL: test_mul_by_73:
1336; X64-JAG:       # %bb.0:
1337; X64-JAG-NEXT:    leaq (%rdi,%rdi,8), %rax
1338; X64-JAG-NEXT:    leaq (%rdi,%rax,8), %rax
1339; X64-JAG-NEXT:    retq
1340;
1341; X64-SLM-LABEL: test_mul_by_73:
1342; X64-SLM:       # %bb.0:
1343; X64-SLM-NEXT:    imulq $73, %rdi, %rax
1344; X64-SLM-NEXT:    retq
1345;
1346; X64-NOOPT-LABEL: test_mul_by_73:
1347; X64-NOOPT:       # %bb.0:
1348; X64-NOOPT-NEXT:    imulq $73, %rdi, %rax
1349; X64-NOOPT-NEXT:    retq
1350  %mul = mul nsw i64 %x, 73
1351  ret i64 %mul
1352}
1353
1354define i64 @test_mul_by_520(i64 %x) {
1355; X86-LABEL: test_mul_by_520:
1356; X86:       # %bb.0:
1357; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
1358; X86-NEXT:    movl %eax, %ecx
1359; X86-NEXT:    shll $9, %ecx
1360; X86-NEXT:    leal (%ecx,%eax,8), %ecx
1361; X86-NEXT:    movl $520, %eax # imm = 0x208
1362; X86-NEXT:    mull {{[0-9]+}}(%esp)
1363; X86-NEXT:    addl %ecx, %edx
1364; X86-NEXT:    retl
1365;
1366; X86-NOOPT-LABEL: test_mul_by_520:
1367; X86-NOOPT:       # %bb.0:
1368; X86-NOOPT-NEXT:    movl $520, %eax # imm = 0x208
1369; X86-NOOPT-NEXT:    mull {{[0-9]+}}(%esp)
1370; X86-NOOPT-NEXT:    imull $520, {{[0-9]+}}(%esp), %ecx # imm = 0x208
1371; X86-NOOPT-NEXT:    addl %ecx, %edx
1372; X86-NOOPT-NEXT:    retl
1373;
1374; X64-HSW-LABEL: test_mul_by_520:
1375; X64-HSW:       # %bb.0:
1376; X64-HSW-NEXT:    movq %rdi, %rax
1377; X64-HSW-NEXT:    shlq $9, %rax
1378; X64-HSW-NEXT:    leaq (%rax,%rdi,8), %rax
1379; X64-HSW-NEXT:    retq
1380;
1381; X64-JAG-LABEL: test_mul_by_520:
1382; X64-JAG:       # %bb.0:
1383; X64-JAG-NEXT:    movq %rdi, %rax
1384; X64-JAG-NEXT:    shlq $9, %rax
1385; X64-JAG-NEXT:    leaq (%rax,%rdi,8), %rax
1386; X64-JAG-NEXT:    retq
1387;
1388; X64-SLM-LABEL: test_mul_by_520:
1389; X64-SLM:       # %bb.0:
1390; X64-SLM-NEXT:    imulq $520, %rdi, %rax # imm = 0x208
1391; X64-SLM-NEXT:    retq
1392;
1393; X64-NOOPT-LABEL: test_mul_by_520:
1394; X64-NOOPT:       # %bb.0:
1395; X64-NOOPT-NEXT:    imulq $520, %rdi, %rax # imm = 0x208
1396; X64-NOOPT-NEXT:    retq
1397  %mul = mul nsw i64 %x, 520
1398  ret i64 %mul
1399}
1400
1401define i64 @test_mul_by_neg10(i64 %x) {
1402; X86-LABEL: test_mul_by_neg10:
1403; X86:       # %bb.0:
1404; X86-NEXT:    pushl %esi
1405; X86-NEXT:    .cfi_def_cfa_offset 8
1406; X86-NEXT:    .cfi_offset %esi, -8
1407; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
1408; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
1409; X86-NEXT:    movl $-10, %edx
1410; X86-NEXT:    movl %ecx, %eax
1411; X86-NEXT:    mull %edx
1412; X86-NEXT:    subl %ecx, %edx
1413; X86-NEXT:    addl %esi, %esi
1414; X86-NEXT:    leal (%esi,%esi,4), %ecx
1415; X86-NEXT:    subl %ecx, %edx
1416; X86-NEXT:    popl %esi
1417; X86-NEXT:    .cfi_def_cfa_offset 4
1418; X86-NEXT:    retl
1419;
1420; X86-NOOPT-LABEL: test_mul_by_neg10:
1421; X86-NOOPT:       # %bb.0:
1422; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %ecx
1423; X86-NOOPT-NEXT:    movl $-10, %edx
1424; X86-NOOPT-NEXT:    movl %ecx, %eax
1425; X86-NOOPT-NEXT:    mull %edx
1426; X86-NOOPT-NEXT:    subl %ecx, %edx
1427; X86-NOOPT-NEXT:    imull $-10, {{[0-9]+}}(%esp), %ecx
1428; X86-NOOPT-NEXT:    addl %ecx, %edx
1429; X86-NOOPT-NEXT:    retl
1430;
1431; X64-OPT-LABEL: test_mul_by_neg10:
1432; X64-OPT:       # %bb.0:
1433; X64-OPT-NEXT:    addq %rdi, %rdi
1434; X64-OPT-NEXT:    leaq (%rdi,%rdi,4), %rax
1435; X64-OPT-NEXT:    negq %rax
1436; X64-OPT-NEXT:    retq
1437;
1438; X64-NOOPT-LABEL: test_mul_by_neg10:
1439; X64-NOOPT:       # %bb.0:
1440; X64-NOOPT-NEXT:    imulq $-10, %rdi, %rax
1441; X64-NOOPT-NEXT:    retq
1442  %mul = mul nsw i64 %x, -10
1443  ret i64 %mul
1444}
1445
1446define i64 @test_mul_by_neg36(i64 %x) {
1447; X86-LABEL: test_mul_by_neg36:
1448; X86:       # %bb.0:
1449; X86-NEXT:    pushl %esi
1450; X86-NEXT:    .cfi_def_cfa_offset 8
1451; X86-NEXT:    .cfi_offset %esi, -8
1452; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
1453; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
1454; X86-NEXT:    movl $-36, %edx
1455; X86-NEXT:    movl %ecx, %eax
1456; X86-NEXT:    mull %edx
1457; X86-NEXT:    subl %ecx, %edx
1458; X86-NEXT:    shll $2, %esi
1459; X86-NEXT:    leal (%esi,%esi,8), %ecx
1460; X86-NEXT:    subl %ecx, %edx
1461; X86-NEXT:    popl %esi
1462; X86-NEXT:    .cfi_def_cfa_offset 4
1463; X86-NEXT:    retl
1464;
1465; X86-NOOPT-LABEL: test_mul_by_neg36:
1466; X86-NOOPT:       # %bb.0:
1467; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %ecx
1468; X86-NOOPT-NEXT:    movl $-36, %edx
1469; X86-NOOPT-NEXT:    movl %ecx, %eax
1470; X86-NOOPT-NEXT:    mull %edx
1471; X86-NOOPT-NEXT:    subl %ecx, %edx
1472; X86-NOOPT-NEXT:    imull $-36, {{[0-9]+}}(%esp), %ecx
1473; X86-NOOPT-NEXT:    addl %ecx, %edx
1474; X86-NOOPT-NEXT:    retl
1475;
1476; X64-OPT-LABEL: test_mul_by_neg36:
1477; X64-OPT:       # %bb.0:
1478; X64-OPT-NEXT:    shlq $2, %rdi
1479; X64-OPT-NEXT:    leaq (%rdi,%rdi,8), %rax
1480; X64-OPT-NEXT:    negq %rax
1481; X64-OPT-NEXT:    retq
1482;
1483; X64-NOOPT-LABEL: test_mul_by_neg36:
1484; X64-NOOPT:       # %bb.0:
1485; X64-NOOPT-NEXT:    imulq $-36, %rdi, %rax
1486; X64-NOOPT-NEXT:    retq
1487  %mul = mul nsw i64 %x, -36
1488  ret i64 %mul
1489}
1490
1491; (x*9+42)*(x*5+2)
1492define i64 @test_mul_spec(i64 %x) nounwind {
1493; X86-LABEL: test_mul_spec:
1494; X86:       # %bb.0:
1495; X86-NEXT:    pushl %ebp
1496; X86-NEXT:    pushl %ebx
1497; X86-NEXT:    pushl %edi
1498; X86-NEXT:    pushl %esi
1499; X86-NEXT:    movl {{[0-9]+}}(%esp), %edi
1500; X86-NEXT:    movl {{[0-9]+}}(%esp), %ebp
1501; X86-NEXT:    movl $9, %ecx
1502; X86-NEXT:    movl %edi, %eax
1503; X86-NEXT:    mull %ecx
1504; X86-NEXT:    movl %eax, %esi
1505; X86-NEXT:    movl %edx, %ecx
1506; X86-NEXT:    leal (%ebp,%ebp,8), %eax
1507; X86-NEXT:    addl $42, %esi
1508; X86-NEXT:    adcl %eax, %ecx
1509; X86-NEXT:    movl $5, %edx
1510; X86-NEXT:    movl %edi, %eax
1511; X86-NEXT:    mull %edx
1512; X86-NEXT:    movl %eax, %edi
1513; X86-NEXT:    movl %edx, %ebx
1514; X86-NEXT:    leal (%ebp,%ebp,4), %eax
1515; X86-NEXT:    addl $2, %edi
1516; X86-NEXT:    adcl %eax, %ebx
1517; X86-NEXT:    movl %esi, %eax
1518; X86-NEXT:    mull %edi
1519; X86-NEXT:    imull %esi, %ebx
1520; X86-NEXT:    addl %ebx, %edx
1521; X86-NEXT:    imull %ecx, %edi
1522; X86-NEXT:    addl %edi, %edx
1523; X86-NEXT:    popl %esi
1524; X86-NEXT:    popl %edi
1525; X86-NEXT:    popl %ebx
1526; X86-NEXT:    popl %ebp
1527; X86-NEXT:    retl
1528;
1529; X86-NOOPT-LABEL: test_mul_spec:
1530; X86-NOOPT:       # %bb.0:
1531; X86-NOOPT-NEXT:    pushl %ebp
1532; X86-NOOPT-NEXT:    pushl %ebx
1533; X86-NOOPT-NEXT:    pushl %edi
1534; X86-NOOPT-NEXT:    pushl %esi
1535; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %edi
1536; X86-NOOPT-NEXT:    movl {{[0-9]+}}(%esp), %ebp
1537; X86-NOOPT-NEXT:    movl $9, %ecx
1538; X86-NOOPT-NEXT:    movl %edi, %eax
1539; X86-NOOPT-NEXT:    mull %ecx
1540; X86-NOOPT-NEXT:    movl %eax, %esi
1541; X86-NOOPT-NEXT:    movl %edx, %ecx
1542; X86-NOOPT-NEXT:    leal (%ebp,%ebp,8), %eax
1543; X86-NOOPT-NEXT:    addl $42, %esi
1544; X86-NOOPT-NEXT:    adcl %eax, %ecx
1545; X86-NOOPT-NEXT:    movl $5, %edx
1546; X86-NOOPT-NEXT:    movl %edi, %eax
1547; X86-NOOPT-NEXT:    mull %edx
1548; X86-NOOPT-NEXT:    movl %eax, %edi
1549; X86-NOOPT-NEXT:    movl %edx, %ebx
1550; X86-NOOPT-NEXT:    leal (%ebp,%ebp,4), %eax
1551; X86-NOOPT-NEXT:    addl $2, %edi
1552; X86-NOOPT-NEXT:    adcl %eax, %ebx
1553; X86-NOOPT-NEXT:    movl %esi, %eax
1554; X86-NOOPT-NEXT:    mull %edi
1555; X86-NOOPT-NEXT:    imull %esi, %ebx
1556; X86-NOOPT-NEXT:    addl %ebx, %edx
1557; X86-NOOPT-NEXT:    imull %ecx, %edi
1558; X86-NOOPT-NEXT:    addl %edi, %edx
1559; X86-NOOPT-NEXT:    popl %esi
1560; X86-NOOPT-NEXT:    popl %edi
1561; X86-NOOPT-NEXT:    popl %ebx
1562; X86-NOOPT-NEXT:    popl %ebp
1563; X86-NOOPT-NEXT:    retl
1564;
1565; X64-HSW-LABEL: test_mul_spec:
1566; X64-HSW:       # %bb.0:
1567; X64-HSW-NEXT:    leaq (%rdi,%rdi,8), %rcx
1568; X64-HSW-NEXT:    addq $42, %rcx
1569; X64-HSW-NEXT:    leaq (%rdi,%rdi,4), %rax
1570; X64-HSW-NEXT:    addq $2, %rax
1571; X64-HSW-NEXT:    imulq %rcx, %rax
1572; X64-HSW-NEXT:    retq
1573;
1574; X64-JAG-LABEL: test_mul_spec:
1575; X64-JAG:       # %bb.0:
1576; X64-JAG-NEXT:    leaq 42(%rdi,%rdi,8), %rcx
1577; X64-JAG-NEXT:    leaq 2(%rdi,%rdi,4), %rax
1578; X64-JAG-NEXT:    imulq %rcx, %rax
1579; X64-JAG-NEXT:    retq
1580;
1581; X64-SLM-LABEL: test_mul_spec:
1582; X64-SLM:       # %bb.0:
1583; X64-SLM-NEXT:    leaq 42(%rdi,%rdi,8), %rcx
1584; X64-SLM-NEXT:    leaq 2(%rdi,%rdi,4), %rax
1585; X64-SLM-NEXT:    imulq %rcx, %rax
1586; X64-SLM-NEXT:    retq
1587;
1588; X64-HSW-NOOPT-LABEL: test_mul_spec:
1589; X64-HSW-NOOPT:       # %bb.0:
1590; X64-HSW-NOOPT-NEXT:    leaq (%rdi,%rdi,8), %rcx
1591; X64-HSW-NOOPT-NEXT:    addq $42, %rcx
1592; X64-HSW-NOOPT-NEXT:    leaq (%rdi,%rdi,4), %rax
1593; X64-HSW-NOOPT-NEXT:    addq $2, %rax
1594; X64-HSW-NOOPT-NEXT:    imulq %rcx, %rax
1595; X64-HSW-NOOPT-NEXT:    retq
1596;
1597; X64-JAG-NOOPT-LABEL: test_mul_spec:
1598; X64-JAG-NOOPT:       # %bb.0:
1599; X64-JAG-NOOPT-NEXT:    leaq 42(%rdi,%rdi,8), %rcx
1600; X64-JAG-NOOPT-NEXT:    leaq 2(%rdi,%rdi,4), %rax
1601; X64-JAG-NOOPT-NEXT:    imulq %rcx, %rax
1602; X64-JAG-NOOPT-NEXT:    retq
1603;
1604; X64-SLM-NOOPT-LABEL: test_mul_spec:
1605; X64-SLM-NOOPT:       # %bb.0:
1606; X64-SLM-NOOPT-NEXT:    leaq 42(%rdi,%rdi,8), %rcx
1607; X64-SLM-NOOPT-NEXT:    leaq 2(%rdi,%rdi,4), %rax
1608; X64-SLM-NOOPT-NEXT:    imulq %rcx, %rax
1609; X64-SLM-NOOPT-NEXT:    retq
1610  %mul = mul nsw i64 %x, 9
1611  %add = add nsw i64 %mul, 42
1612  %mul2 = mul nsw i64 %x, 5
1613  %add2 = add nsw i64 %mul2, 2
1614  %mul3 = mul nsw i64 %add, %add2
1615  ret i64 %mul3
1616}
1617
1618define i64 @PR111325(i64 %a0, i1 %a1) {
1619; X86-LABEL: PR111325:
1620; X86:       # %bb.0: # %entry
1621; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx
1622; X86-NEXT:    andb $1, %cl
1623; X86-NEXT:    xorl %eax, %eax
1624; X86-NEXT:    xorl %edx, %edx
1625; X86-NEXT:    subl {{[0-9]+}}(%esp), %edx
1626; X86-NEXT:    cmpb $1, %cl
1627; X86-NEXT:    sbbl %eax, %eax
1628; X86-NEXT:    orl %edx, %eax
1629; X86-NEXT:    xorl %edx, %edx
1630; X86-NEXT:    retl
1631;
1632; X86-NOOPT-LABEL: PR111325:
1633; X86-NOOPT:       # %bb.0: # %entry
1634; X86-NOOPT-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx
1635; X86-NOOPT-NEXT:    andb $1, %cl
1636; X86-NOOPT-NEXT:    xorl %eax, %eax
1637; X86-NOOPT-NEXT:    xorl %edx, %edx
1638; X86-NOOPT-NEXT:    subl {{[0-9]+}}(%esp), %edx
1639; X86-NOOPT-NEXT:    cmpb $1, %cl
1640; X86-NOOPT-NEXT:    sbbl %eax, %eax
1641; X86-NOOPT-NEXT:    orl %edx, %eax
1642; X86-NOOPT-NEXT:    xorl %edx, %edx
1643; X86-NOOPT-NEXT:    retl
1644;
1645; X64-LABEL: PR111325:
1646; X64:       # %bb.0: # %entry
1647; X64-NEXT:    negl %edi
1648; X64-NEXT:    testb $1, %sil
1649; X64-NEXT:    movl $4294967295, %eax # imm = 0xFFFFFFFF
1650; X64-NEXT:    cmovneq %rdi, %rax
1651; X64-NEXT:    retq
1652entry:
1653  %mul = mul i64 %a0, 4294967295
1654  %mask = and i64 %mul, 4294967295
1655  %sel = select i1 %a1, i64 %mask, i64 4294967295
1656  ret i64 %sel
1657}
1658