1; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu | FileCheck %s --check-prefix=X64
2; RUN: llc < %s -mtriple=x86_64-pc-linux-gnux32 | FileCheck %s --check-prefix=X64
3; RUN: llc < %s -mtriple=i686-pc-linux | FileCheck %s --check-prefix=X86
4
5define i32 @mul4_32(i32 %A) {
6; X64-LABEL: mul4_32:
7; X64: leal
8; X86-LABEL: mul4_32:
9; X86: shll
10    %mul = mul i32 %A, 4
11    ret i32 %mul
12}
13
14define i64 @mul4_64(i64 %A) {
15; X64-LABEL: mul4_64:
16; X64: leaq
17; X86-LABEL: mul4_64:
18; X86: shldl
19; X86: shll
20    %mul = mul i64 %A, 4
21    ret i64 %mul
22}
23
24define i32 @mul4096_32(i32 %A) {
25; X64-LABEL: mul4096_32:
26; X64: shll
27; X86-LABEL: mul4096_32:
28; X86: shll
29    %mul = mul i32 %A, 4096
30    ret i32 %mul
31}
32
33define i64 @mul4096_64(i64 %A) {
34; X64-LABEL: mul4096_64:
35; X64: shlq
36; X86-LABEL: mul4096_64:
37; X86: shldl
38; X86: shll
39    %mul = mul i64 %A, 4096
40    ret i64 %mul
41}
42
43define i32 @mulmin4096_32(i32 %A) {
44; X64-LABEL: mulmin4096_32:
45; X64: shll
46; X64-NEXT: negl
47; X86-LABEL: mulmin4096_32:
48; X86: shll
49; X86-NEXT: negl
50    %mul = mul i32 %A, -4096
51    ret i32 %mul
52}
53
54define i64 @mulmin4096_64(i64 %A) {
55; X64-LABEL: mulmin4096_64:
56; X64: shlq
57; X64-NEXT: negq
58; X86-LABEL: mulmin4096_64:
59; X86: shldl
60; X86-NEXT: shll
61; X86-NEXT: xorl
62; X86-NEXT: negl
63; X86-NEXT: sbbl
64    %mul = mul i64 %A, -4096
65    ret i64 %mul
66}
67
68define i32 @mul3_32(i32 %A) {
69; X64-LABEL: mul3_32:
70; X64: leal
71; X86-LABEL: mul3_32:
72; But why?!
73; X86: imull
74    %mul = mul i32 %A, 3
75    ret i32 %mul
76}
77
78define i64 @mul3_64(i64 %A) {
79; X64-LABEL: mul3_64:
80; X64: leaq
81; X86-LABEL: mul3_64:
82; X86: mull
83; X86-NEXT: imull
84    %mul = mul i64 %A, 3
85    ret i64 %mul
86}
87
88define i32 @mul40_32(i32 %A) {
89; X64-LABEL: mul40_32:
90; X64: shll
91; X64-NEXT: leal
92; X86-LABEL: mul40_32:
93; X86: shll
94; X86-NEXT: leal
95    %mul = mul i32 %A, 40
96    ret i32 %mul
97}
98
99define i64 @mul40_64(i64 %A) {
100; X64-LABEL: mul40_64:
101; X64: shlq
102; X64-NEXT: leaq
103; X86-LABEL: mul40_64:
104; X86: leal
105; X86-NEXT: movl
106; X86-NEXT: mull
107; X86-NEXT: leal
108    %mul = mul i64 %A, 40
109    ret i64 %mul
110}
111