xref: /llvm-project/llvm/test/CodeGen/X86/mul-constant-i16.ll (revision 4196ca3278f78c6e19246e54ab0ecb364e37d66a)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i686-unknown | FileCheck %s --check-prefix=X86
3; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s --check-prefix=X64
4
5define i16 @test_mul_by_1(i16 %x) {
6; X86-LABEL: test_mul_by_1:
7; X86:       # %bb.0:
8; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
9; X86-NEXT:    retl
10;
11; X64-LABEL: test_mul_by_1:
12; X64:       # %bb.0:
13; X64-NEXT:    movl %edi, %eax
14; X64-NEXT:    # kill: def $ax killed $ax killed $eax
15; X64-NEXT:    retq
16  %mul = mul nsw i16 %x, 1
17  ret i16 %mul
18}
19
20define i16 @test_mul_by_2(i16 %x) {
21; X86-LABEL: test_mul_by_2:
22; X86:       # %bb.0:
23; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
24; X86-NEXT:    addl %eax, %eax
25; X86-NEXT:    # kill: def $ax killed $ax killed $eax
26; X86-NEXT:    retl
27;
28; X64-LABEL: test_mul_by_2:
29; X64:       # %bb.0:
30; X64-NEXT:    # kill: def $edi killed $edi def $rdi
31; X64-NEXT:    leal (%rdi,%rdi), %eax
32; X64-NEXT:    # kill: def $ax killed $ax killed $eax
33; X64-NEXT:    retq
34  %mul = mul nsw i16 %x, 2
35  ret i16 %mul
36}
37
38define i16 @test_mul_by_3(i16 %x) {
39; X86-LABEL: test_mul_by_3:
40; X86:       # %bb.0:
41; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
42; X86-NEXT:    leal (%eax,%eax,2), %eax
43; X86-NEXT:    # kill: def $ax killed $ax killed $eax
44; X86-NEXT:    retl
45;
46; X64-LABEL: test_mul_by_3:
47; X64:       # %bb.0:
48; X64-NEXT:    # kill: def $edi killed $edi def $rdi
49; X64-NEXT:    leal (%rdi,%rdi,2), %eax
50; X64-NEXT:    # kill: def $ax killed $ax killed $eax
51; X64-NEXT:    retq
52  %mul = mul nsw i16 %x, 3
53  ret i16 %mul
54}
55
56define i16 @test_mul_by_4(i16 %x) {
57; X86-LABEL: test_mul_by_4:
58; X86:       # %bb.0:
59; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
60; X86-NEXT:    shll $2, %eax
61; X86-NEXT:    # kill: def $ax killed $ax killed $eax
62; X86-NEXT:    retl
63;
64; X64-LABEL: test_mul_by_4:
65; X64:       # %bb.0:
66; X64-NEXT:    # kill: def $edi killed $edi def $rdi
67; X64-NEXT:    leal (,%rdi,4), %eax
68; X64-NEXT:    # kill: def $ax killed $ax killed $eax
69; X64-NEXT:    retq
70  %mul = mul nsw i16 %x, 4
71  ret i16 %mul
72}
73
74define i16 @test_mul_by_5(i16 %x) {
75; X86-LABEL: test_mul_by_5:
76; X86:       # %bb.0:
77; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
78; X86-NEXT:    leal (%eax,%eax,4), %eax
79; X86-NEXT:    # kill: def $ax killed $ax killed $eax
80; X86-NEXT:    retl
81;
82; X64-LABEL: test_mul_by_5:
83; X64:       # %bb.0:
84; X64-NEXT:    # kill: def $edi killed $edi def $rdi
85; X64-NEXT:    leal (%rdi,%rdi,4), %eax
86; X64-NEXT:    # kill: def $ax killed $ax killed $eax
87; X64-NEXT:    retq
88  %mul = mul nsw i16 %x, 5
89  ret i16 %mul
90}
91
92define i16 @test_mul_by_6(i16 %x) {
93; X86-LABEL: test_mul_by_6:
94; X86:       # %bb.0:
95; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
96; X86-NEXT:    addl %eax, %eax
97; X86-NEXT:    leal (%eax,%eax,2), %eax
98; X86-NEXT:    # kill: def $ax killed $ax killed $eax
99; X86-NEXT:    retl
100;
101; X64-LABEL: test_mul_by_6:
102; X64:       # %bb.0:
103; X64-NEXT:    # kill: def $edi killed $edi def $rdi
104; X64-NEXT:    addl %edi, %edi
105; X64-NEXT:    leal (%rdi,%rdi,2), %eax
106; X64-NEXT:    # kill: def $ax killed $ax killed $eax
107; X64-NEXT:    retq
108  %mul = mul nsw i16 %x, 6
109  ret i16 %mul
110}
111
112define i16 @test_mul_by_7(i16 %x) {
113; X86-LABEL: test_mul_by_7:
114; X86:       # %bb.0:
115; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
116; X86-NEXT:    leal (,%ecx,8), %eax
117; X86-NEXT:    subl %ecx, %eax
118; X86-NEXT:    # kill: def $ax killed $ax killed $eax
119; X86-NEXT:    retl
120;
121; X64-LABEL: test_mul_by_7:
122; X64:       # %bb.0:
123; X64-NEXT:    # kill: def $edi killed $edi def $rdi
124; X64-NEXT:    leal (,%rdi,8), %eax
125; X64-NEXT:    subl %edi, %eax
126; X64-NEXT:    # kill: def $ax killed $ax killed $eax
127; X64-NEXT:    retq
128  %mul = mul nsw i16 %x, 7
129  ret i16 %mul
130}
131
132define i16 @test_mul_by_8(i16 %x) {
133; X86-LABEL: test_mul_by_8:
134; X86:       # %bb.0:
135; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
136; X86-NEXT:    shll $3, %eax
137; X86-NEXT:    # kill: def $ax killed $ax killed $eax
138; X86-NEXT:    retl
139;
140; X64-LABEL: test_mul_by_8:
141; X64:       # %bb.0:
142; X64-NEXT:    # kill: def $edi killed $edi def $rdi
143; X64-NEXT:    leal (,%rdi,8), %eax
144; X64-NEXT:    # kill: def $ax killed $ax killed $eax
145; X64-NEXT:    retq
146  %mul = mul nsw i16 %x, 8
147  ret i16 %mul
148}
149
150define i16 @test_mul_by_9(i16 %x) {
151; X86-LABEL: test_mul_by_9:
152; X86:       # %bb.0:
153; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
154; X86-NEXT:    leal (%eax,%eax,8), %eax
155; X86-NEXT:    # kill: def $ax killed $ax killed $eax
156; X86-NEXT:    retl
157;
158; X64-LABEL: test_mul_by_9:
159; X64:       # %bb.0:
160; X64-NEXT:    # kill: def $edi killed $edi def $rdi
161; X64-NEXT:    leal (%rdi,%rdi,8), %eax
162; X64-NEXT:    # kill: def $ax killed $ax killed $eax
163; X64-NEXT:    retq
164  %mul = mul nsw i16 %x, 9
165  ret i16 %mul
166}
167
168define i16 @test_mul_by_10(i16 %x) {
169; X86-LABEL: test_mul_by_10:
170; X86:       # %bb.0:
171; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
172; X86-NEXT:    addl %eax, %eax
173; X86-NEXT:    leal (%eax,%eax,4), %eax
174; X86-NEXT:    # kill: def $ax killed $ax killed $eax
175; X86-NEXT:    retl
176;
177; X64-LABEL: test_mul_by_10:
178; X64:       # %bb.0:
179; X64-NEXT:    # kill: def $edi killed $edi def $rdi
180; X64-NEXT:    addl %edi, %edi
181; X64-NEXT:    leal (%rdi,%rdi,4), %eax
182; X64-NEXT:    # kill: def $ax killed $ax killed $eax
183; X64-NEXT:    retq
184  %mul = mul nsw i16 %x, 10
185  ret i16 %mul
186}
187
188define i16 @test_mul_by_11(i16 %x) {
189; X86-LABEL: test_mul_by_11:
190; X86:       # %bb.0:
191; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
192; X86-NEXT:    leal (%eax,%eax,4), %ecx
193; X86-NEXT:    leal (%eax,%ecx,2), %eax
194; X86-NEXT:    # kill: def $ax killed $ax killed $eax
195; X86-NEXT:    retl
196;
197; X64-LABEL: test_mul_by_11:
198; X64:       # %bb.0:
199; X64-NEXT:    # kill: def $edi killed $edi def $rdi
200; X64-NEXT:    leal (%rdi,%rdi,4), %eax
201; X64-NEXT:    leal (%rdi,%rax,2), %eax
202; X64-NEXT:    # kill: def $ax killed $ax killed $eax
203; X64-NEXT:    retq
204  %mul = mul nsw i16 %x, 11
205  ret i16 %mul
206}
207
208define i16 @test_mul_by_12(i16 %x) {
209; X86-LABEL: test_mul_by_12:
210; X86:       # %bb.0:
211; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
212; X86-NEXT:    shll $2, %eax
213; X86-NEXT:    leal (%eax,%eax,2), %eax
214; X86-NEXT:    # kill: def $ax killed $ax killed $eax
215; X86-NEXT:    retl
216;
217; X64-LABEL: test_mul_by_12:
218; X64:       # %bb.0:
219; X64-NEXT:    # kill: def $edi killed $edi def $rdi
220; X64-NEXT:    shll $2, %edi
221; X64-NEXT:    leal (%rdi,%rdi,2), %eax
222; X64-NEXT:    # kill: def $ax killed $ax killed $eax
223; X64-NEXT:    retq
224  %mul = mul nsw i16 %x, 12
225  ret i16 %mul
226}
227
228define i16 @test_mul_by_13(i16 %x) {
229; X86-LABEL: test_mul_by_13:
230; X86:       # %bb.0:
231; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
232; X86-NEXT:    leal (%eax,%eax,2), %ecx
233; X86-NEXT:    leal (%eax,%ecx,4), %eax
234; X86-NEXT:    # kill: def $ax killed $ax killed $eax
235; X86-NEXT:    retl
236;
237; X64-LABEL: test_mul_by_13:
238; X64:       # %bb.0:
239; X64-NEXT:    # kill: def $edi killed $edi def $rdi
240; X64-NEXT:    leal (%rdi,%rdi,2), %eax
241; X64-NEXT:    leal (%rdi,%rax,4), %eax
242; X64-NEXT:    # kill: def $ax killed $ax killed $eax
243; X64-NEXT:    retq
244  %mul = mul nsw i16 %x, 13
245  ret i16 %mul
246}
247
248define i16 @test_mul_by_14(i16 %x) {
249; X86-LABEL: test_mul_by_14:
250; X86:       # %bb.0:
251; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
252; X86-NEXT:    leal (%eax,%eax), %ecx
253; X86-NEXT:    shll $4, %eax
254; X86-NEXT:    subl %ecx, %eax
255; X86-NEXT:    # kill: def $ax killed $ax killed $eax
256; X86-NEXT:    retl
257;
258; X64-LABEL: test_mul_by_14:
259; X64:       # %bb.0:
260; X64-NEXT:    movl %edi, %eax
261; X64-NEXT:    leal (%rax,%rax), %ecx
262; X64-NEXT:    shll $4, %eax
263; X64-NEXT:    subl %ecx, %eax
264; X64-NEXT:    # kill: def $ax killed $ax killed $rax
265; X64-NEXT:    retq
266  %mul = mul nsw i16 %x, 14
267  ret i16 %mul
268}
269
270define i16 @test_mul_by_15(i16 %x) {
271; X86-LABEL: test_mul_by_15:
272; X86:       # %bb.0:
273; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
274; X86-NEXT:    leal (%eax,%eax,4), %eax
275; X86-NEXT:    leal (%eax,%eax,2), %eax
276; X86-NEXT:    # kill: def $ax killed $ax killed $eax
277; X86-NEXT:    retl
278;
279; X64-LABEL: test_mul_by_15:
280; X64:       # %bb.0:
281; X64-NEXT:    # kill: def $edi killed $edi def $rdi
282; X64-NEXT:    leal (%rdi,%rdi,4), %eax
283; X64-NEXT:    leal (%rax,%rax,2), %eax
284; X64-NEXT:    # kill: def $ax killed $ax killed $eax
285; X64-NEXT:    retq
286  %mul = mul nsw i16 %x, 15
287  ret i16 %mul
288}
289
290define i16 @test_mul_by_16(i16 %x) {
291; X86-LABEL: test_mul_by_16:
292; X86:       # %bb.0:
293; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
294; X86-NEXT:    shll $4, %eax
295; X86-NEXT:    # kill: def $ax killed $ax killed $eax
296; X86-NEXT:    retl
297;
298; X64-LABEL: test_mul_by_16:
299; X64:       # %bb.0:
300; X64-NEXT:    movl %edi, %eax
301; X64-NEXT:    shll $4, %eax
302; X64-NEXT:    # kill: def $ax killed $ax killed $eax
303; X64-NEXT:    retq
304  %mul = mul nsw i16 %x, 16
305  ret i16 %mul
306}
307
308define i16 @test_mul_by_17(i16 %x) {
309; X86-LABEL: test_mul_by_17:
310; X86:       # %bb.0:
311; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
312; X86-NEXT:    movl %ecx, %eax
313; X86-NEXT:    shll $4, %eax
314; X86-NEXT:    addl %ecx, %eax
315; X86-NEXT:    # kill: def $ax killed $ax killed $eax
316; X86-NEXT:    retl
317;
318; X64-LABEL: test_mul_by_17:
319; X64:       # %bb.0:
320; X64-NEXT:    movl %edi, %eax
321; X64-NEXT:    shll $4, %eax
322; X64-NEXT:    addl %edi, %eax
323; X64-NEXT:    # kill: def $ax killed $ax killed $eax
324; X64-NEXT:    retq
325  %mul = mul nsw i16 %x, 17
326  ret i16 %mul
327}
328
329define i16 @test_mul_by_18(i16 %x) {
330; X86-LABEL: test_mul_by_18:
331; X86:       # %bb.0:
332; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
333; X86-NEXT:    addl %eax, %eax
334; X86-NEXT:    leal (%eax,%eax,8), %eax
335; X86-NEXT:    # kill: def $ax killed $ax killed $eax
336; X86-NEXT:    retl
337;
338; X64-LABEL: test_mul_by_18:
339; X64:       # %bb.0:
340; X64-NEXT:    # kill: def $edi killed $edi def $rdi
341; X64-NEXT:    addl %edi, %edi
342; X64-NEXT:    leal (%rdi,%rdi,8), %eax
343; X64-NEXT:    # kill: def $ax killed $ax killed $eax
344; X64-NEXT:    retq
345  %mul = mul nsw i16 %x, 18
346  ret i16 %mul
347}
348
349define i16 @test_mul_by_19(i16 %x) {
350; X86-LABEL: test_mul_by_19:
351; X86:       # %bb.0:
352; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
353; X86-NEXT:    leal (%eax,%eax,8), %ecx
354; X86-NEXT:    leal (%eax,%ecx,2), %eax
355; X86-NEXT:    # kill: def $ax killed $ax killed $eax
356; X86-NEXT:    retl
357;
358; X64-LABEL: test_mul_by_19:
359; X64:       # %bb.0:
360; X64-NEXT:    # kill: def $edi killed $edi def $rdi
361; X64-NEXT:    leal (%rdi,%rdi,8), %eax
362; X64-NEXT:    leal (%rdi,%rax,2), %eax
363; X64-NEXT:    # kill: def $ax killed $ax killed $eax
364; X64-NEXT:    retq
365  %mul = mul nsw i16 %x, 19
366  ret i16 %mul
367}
368
369define i16 @test_mul_by_20(i16 %x) {
370; X86-LABEL: test_mul_by_20:
371; X86:       # %bb.0:
372; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
373; X86-NEXT:    shll $2, %eax
374; X86-NEXT:    leal (%eax,%eax,4), %eax
375; X86-NEXT:    # kill: def $ax killed $ax killed $eax
376; X86-NEXT:    retl
377;
378; X64-LABEL: test_mul_by_20:
379; X64:       # %bb.0:
380; X64-NEXT:    # kill: def $edi killed $edi def $rdi
381; X64-NEXT:    shll $2, %edi
382; X64-NEXT:    leal (%rdi,%rdi,4), %eax
383; X64-NEXT:    # kill: def $ax killed $ax killed $eax
384; X64-NEXT:    retq
385  %mul = mul nsw i16 %x, 20
386  ret i16 %mul
387}
388
389define i16 @test_mul_by_21(i16 %x) {
390; X86-LABEL: test_mul_by_21:
391; X86:       # %bb.0:
392; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
393; X86-NEXT:    leal (%eax,%eax,4), %ecx
394; X86-NEXT:    leal (%eax,%ecx,4), %eax
395; X86-NEXT:    # kill: def $ax killed $ax killed $eax
396; X86-NEXT:    retl
397;
398; X64-LABEL: test_mul_by_21:
399; X64:       # %bb.0:
400; X64-NEXT:    # kill: def $edi killed $edi def $rdi
401; X64-NEXT:    leal (%rdi,%rdi,4), %eax
402; X64-NEXT:    leal (%rdi,%rax,4), %eax
403; X64-NEXT:    # kill: def $ax killed $ax killed $eax
404; X64-NEXT:    retq
405  %mul = mul nsw i16 %x, 21
406  ret i16 %mul
407}
408
409define i16 @test_mul_by_22(i16 %x) {
410; X86-LABEL: test_mul_by_22:
411; X86:       # %bb.0:
412; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
413; X86-NEXT:    leal (%ecx,%ecx,4), %eax
414; X86-NEXT:    leal (%ecx,%eax,4), %eax
415; X86-NEXT:    addl %ecx, %eax
416; X86-NEXT:    # kill: def $ax killed $ax killed $eax
417; X86-NEXT:    retl
418;
419; X64-LABEL: test_mul_by_22:
420; X64:       # %bb.0:
421; X64-NEXT:    # kill: def $edi killed $edi def $rdi
422; X64-NEXT:    leal (%rdi,%rdi,4), %eax
423; X64-NEXT:    leal (%rdi,%rax,4), %eax
424; X64-NEXT:    addl %edi, %eax
425; X64-NEXT:    # kill: def $ax killed $ax killed $eax
426; X64-NEXT:    retq
427  %mul = mul nsw i16 %x, 22
428  ret i16 %mul
429}
430
431define i16 @test_mul_by_23(i16 %x) {
432; X86-LABEL: test_mul_by_23:
433; X86:       # %bb.0:
434; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
435; X86-NEXT:    leal (%ecx,%ecx,2), %eax
436; X86-NEXT:    shll $3, %eax
437; X86-NEXT:    subl %ecx, %eax
438; X86-NEXT:    # kill: def $ax killed $ax killed $eax
439; X86-NEXT:    retl
440;
441; X64-LABEL: test_mul_by_23:
442; X64:       # %bb.0:
443; X64-NEXT:    # kill: def $edi killed $edi def $rdi
444; X64-NEXT:    leal (%rdi,%rdi,2), %eax
445; X64-NEXT:    shll $3, %eax
446; X64-NEXT:    subl %edi, %eax
447; X64-NEXT:    # kill: def $ax killed $ax killed $eax
448; X64-NEXT:    retq
449  %mul = mul nsw i16 %x, 23
450  ret i16 %mul
451}
452
453define i16 @test_mul_by_24(i16 %x) {
454; X86-LABEL: test_mul_by_24:
455; X86:       # %bb.0:
456; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
457; X86-NEXT:    shll $3, %eax
458; X86-NEXT:    leal (%eax,%eax,2), %eax
459; X86-NEXT:    # kill: def $ax killed $ax killed $eax
460; X86-NEXT:    retl
461;
462; X64-LABEL: test_mul_by_24:
463; X64:       # %bb.0:
464; X64-NEXT:    # kill: def $edi killed $edi def $rdi
465; X64-NEXT:    shll $3, %edi
466; X64-NEXT:    leal (%rdi,%rdi,2), %eax
467; X64-NEXT:    # kill: def $ax killed $ax killed $eax
468; X64-NEXT:    retq
469  %mul = mul nsw i16 %x, 24
470  ret i16 %mul
471}
472
473define i16 @test_mul_by_25(i16 %x) {
474; X86-LABEL: test_mul_by_25:
475; X86:       # %bb.0:
476; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
477; X86-NEXT:    leal (%eax,%eax,4), %eax
478; X86-NEXT:    leal (%eax,%eax,4), %eax
479; X86-NEXT:    # kill: def $ax killed $ax killed $eax
480; X86-NEXT:    retl
481;
482; X64-LABEL: test_mul_by_25:
483; X64:       # %bb.0:
484; X64-NEXT:    # kill: def $edi killed $edi def $rdi
485; X64-NEXT:    leal (%rdi,%rdi,4), %eax
486; X64-NEXT:    leal (%rax,%rax,4), %eax
487; X64-NEXT:    # kill: def $ax killed $ax killed $eax
488; X64-NEXT:    retq
489  %mul = mul nsw i16 %x, 25
490  ret i16 %mul
491}
492
493define i16 @test_mul_by_26(i16 %x) {
494; X86-LABEL: test_mul_by_26:
495; X86:       # %bb.0:
496; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
497; X86-NEXT:    leal (%ecx,%ecx,4), %eax
498; X86-NEXT:    leal (%eax,%eax,4), %eax
499; X86-NEXT:    addl %ecx, %eax
500; X86-NEXT:    # kill: def $ax killed $ax killed $eax
501; X86-NEXT:    retl
502;
503; X64-LABEL: test_mul_by_26:
504; X64:       # %bb.0:
505; X64-NEXT:    # kill: def $edi killed $edi def $rdi
506; X64-NEXT:    leal (%rdi,%rdi,4), %eax
507; X64-NEXT:    leal (%rax,%rax,4), %eax
508; X64-NEXT:    addl %edi, %eax
509; X64-NEXT:    # kill: def $ax killed $ax killed $eax
510; X64-NEXT:    retq
511  %mul = mul nsw i16 %x, 26
512  ret i16 %mul
513}
514
515define i16 @test_mul_by_27(i16 %x) {
516; X86-LABEL: test_mul_by_27:
517; X86:       # %bb.0:
518; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
519; X86-NEXT:    leal (%eax,%eax,8), %eax
520; X86-NEXT:    leal (%eax,%eax,2), %eax
521; X86-NEXT:    # kill: def $ax killed $ax killed $eax
522; X86-NEXT:    retl
523;
524; X64-LABEL: test_mul_by_27:
525; X64:       # %bb.0:
526; X64-NEXT:    # kill: def $edi killed $edi def $rdi
527; X64-NEXT:    leal (%rdi,%rdi,8), %eax
528; X64-NEXT:    leal (%rax,%rax,2), %eax
529; X64-NEXT:    # kill: def $ax killed $ax killed $eax
530; X64-NEXT:    retq
531  %mul = mul nsw i16 %x, 27
532  ret i16 %mul
533}
534
535define i16 @test_mul_by_28(i16 %x) {
536; X86-LABEL: test_mul_by_28:
537; X86:       # %bb.0:
538; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
539; X86-NEXT:    leal (%ecx,%ecx,8), %eax
540; X86-NEXT:    leal (%eax,%eax,2), %eax
541; X86-NEXT:    addl %ecx, %eax
542; X86-NEXT:    # kill: def $ax killed $ax killed $eax
543; X86-NEXT:    retl
544;
545; X64-LABEL: test_mul_by_28:
546; X64:       # %bb.0:
547; X64-NEXT:    # kill: def $edi killed $edi def $rdi
548; X64-NEXT:    leal (%rdi,%rdi,8), %eax
549; X64-NEXT:    leal (%rax,%rax,2), %eax
550; X64-NEXT:    addl %edi, %eax
551; X64-NEXT:    # kill: def $ax killed $ax killed $eax
552; X64-NEXT:    retq
553  %mul = mul nsw i16 %x, 28
554  ret i16 %mul
555}
556
557define i16 @test_mul_by_29(i16 %x) {
558; X86-LABEL: test_mul_by_29:
559; X86:       # %bb.0:
560; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
561; X86-NEXT:    leal (%eax,%eax,8), %ecx
562; X86-NEXT:    leal (%ecx,%ecx,2), %ecx
563; X86-NEXT:    addl %eax, %eax
564; X86-NEXT:    addl %ecx, %eax
565; X86-NEXT:    # kill: def $ax killed $ax killed $eax
566; X86-NEXT:    retl
567;
568; X64-LABEL: test_mul_by_29:
569; X64:       # %bb.0:
570; X64-NEXT:    # kill: def $edi killed $edi def $rdi
571; X64-NEXT:    leal (%rdi,%rdi,8), %eax
572; X64-NEXT:    leal (%rax,%rax,2), %eax
573; X64-NEXT:    addl %edi, %eax
574; X64-NEXT:    addl %edi, %eax
575; X64-NEXT:    # kill: def $ax killed $ax killed $eax
576; X64-NEXT:    retq
577  %mul = mul nsw i16 %x, 29
578  ret i16 %mul
579}
580
581define i16 @test_mul_by_30(i16 %x) {
582; X86-LABEL: test_mul_by_30:
583; X86:       # %bb.0:
584; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
585; X86-NEXT:    leal (%eax,%eax), %ecx
586; X86-NEXT:    shll $5, %eax
587; X86-NEXT:    subl %ecx, %eax
588; X86-NEXT:    # kill: def $ax killed $ax killed $eax
589; X86-NEXT:    retl
590;
591; X64-LABEL: test_mul_by_30:
592; X64:       # %bb.0:
593; X64-NEXT:    movl %edi, %eax
594; X64-NEXT:    leal (%rax,%rax), %ecx
595; X64-NEXT:    shll $5, %eax
596; X64-NEXT:    subl %ecx, %eax
597; X64-NEXT:    # kill: def $ax killed $ax killed $rax
598; X64-NEXT:    retq
599  %mul = mul nsw i16 %x, 30
600  ret i16 %mul
601}
602
603define i16 @test_mul_by_31(i16 %x) {
604; X86-LABEL: test_mul_by_31:
605; X86:       # %bb.0:
606; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
607; X86-NEXT:    movl %ecx, %eax
608; X86-NEXT:    shll $5, %eax
609; X86-NEXT:    subl %ecx, %eax
610; X86-NEXT:    # kill: def $ax killed $ax killed $eax
611; X86-NEXT:    retl
612;
613; X64-LABEL: test_mul_by_31:
614; X64:       # %bb.0:
615; X64-NEXT:    movl %edi, %eax
616; X64-NEXT:    shll $5, %eax
617; X64-NEXT:    subl %edi, %eax
618; X64-NEXT:    # kill: def $ax killed $ax killed $eax
619; X64-NEXT:    retq
620  %mul = mul nsw i16 %x, 31
621  ret i16 %mul
622}
623
624define i16 @test_mul_by_32(i16 %x) {
625; X86-LABEL: test_mul_by_32:
626; X86:       # %bb.0:
627; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
628; X86-NEXT:    shll $5, %eax
629; X86-NEXT:    # kill: def $ax killed $ax killed $eax
630; X86-NEXT:    retl
631;
632; X64-LABEL: test_mul_by_32:
633; X64:       # %bb.0:
634; X64-NEXT:    movl %edi, %eax
635; X64-NEXT:    shll $5, %eax
636; X64-NEXT:    # kill: def $ax killed $ax killed $eax
637; X64-NEXT:    retq
638  %mul = mul nsw i16 %x, 32
639  ret i16 %mul
640}
641
642define i16 @test_mul_by_37(i16 %x) {
643; X86-LABEL: test_mul_by_37:
644; X86:       # %bb.0:
645; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
646; X86-NEXT:    leal (%eax,%eax,8), %ecx
647; X86-NEXT:    leal (%eax,%ecx,4), %eax
648; X86-NEXT:    # kill: def $ax killed $ax killed $eax
649; X86-NEXT:    retl
650;
651; X64-LABEL: test_mul_by_37:
652; X64:       # %bb.0:
653; X64-NEXT:    # kill: def $edi killed $edi def $rdi
654; X64-NEXT:    leal (%rdi,%rdi,8), %eax
655; X64-NEXT:    leal (%rdi,%rax,4), %eax
656; X64-NEXT:    # kill: def $ax killed $ax killed $eax
657; X64-NEXT:    retq
658  %mul = mul nsw i16 %x, 37
659  ret i16 %mul
660}
661
662define i16 @test_mul_by_41(i16 %x) {
663; X86-LABEL: test_mul_by_41:
664; X86:       # %bb.0:
665; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
666; X86-NEXT:    leal (%eax,%eax,4), %ecx
667; X86-NEXT:    leal (%eax,%ecx,8), %eax
668; X86-NEXT:    # kill: def $ax killed $ax killed $eax
669; X86-NEXT:    retl
670;
671; X64-LABEL: test_mul_by_41:
672; X64:       # %bb.0:
673; X64-NEXT:    # kill: def $edi killed $edi def $rdi
674; X64-NEXT:    leal (%rdi,%rdi,4), %eax
675; X64-NEXT:    leal (%rdi,%rax,8), %eax
676; X64-NEXT:    # kill: def $ax killed $ax killed $eax
677; X64-NEXT:    retq
678  %mul = mul nsw i16 %x, 41
679  ret i16 %mul
680}
681
682define i16 @test_mul_by_62(i16 %x) {
683; X86-LABEL: test_mul_by_62:
684; X86:       # %bb.0:
685; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
686; X86-NEXT:    leal (%eax,%eax), %ecx
687; X86-NEXT:    shll $6, %eax
688; X86-NEXT:    subl %ecx, %eax
689; X86-NEXT:    # kill: def $ax killed $ax killed $eax
690; X86-NEXT:    retl
691;
692; X64-LABEL: test_mul_by_62:
693; X64:       # %bb.0:
694; X64-NEXT:    movl %edi, %eax
695; X64-NEXT:    leal (%rax,%rax), %ecx
696; X64-NEXT:    shll $6, %eax
697; X64-NEXT:    subl %ecx, %eax
698; X64-NEXT:    # kill: def $ax killed $ax killed $rax
699; X64-NEXT:    retq
700  %mul = mul nsw i16 %x, 62
701  ret i16 %mul
702}
703
704define i16 @test_mul_by_66(i16 %x) {
705; X86-LABEL: test_mul_by_66:
706; X86:       # %bb.0:
707; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
708; X86-NEXT:    movl %eax, %ecx
709; X86-NEXT:    shll $6, %ecx
710; X86-NEXT:    leal (%ecx,%eax,2), %eax
711; X86-NEXT:    # kill: def $ax killed $ax killed $eax
712; X86-NEXT:    retl
713;
714; X64-LABEL: test_mul_by_66:
715; X64:       # %bb.0:
716; X64-NEXT:    # kill: def $edi killed $edi def $rdi
717; X64-NEXT:    movl %edi, %eax
718; X64-NEXT:    shll $6, %eax
719; X64-NEXT:    leal (%rax,%rdi,2), %eax
720; X64-NEXT:    # kill: def $ax killed $ax killed $eax
721; X64-NEXT:    retq
722  %mul = mul nsw i16 %x, 66
723  ret i16 %mul
724}
725
726define i16 @test_mul_by_73(i16 %x) {
727; X86-LABEL: test_mul_by_73:
728; X86:       # %bb.0:
729; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
730; X86-NEXT:    leal (%eax,%eax,8), %ecx
731; X86-NEXT:    leal (%eax,%ecx,8), %eax
732; X86-NEXT:    # kill: def $ax killed $ax killed $eax
733; X86-NEXT:    retl
734;
735; X64-LABEL: test_mul_by_73:
736; X64:       # %bb.0:
737; X64-NEXT:    # kill: def $edi killed $edi def $rdi
738; X64-NEXT:    leal (%rdi,%rdi,8), %eax
739; X64-NEXT:    leal (%rdi,%rax,8), %eax
740; X64-NEXT:    # kill: def $ax killed $ax killed $eax
741; X64-NEXT:    retq
742  %mul = mul nsw i16 %x, 73
743  ret i16 %mul
744}
745
746define i16 @test_mul_by_520(i16 %x) {
747; X86-LABEL: test_mul_by_520:
748; X86:       # %bb.0:
749; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
750; X86-NEXT:    movl %eax, %ecx
751; X86-NEXT:    shll $9, %ecx
752; X86-NEXT:    leal (%ecx,%eax,8), %eax
753; X86-NEXT:    # kill: def $ax killed $ax killed $eax
754; X86-NEXT:    retl
755;
756; X64-LABEL: test_mul_by_520:
757; X64:       # %bb.0:
758; X64-NEXT:    # kill: def $edi killed $edi def $rdi
759; X64-NEXT:    movl %edi, %eax
760; X64-NEXT:    shll $9, %eax
761; X64-NEXT:    leal (%rax,%rdi,8), %eax
762; X64-NEXT:    # kill: def $ax killed $ax killed $eax
763; X64-NEXT:    retq
764  %mul = mul nsw i16 %x, 520
765  ret i16 %mul
766}
767
768define i16 @test_mul_by_neg10(i16 %x) {
769; X86-LABEL: test_mul_by_neg10:
770; X86:       # %bb.0:
771; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
772; X86-NEXT:    addl %eax, %eax
773; X86-NEXT:    leal (%eax,%eax,4), %eax
774; X86-NEXT:    negl %eax
775; X86-NEXT:    # kill: def $ax killed $ax killed $eax
776; X86-NEXT:    retl
777;
778; X64-LABEL: test_mul_by_neg10:
779; X64:       # %bb.0:
780; X64-NEXT:    # kill: def $edi killed $edi def $rdi
781; X64-NEXT:    addl %edi, %edi
782; X64-NEXT:    leal (%rdi,%rdi,4), %eax
783; X64-NEXT:    negl %eax
784; X64-NEXT:    # kill: def $ax killed $ax killed $eax
785; X64-NEXT:    retq
786  %mul = mul nsw i16 %x, -10
787  ret i16 %mul
788}
789
790define i16 @test_mul_by_neg36(i16 %x) {
791; X86-LABEL: test_mul_by_neg36:
792; X86:       # %bb.0:
793; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
794; X86-NEXT:    shll $2, %eax
795; X86-NEXT:    leal (%eax,%eax,8), %eax
796; X86-NEXT:    negl %eax
797; X86-NEXT:    # kill: def $ax killed $ax killed $eax
798; X86-NEXT:    retl
799;
800; X64-LABEL: test_mul_by_neg36:
801; X64:       # %bb.0:
802; X64-NEXT:    # kill: def $edi killed $edi def $rdi
803; X64-NEXT:    shll $2, %edi
804; X64-NEXT:    leal (%rdi,%rdi,8), %eax
805; X64-NEXT:    negl %eax
806; X64-NEXT:    # kill: def $ax killed $ax killed $eax
807; X64-NEXT:    retq
808  %mul = mul nsw i16 %x, -36
809  ret i16 %mul
810}
811
812; (x*9+42)*(x*5+2)
813define i16 @test_mul_spec(i16 %x) nounwind {
814; X86-LABEL: test_mul_spec:
815; X86:       # %bb.0:
816; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
817; X86-NEXT:    leal 42(%eax,%eax,8), %ecx
818; X86-NEXT:    leal 2(%eax,%eax,4), %eax
819; X86-NEXT:    imull %ecx, %eax
820; X86-NEXT:    # kill: def $ax killed $ax killed $eax
821; X86-NEXT:    retl
822;
823; X64-LABEL: test_mul_spec:
824; X64:       # %bb.0:
825; X64-NEXT:    # kill: def $edi killed $edi def $rdi
826; X64-NEXT:    leal 42(%rdi,%rdi,8), %ecx
827; X64-NEXT:    leal 2(%rdi,%rdi,4), %eax
828; X64-NEXT:    imull %ecx, %eax
829; X64-NEXT:    # kill: def $ax killed $ax killed $eax
830; X64-NEXT:    retq
831  %mul = mul nsw i16 %x, 9
832  %add = add nsw i16 %mul, 42
833  %mul2 = mul nsw i16 %x, 5
834  %add2 = add nsw i16 %mul2, 2
835  %mul3 = mul nsw i16 %add, %add2
836  ret i16 %mul3
837}
838