1 ; RUN: llc < %s -march=mips -mcpu=mips2 -relocation-model=pic | \
2 ; RUN: FileCheck %s -check-prefixes=ALL,M2,GP32
3 ; RUN: llc < %s -march=mips -mcpu=mips32 -relocation-model=pic | \
4 ; RUN: FileCheck %s -check-prefixes=ALL,32R1-R5,GP32
5 ; RUN: llc < %s -march=mips -mcpu=mips32r2 -relocation-model=pic | \
6 ; RUN: FileCheck %s -check-prefixes=ALL,32R1-R5,32R2-R5,GP32
7 ; RUN: llc < %s -march=mips -mcpu=mips32r3 -relocation-model=pic | \
8 ; RUN: FileCheck %s -check-prefixes=ALL,32R1-R5,32R2-R5,GP32
9 ; RUN: llc < %s -march=mips -mcpu=mips32r5 -relocation-model=pic | \
10 ; RUN: FileCheck %s -check-prefixes=ALL,32R1-R5,32R2-R5,GP32
11 ; RUN: llc < %s -march=mips -mcpu=mips32r6 -relocation-model=pic | \
12 ; RUN: FileCheck %s -check-prefixes=ALL,32R6,GP32
13 ; RUN: llc < %s -march=mips64 -mcpu=mips4 -relocation-model=pic | \
14 ; RUN: FileCheck %s -check-prefixes=ALL,M4,GP64-NOT-R6
15 ; RUN: llc < %s -march=mips64 -mcpu=mips64 -relocation-model=pic | \
16 ; RUN: FileCheck %s -check-prefixes=ALL,64R1-R5,GP64-NOT-R6
17 ; RUN: llc < %s -march=mips64 -mcpu=mips64r2 -relocation-model=pic | \
18 ; RUN: FileCheck %s -check-prefixes=ALL,64R1-R5,GP64,GP64-NOT-R6
19 ; RUN: llc < %s -march=mips64 -mcpu=mips64r3 -relocation-model=pic | \
20 ; RUN: FileCheck %s -check-prefixes=ALL,64R1-R5,GP64,GP64-NOT-R6
21 ; RUN: llc < %s -march=mips64 -mcpu=mips64r5 -relocation-model=pic | \
22 ; RUN: FileCheck %s -check-prefixes=ALL,64R1-R5,GP64,GP64-NOT-R6
23 ; RUN: llc < %s -march=mips64 -mcpu=mips64r6 -relocation-model=pic | \
24 ; RUN: FileCheck %s -check-prefixes=ALL,64R6
25 ; RUN: llc < %s -march=mips -mcpu=mips32r3 -mattr=+micromips -relocation-model=pic | \
26 ; RUN: FileCheck %s -check-prefixes=MM32,MM32R3
27 ; RUN: llc < %s -march=mips -mcpu=mips32r6 -mattr=+micromips -relocation-model=pic | \
28 ; RUN: FileCheck %s -check-prefixes=MM32,MM32R6
30 define signext i1 @mul_i1(i1 signext %a, i1 signext %b) {
35 ; M2: mflo $[[T0:[0-9]+]]
36 ; M2: andi $[[T0]], $[[T0]], 1
37 ; M2: negu $2, $[[T0]]
39 ; 32R1-R5: mul $[[T0:[0-9]+]], $4, $5
40 ; 32R1-R5: andi $[[T0]], $[[T0]], 1
41 ; 32R1-R5: negu $2, $[[T0]]
43 ; 32R6: mul $[[T0:[0-9]+]], $4, $5
44 ; 32R6: andi $[[T0]], $[[T0]], 1
45 ; 32R6: negu $2, $[[T0]]
48 ; M4: mflo $[[T0:[0-9]+]]
49 ; M4: andi $[[T0]], $[[T0]], 1
50 ; M4: negu $2, $[[T0]]
52 ; 64R1-R5: mul $[[T0:[0-9]+]], $4, $5
53 ; 64R1-R5: andi $[[T0]], $[[T0]], 1
54 ; 64R1-R5: negu $2, $[[T0]]
56 ; 64R6: mul $[[T0:[0-9]+]], $4, $5
57 ; 64R6: andi $[[T0]], $[[T0]], 1
58 ; 64R6: negu $2, $[[T0]]
60 ; MM32: mul $[[T0:[0-9]+]], $4, $5
61 ; MM32: andi16 $[[T0]], $[[T0]], 1
62 ; MM32: li16 $[[T1:[0-9]+]], 0
63 ; MM32: subu16 $2, $[[T1]], $[[T0]]
69 define signext i8 @mul_i8(i8 signext %a, i8 signext %b) {
74 ; M2: mflo $[[T0:[0-9]+]]
75 ; M2: sll $[[T0]], $[[T0]], 24
76 ; M2: sra $2, $[[T0]], 24
78 ; 32R1: mul $[[T0:[0-9]+]], $4, $5
79 ; 32R1: sll $[[T0]], $[[T0]], 24
80 ; 32R1: sra $2, $[[T0]], 24
82 ; 32R2-R5: mul $[[T0:[0-9]+]], $4, $5
83 ; 32R2-R5: seb $2, $[[T0]]
85 ; 32R6: mul $[[T0:[0-9]+]], $4, $5
86 ; 32R6: seb $2, $[[T0]]
89 ; M4: mflo $[[T0:[0-9]+]]
90 ; M4: sll $[[T0]], $[[T0]], 24
91 ; M4: sra $2, $[[T0]], 24
93 ; 64R1: mul $[[T0:[0-9]+]], $4, $5
94 ; 64R1: sll $[[T0]], $[[T0]], 24
95 ; 64R1: sra $2, $[[T0]], 24
97 ; 64R2: mul $[[T0:[0-9]+]], $4, $5
98 ; 64R2: seb $2, $[[T0]]
100 ; 64R6: mul $[[T0:[0-9]+]], $4, $5
101 ; 64R6: seb $2, $[[T0]]
103 ; MM32: mul $[[T0:[0-9]+]], $4, $5
104 ; MM32: seb $2, $[[T0]]
110 define signext i16 @mul_i16(i16 signext %a, i16 signext %b) {
112 ; ALL-LABEL: mul_i16:
115 ; M2: mflo $[[T0:[0-9]+]]
116 ; M2: sll $[[T0]], $[[T0]], 16
117 ; M2: sra $2, $[[T0]], 16
119 ; 32R1: mul $[[T0:[0-9]+]], $4, $5
120 ; 32R1: sll $[[T0]], $[[T0]], 16
121 ; 32R1: sra $2, $[[T0]], 16
123 ; 32R2-R5: mul $[[T0:[0-9]+]], $4, $5
124 ; 32R2-R5: seh $2, $[[T0]]
126 ; 32R6: mul $[[T0:[0-9]+]], $4, $5
127 ; 32R6: seh $2, $[[T0]]
130 ; M4: mflo $[[T0:[0-9]+]]
131 ; M4: sll $[[T0]], $[[T0]], 16
132 ; M4: sra $2, $[[T0]], 16
134 ; 64R1: mul $[[T0:[0-9]+]], $4, $5
135 ; 64R1: sll $[[T0]], $[[T0]], 16
136 ; 64R1: sra $2, $[[T0]], 16
138 ; 64R2: mul $[[T0:[0-9]+]], $4, $5
139 ; 64R2: seh $2, $[[T0]]
141 ; 64R6: mul $[[T0:[0-9]+]], $4, $5
142 ; 64R6: seh $2, $[[T0]]
144 ; MM32: mul $[[T0:[0-9]+]], $4, $5
145 ; MM32: seh $2, $[[T0]]
151 define signext i32 @mul_i32(i32 signext %a, i32 signext %b) {
153 ; ALL-LABEL: mul_i32:
161 ; 32R1-R5: mul $2, $4, $5
162 ; 32R6: mul $2, $4, $5
164 ; 64R1-R5: mul $2, $4, $5
165 ; 64R6: mul $2, $4, $5
167 ; MM32: mul $2, $4, $5
173 define signext i64 @mul_i64(i64 signext %a, i64 signext %b) {
175 ; ALL-LABEL: mul_i64:
178 ; M2: mflo $[[T0:[0-9]+]]
180 ; M2: mflo $[[T1:[0-9]+]]
184 ; M2: addu $[[T2:[0-9]+]], $4, $[[T1]]
185 ; M2: addu $2, $[[T2]], $[[T0]]
187 ; 32R1-R5: multu $5, $7
189 ; 32R1-R5: mfhi $[[T0:[0-9]+]]
190 ; 32R1-R5: mul $[[T1:[0-9]+]], $5, $6
191 ; 32R1-R5: addu $[[T0]], $[[T0]], $[[T1:[0-9]+]]
192 ; 32R1-R5: mul $[[T2:[0-9]+]], $4, $7
193 ; 32R1-R5: addu $2, $[[T0]], $[[T2]]
195 ; 32R6-DAG: mul $[[T0:[0-9]+]], $5, $6
196 ; 32R6: muhu $[[T1:[0-9]+]], $5, $7
197 ; 32R6: addu $[[T0]], $[[T1]], $[[T0]]
198 ; 32R6-DAG: mul $[[T2:[0-9]+]], $4, $7
199 ; 32R6: addu $2, $[[T0]], $[[T2]]
200 ; 32R6-DAG: mul $3, $5, $7
205 ; 64R1-R5: dmult $4, $5
208 ; 64R6: dmul $2, $4, $5
210 ; MM32R3: multu $[[T0:[0-9]+]], $7
211 ; MM32R3: mflo16 $[[T1:[0-9]+]]
212 ; MM32R3: mfhi16 $[[T2:[0-9]+]]
213 ; MM32R3: mul $[[T0]], $[[T0]], $6
214 ; MM32R3: addu16 $2, $[[T2]], $[[T0]]
215 ; MM32R3: mul $[[T3:[0-9]+]], $4, $7
216 ; MM32R3: addu16 $[[T2]], $[[T2]], $[[T3]]
218 ; MM32R6: mul $[[T0:[0-9]+]], $5, $6
219 ; MM32R6: muhu $[[T1:[0-9]+]], $5, $7
220 ; MM32R6: addu16 $[[T2:[0-9]+]], $[[T1]], $[[T0]]
221 ; MM32R6: mul $[[T3:[0-9]+]], $4, $7
222 ; MM32R6: addu16 $2, $[[T2]], $[[T3]]
223 ; MM32R6: mul $[[T1]], $5, $7
229 define signext i128 @mul_i128(i128 signext %a, i128 signext %b) {
231 ; ALL-LABEL: mul_i128:
233 ; GP32: lw $25, %call16(__multi3)($gp)
235 ; GP64-NOT-R6: dmult $4, $7
236 ; GP64-NOT-R6: mflo $[[T0:[0-9]+]]
237 ; GP64-NOT-R6: dmult $5, $6
238 ; GP64-NOT-R6: mflo $[[T1:[0-9]+]]
239 ; GP64-NOT-R6: dmultu $5, $7
240 ; GP64-NOT-R6: mflo $3
241 ; GP64-NOT-R6: mfhi $[[T2:[0-9]+]]
242 ; GP64-NOT-R6: daddu $[[T3:[0-9]+]], $[[T2]], $[[T1]]
243 ; GP64-NOT-R6: daddu $2, $[[T3:[0-9]+]], $[[T0]]
245 ; 64R6-DAG: dmul $[[T1:[0-9]+]], $5, $6
246 ; 64R6: dmuhu $[[T2:[0-9]+]], $5, $7
247 ; 64R6: daddu $[[T3:[0-9]+]], $[[T2]], $[[T1]]
248 ; 64R6-DAG: dmul $[[T0:[0-9]+]], $4, $7
249 ; 64R6: daddu $2, $[[T1]], $[[T0]]
250 ; 64R6-DAG: dmul $3, $5, $7
252 ; MM32: lw $25, %call16(__multi3)($16)