1; RUN: llc < %s -mtriple=ve-unknown-unknown | FileCheck %s
2
3define signext i8 @func8s(i8 signext %a, i8 signext %b) {
4; CHECK-LABEL: func8s:
5; CHECK:       # %bb.0:
6; CHECK-NEXT:    muls.w.sx %s0, %s1, %s0
7; CHECK-NEXT:    sll %s0, %s0, 56
8; CHECK-NEXT:    sra.l %s0, %s0, 56
9; CHECK-NEXT:    b.l.t (, %s10)
10  %r = mul i8 %b, %a
11  ret i8 %r
12}
13
14define signext i16 @func16s(i16 signext %a, i16 signext %b) {
15; CHECK-LABEL: func16s:
16; CHECK:       # %bb.0:
17; CHECK-NEXT:    muls.w.sx %s0, %s1, %s0
18; CHECK-NEXT:    sll %s0, %s0, 48
19; CHECK-NEXT:    sra.l %s0, %s0, 48
20; CHECK-NEXT:    b.l.t (, %s10)
21  %r = mul i16 %b, %a
22  ret i16 %r
23}
24
25define signext i32 @func32s(i32 signext %a, i32 signext %b) {
26; CHECK-LABEL: func32s:
27; CHECK:       # %bb.0:
28; CHECK-NEXT:    muls.w.sx %s0, %s1, %s0
29; CHECK-NEXT:    adds.w.sx %s0, %s0, (0)1
30; CHECK-NEXT:    b.l.t (, %s10)
31  %r = mul nsw i32 %b, %a
32  ret i32 %r
33}
34
35define i64 @func64(i64 %a, i64 %b) {
36; CHECK-LABEL: func64:
37; CHECK:       # %bb.0:
38; CHECK-NEXT:    muls.l %s0, %s1, %s0
39; CHECK-NEXT:    b.l.t (, %s10)
40  %r = mul nsw i64 %b, %a
41  ret i64 %r
42}
43
44define i128 @func128(i128 %a, i128 %b) {
45; CHECK-LABEL: func128:
46; CHECK:       .LBB{{[0-9]+}}_2:
47; CHECK-NEXT:    or %s4, 0, %s1
48; CHECK-NEXT:    or %s5, 0, %s0
49; CHECK-NEXT:    lea %s0, __multi3@lo
50; CHECK-NEXT:    and %s0, %s0, (32)0
51; CHECK-NEXT:    lea.sl %s12, __multi3@hi(, %s0)
52; CHECK-NEXT:    or %s0, 0, %s2
53; CHECK-NEXT:    or %s1, 0, %s3
54; CHECK-NEXT:    or %s2, 0, %s5
55; CHECK-NEXT:    or %s3, 0, %s4
56; CHECK-NEXT:    bsic %s10, (, %s12)
57; CHECK-NEXT:    or %s11, 0, %s9
58  %r = mul nsw i128 %b, %a
59  ret i128 %r
60}
61
62define zeroext i8 @func8z(i8 zeroext %a, i8 zeroext %b) {
63; CHECK-LABEL: func8z:
64; CHECK:       # %bb.0:
65; CHECK-NEXT:    muls.w.sx %s0, %s1, %s0
66; CHECK-NEXT:    and %s0, %s0, (56)0
67; CHECK-NEXT:    b.l.t (, %s10)
68  %r = mul i8 %b, %a
69  ret i8 %r
70}
71
72define zeroext i16 @func16z(i16 zeroext %a, i16 zeroext %b) {
73; CHECK-LABEL: func16z:
74; CHECK:       # %bb.0:
75; CHECK-NEXT:    muls.w.sx %s0, %s1, %s0
76; CHECK-NEXT:    and %s0, %s0, (48)0
77; CHECK-NEXT:    b.l.t (, %s10)
78  %r = mul i16 %b, %a
79  ret i16 %r
80}
81
82define zeroext i32 @func32z(i32 zeroext %a, i32 zeroext %b) {
83; CHECK-LABEL: func32z:
84; CHECK:       # %bb.0:
85; CHECK-NEXT:    muls.w.sx %s0, %s1, %s0
86; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
87; CHECK-NEXT:    b.l.t (, %s10)
88  %r = mul i32 %b, %a
89  ret i32 %r
90}
91
92define i64 @func64z(i64 %a, i64 %b) {
93; CHECK-LABEL: func64z:
94; CHECK:       # %bb.0:
95; CHECK-NEXT:    muls.l %s0, %s1, %s0
96; CHECK-NEXT:    b.l.t (, %s10)
97  %r = mul i64 %b, %a
98  ret i64 %r
99}
100
101define i128 @func128z(i128 %a, i128 %b) {
102; CHECK-LABEL: func128z:
103; CHECK:       .LBB{{[0-9]+}}_2:
104; CHECK-NEXT:    or %s4, 0, %s1
105; CHECK-NEXT:    or %s5, 0, %s0
106; CHECK-NEXT:    lea %s0, __multi3@lo
107; CHECK-NEXT:    and %s0, %s0, (32)0
108; CHECK-NEXT:    lea.sl %s12, __multi3@hi(, %s0)
109; CHECK-NEXT:    or %s0, 0, %s2
110; CHECK-NEXT:    or %s1, 0, %s3
111; CHECK-NEXT:    or %s2, 0, %s5
112; CHECK-NEXT:    or %s3, 0, %s4
113; CHECK-NEXT:    bsic %s10, (, %s12)
114; CHECK-NEXT:    or %s11, 0, %s9
115  %r = mul i128 %b, %a
116  ret i128 %r
117}
118
119define signext i8 @funci8s(i8 signext %a) {
120; CHECK-LABEL: funci8s:
121; CHECK:       # %bb.0:
122; CHECK-NEXT:    muls.w.sx %s0, 5, %s0
123; CHECK-NEXT:    sll %s0, %s0, 56
124; CHECK-NEXT:    sra.l %s0, %s0, 56
125; CHECK-NEXT:    b.l.t (, %s10)
126  %r = mul i8 %a, 5
127  ret i8 %r
128}
129
130define signext i16 @funci16s(i16 signext %a) {
131; CHECK-LABEL: funci16s:
132; CHECK:       # %bb.0:
133; CHECK-NEXT:    muls.w.sx %s0, 5, %s0
134; CHECK-NEXT:    sll %s0, %s0, 48
135; CHECK-NEXT:    sra.l %s0, %s0, 48
136; CHECK-NEXT:    b.l.t (, %s10)
137  %r = mul i16 %a, 5
138  ret i16 %r
139}
140
141define signext i32 @funci32s(i32 signext %a) {
142; CHECK-LABEL: funci32s:
143; CHECK:       # %bb.0:
144; CHECK-NEXT:    muls.w.sx %s0, 5, %s0
145; CHECK-NEXT:    adds.w.sx %s0, %s0, (0)1
146; CHECK-NEXT:    b.l.t (, %s10)
147  %r = mul nsw i32 %a, 5
148  ret i32 %r
149}
150
151define i64 @funci64(i64 %a) {
152; CHECK-LABEL: funci64:
153; CHECK:       # %bb.0:
154; CHECK-NEXT:    muls.l %s0, 5, %s0
155; CHECK-NEXT:    b.l.t (, %s10)
156  %r = mul nsw i64 %a, 5
157  ret i64 %r
158}
159
160define i128 @funci128(i128 %a) {
161; CHECK-LABEL: funci128:
162; CHECK:       .LBB{{[0-9]+}}_2:
163; CHECK-NEXT:    lea %s2, __multi3@lo
164; CHECK-NEXT:    and %s2, %s2, (32)0
165; CHECK-NEXT:    lea.sl %s12, __multi3@hi(, %s2)
166; CHECK-NEXT:    or %s2, 5, (0)1
167; CHECK-NEXT:    or %s3, 0, (0)1
168; CHECK-NEXT:    bsic %s10, (, %s12)
169; CHECK-NEXT:    or %s11, 0, %s9
170  %r = mul nsw i128 %a, 5
171  ret i128 %r
172}
173
174define zeroext i8 @funci8z(i8 zeroext %a) {
175; CHECK-LABEL: funci8z:
176; CHECK:       # %bb.0:
177; CHECK-NEXT:    muls.w.sx %s0, 5, %s0
178; CHECK-NEXT:    and %s0, %s0, (56)0
179; CHECK-NEXT:    b.l.t (, %s10)
180  %r = mul i8 %a, 5
181  ret i8 %r
182}
183
184define zeroext i16 @funci16z(i16 zeroext %a) {
185; CHECK-LABEL: funci16z:
186; CHECK:       # %bb.0:
187; CHECK-NEXT:    muls.w.sx %s0, 5, %s0
188; CHECK-NEXT:    and %s0, %s0, (48)0
189; CHECK-NEXT:    b.l.t (, %s10)
190  %r = mul i16 %a, 5
191  ret i16 %r
192}
193
194define zeroext i32 @funci32z(i32 zeroext %a) {
195; CHECK-LABEL: funci32z:
196; CHECK:       # %bb.0:
197; CHECK-NEXT:    muls.w.sx %s0, 5, %s0
198; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
199; CHECK-NEXT:    b.l.t (, %s10)
200  %r = mul i32 %a, 5
201  ret i32 %r
202}
203
204define i64 @funci64z(i64 %a) {
205; CHECK-LABEL: funci64z:
206; CHECK:       # %bb.0:
207; CHECK-NEXT:    muls.l %s0, 5, %s0
208; CHECK-NEXT:    b.l.t (, %s10)
209  %r = mul i64 %a, 5
210  ret i64 %r
211}
212
213define i128 @funci128z(i128 %a) {
214; CHECK-LABEL: funci128z:
215; CHECK:       .LBB{{[0-9]+}}_2:
216; CHECK-NEXT:    lea %s2, __multi3@lo
217; CHECK-NEXT:    and %s2, %s2, (32)0
218; CHECK-NEXT:    lea.sl %s12, __multi3@hi(, %s2)
219; CHECK-NEXT:    or %s2, 5, (0)1
220; CHECK-NEXT:    or %s3, 0, (0)1
221; CHECK-NEXT:    bsic %s10, (, %s12)
222; CHECK-NEXT:    or %s11, 0, %s9
223  %r = mul i128 %a, 5
224  ret i128 %r
225}
226
227define zeroext i32 @funci32z_2(i32 zeroext %a) {
228; CHECK-LABEL: funci32z_2:
229; CHECK:       # %bb.0:
230; CHECK-NEXT:    sla.w.sx %s0, %s0, 31
231; CHECK-NEXT:    adds.w.zx %s0, %s0, (0)1
232; CHECK-NEXT:    b.l.t (, %s10)
233  %r = shl i32 %a, 31
234  ret i32 %r
235}
236
237define i64 @funci64_2(i64 %a) {
238; CHECK-LABEL: funci64_2:
239; CHECK:       # %bb.0:
240; CHECK-NEXT:    sll %s0, %s0, 31
241; CHECK-NEXT:    b.l.t (, %s10)
242  %r = shl nsw i64 %a, 31
243  ret i64 %r
244}
245
246define i128 @funci128_2(i128 %a) {
247; CHECK-LABEL: funci128_2:
248; CHECK:       # %bb.0:
249; CHECK-NEXT:    srl %s2, %s0, 33
250; CHECK-NEXT:    sll %s1, %s1, 31
251; CHECK-NEXT:    or %s1, %s1, %s2
252; CHECK-NEXT:    sll %s0, %s0, 31
253; CHECK-NEXT:    b.l.t (, %s10)
254  %r = shl nsw i128 %a, 31
255  ret i128 %r
256}
257