blob: 160c126c7e3ab34e9b3a47f546812994a1a65eb8 [file] [log] [blame]
Petar Jovanovice578e972016-04-11 15:24:23 +00001; RUN: llc < %s -march=mips -mcpu=mips2 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +00002; RUN: -check-prefixes=ALL,GP32,NOT-R6,NOT-R2-R6
Petar Jovanovice578e972016-04-11 15:24:23 +00003; RUN: llc < %s -march=mips -mcpu=mips32 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +00004; RUN: -check-prefixes=ALL,GP32,NOT-R6,NOT-R2-R6
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +00005; RUN: llc < %s -march=mips -mcpu=mips32r2 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +00006; RUN: -check-prefixes=ALL,GP32,R2-R5,R2-R6,NOT-R6
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +00007; RUN: llc < %s -march=mips -mcpu=mips32r3 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +00008; RUN: -check-prefixes=ALL,GP32,R2-R5,R2-R6,NOT-R6
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +00009; RUN: llc < %s -march=mips -mcpu=mips32r5 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000010; RUN: -check-prefixes=ALL,GP32,R2-R5,R2-R6,NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000011; RUN: llc < %s -march=mips -mcpu=mips32r6 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000012; RUN: -check-prefixes=ALL,GP32,R6,R2-R6
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +000013
Petar Jovanovice578e972016-04-11 15:24:23 +000014; RUN: llc < %s -march=mips64 -mcpu=mips3 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000015; RUN: -check-prefixes=ALL,GP64-NOT-R6,NOT-R6,NOT-R2-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000016; RUN: llc < %s -march=mips64 -mcpu=mips4 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000017; RUN: -check-prefixes=ALL,GP64-NOT-R6,NOT-R6,NOT-R2-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000018; RUN: llc < %s -march=mips64 -mcpu=mips64 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000019; RUN: -check-prefixes=ALL,GP64-NOT-R6,NOT-R6,NOT-R2-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000020; RUN: llc < %s -march=mips64 -mcpu=mips64r2 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000021; RUN: -check-prefixes=ALL,R2-R5,R2-R6,GP64-NOT-R6,NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000022; RUN: llc < %s -march=mips64 -mcpu=mips64r3 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000023; RUN: -check-prefixes=ALL,R2-R5,R2-R6,GP64-NOT-R6,NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000024; RUN: llc < %s -march=mips64 -mcpu=mips64r5 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000025; RUN: -check-prefixes=ALL,R2-R5,R2-R6,GP64-NOT-R6,NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000026; RUN: llc < %s -march=mips64 -mcpu=mips64r6 -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000027; RUN: -check-prefixes=ALL,64R6,R6,R2-R6
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +000028
Zlatko Buljan58d6a952016-04-13 08:02:26 +000029; RUN: llc < %s -march=mips -mcpu=mips32r3 -mattr=+micromips -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000030; RUN: -check-prefixes=ALL,MMR3,MM32
Zlatko Buljan58d6a952016-04-13 08:02:26 +000031; RUN: llc < %s -march=mips -mcpu=mips32r6 -mattr=+micromips -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000032; RUN: -check-prefixes=ALL,MMR6,MM32
Daniel Sandersde393322016-06-23 12:42:53 +000033; RUN: llc < %s -march=mips -mcpu=mips64r6 -target-abi n64 -mattr=+micromips -relocation-model=pic | FileCheck %s \
Daniel Sanders0d972702016-06-24 12:23:17 +000034; RUN: -check-prefixes=ALL,MMR6,MM64
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000035
36define signext i1 @urem_i1(i1 signext %a, i1 signext %b) {
37entry:
38; ALL-LABEL: urem_i1:
39
40 ; NOT-R6: andi $[[T0:[0-9]+]], $5, 1
41 ; NOT-R6: andi $[[T1:[0-9]+]], $4, 1
42 ; NOT-R6: divu $zero, $[[T1]], $[[T0]]
43 ; NOT-R6: teq $[[T0]], $zero, 7
44 ; NOT-R6: mfhi $[[T2:[0-9]+]]
Sanjay Patel3a3aaf62016-10-19 16:58:59 +000045 ; NOT-R6: andi $[[T0]], $[[T0]], 1
46 ; NOT-R6: negu $2, $[[T0]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000047
48 ; R6: andi $[[T0:[0-9]+]], $5, 1
49 ; R6: andi $[[T1:[0-9]+]], $4, 1
50 ; R6: modu $[[T2:[0-9]+]], $[[T1]], $[[T0]]
51 ; R6: teq $[[T0]], $zero, 7
Sanjay Patel3a3aaf62016-10-19 16:58:59 +000052 ; R6: negu $2, $[[T2]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000053
Zlatko Buljan58d6a952016-04-13 08:02:26 +000054 ; MMR3: andi16 $[[T0:[0-9]+]], $5, 1
55 ; MMR3: andi16 $[[T1:[0-9]+]], $4, 1
56 ; MMR3: divu $zero, $[[T1]], $[[T0]]
57 ; MMR3: teq $[[T0]], $zero, 7
58 ; MMR3: mfhi $[[T2:[0-9]+]]
Sanjay Patel3a3aaf62016-10-19 16:58:59 +000059 ; MMR3: andi16 $[[T0]], $[[T0]], 1
60 ; MMR3: li16 $[[T1:[0-9]+]], 0
61 ; MMR3: subu16 $2, $[[T1]], $[[T0]]
Zlatko Buljan58d6a952016-04-13 08:02:26 +000062
63 ; MMR6: andi16 $[[T0:[0-9]+]], $5, 1
64 ; MMR6: andi16 $[[T1:[0-9]+]], $4, 1
65 ; MMR6: modu $[[T2:[0-9]+]], $[[T1]], $[[T0]]
66 ; MMR6: teq $[[T0]], $zero, 7
Sanjay Patel3a3aaf62016-10-19 16:58:59 +000067 ; MMR6: li16 $[[T3:[0-9]+]], 0
68 ; MMR6: subu16 $2, $[[T3]], $[[T2]]
Zlatko Buljan58d6a952016-04-13 08:02:26 +000069
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000070 %r = urem i1 %a, %b
71 ret i1 %r
72}
73
74define signext i8 @urem_i8(i8 signext %a, i8 signext %b) {
75entry:
76; ALL-LABEL: urem_i8:
77
78 ; NOT-R2-R6: andi $[[T0:[0-9]+]], $5, 255
79 ; NOT-R2-R6: andi $[[T1:[0-9]+]], $4, 255
80 ; NOT-R2-R6: divu $zero, $[[T1]], $[[T0]]
81 ; NOT-R2-R6: teq $[[T0]], $zero, 7
82 ; NOT-R2-R6: mfhi $[[T2:[0-9]+]]
83 ; NOT-R2-R6: sll $[[T3:[0-9]+]], $[[T2]], 24
84 ; NOT-R2-R6: sra $2, $[[T3]], 24
85
Daniel Sanders17793142015-02-18 16:24:50 +000086 ; R2-R5: andi $[[T0:[0-9]+]], $5, 255
87 ; R2-R5: andi $[[T1:[0-9]+]], $4, 255
88 ; R2-R5: divu $zero, $[[T1]], $[[T0]]
89 ; R2-R5: teq $[[T0]], $zero, 7
90 ; R2-R5: mfhi $[[T2:[0-9]+]]
91 ; R2-R5: seb $2, $[[T2]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000092
93 ; R6: andi $[[T0:[0-9]+]], $5, 255
94 ; R6: andi $[[T1:[0-9]+]], $4, 255
95 ; R6: modu $[[T2:[0-9]+]], $[[T1]], $[[T0]]
96 ; R6: teq $[[T0]], $zero, 7
97 ; R6: seb $2, $[[T2]]
98
Zlatko Buljan58d6a952016-04-13 08:02:26 +000099 ; MMR3: andi16 $[[T0:[0-9]+]], $5, 255
100 ; MMR3: andi16 $[[T1:[0-9]+]], $4, 255
101 ; MMR3: divu $zero, $[[T1]], $[[T0]]
102 ; MMR3: teq $[[T0]], $zero, 7
103 ; MMR3: mfhi $[[T2:[0-9]+]]
104 ; MMR3: seb $2, $[[T2]]
105
106 ; MMR6: andi16 $[[T0:[0-9]+]], $5, 255
107 ; MMR6: andi16 $[[T1:[0-9]+]], $4, 255
108 ; MMR6: modu $[[T2:[0-9]+]], $[[T1]], $[[T0]]
109 ; MMR6: teq $[[T0]], $zero, 7
110 ; MMR6: seb $2, $[[T2]]
111
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000112 %r = urem i8 %a, %b
113 ret i8 %r
114}
115
116define signext i16 @urem_i16(i16 signext %a, i16 signext %b) {
117entry:
118; ALL-LABEL: urem_i16:
119
120 ; NOT-R2-R6: andi $[[T0:[0-9]+]], $5, 65535
121 ; NOT-R2-R6: andi $[[T1:[0-9]+]], $4, 65535
122 ; NOT-R2-R6: divu $zero, $[[T1]], $[[T0]]
123 ; NOT-R2-R6: teq $[[T0]], $zero, 7
124 ; NOT-R2-R6: mfhi $[[T2:[0-9]+]]
125 ; NOT-R2-R6: sll $[[T3:[0-9]+]], $[[T2]], 16
126 ; NOT-R2-R6: sra $2, $[[T3]], 16
127
Daniel Sanders17793142015-02-18 16:24:50 +0000128 ; R2-R5: andi $[[T0:[0-9]+]], $5, 65535
129 ; R2-R5: andi $[[T1:[0-9]+]], $4, 65535
130 ; R2-R5: divu $zero, $[[T1]], $[[T0]]
131 ; R2-R5: teq $[[T0]], $zero, 7
132 ; R2-R5: mfhi $[[T3:[0-9]+]]
133 ; R2-R5: seh $2, $[[T2]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000134
135 ; R6: andi $[[T0:[0-9]+]], $5, 65535
136 ; R6: andi $[[T1:[0-9]+]], $4, 65535
137 ; R6: modu $[[T2:[0-9]+]], $[[T1]], $[[T0]]
138 ; R6: teq $[[T0]], $zero, 7
139 ; R6: seh $2, $[[T2]]
140
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000141 ; MMR3: andi16 $[[T0:[0-9]+]], $5, 65535
142 ; MMR3: andi16 $[[T1:[0-9]+]], $4, 65535
143 ; MMR3: divu $zero, $[[T1]], $[[T0]]
144 ; MMR3: teq $[[T0]], $zero, 7
145 ; MMR3: mfhi $[[T2:[0-9]+]]
146 ; MMR3: seh $2, $[[T2]]
147
148 ; MMR6: andi16 $[[T0:[0-9]+]], $5, 65535
149 ; MMR6: andi16 $[[T1:[0-9]+]], $4, 65535
150 ; MMR6: modu $[[T2:[0-9]+]], $[[T1]], $[[T0]]
151 ; MMR6: teq $[[T0]], $zero, 7
152 ; MMR6: seh $2, $[[T2]]
153
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000154 %r = urem i16 %a, %b
155 ret i16 %r
156}
157
158define signext i32 @urem_i32(i32 signext %a, i32 signext %b) {
159entry:
160; ALL-LABEL: urem_i32:
161
162 ; NOT-R6: divu $zero, $4, $5
163 ; NOT-R6: teq $5, $zero, 7
164 ; NOT-R6: mfhi $2
165
166 ; R6: modu $2, $4, $5
167 ; R6: teq $5, $zero, 7
168
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000169 ; MMR3: divu $zero, $4, $5
170 ; MMR3: teq $5, $zero, 7
171 ; MMR3: mfhi $2
172
173 ; MMR6: modu $2, $4, $5
174 ; MMR6: teq $5, $zero, 7
175
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000176 %r = urem i32 %a, %b
177 ret i32 %r
178}
179
180define signext i64 @urem_i64(i64 signext %a, i64 signext %b) {
181entry:
182; ALL-LABEL: urem_i64:
183
184 ; GP32: lw $25, %call16(__umoddi3)($gp)
185
186 ; GP64-NOT-R6: ddivu $zero, $4, $5
187 ; GP64-NOT-R6: teq $5, $zero, 7
188 ; GP64-NOT-R6: mfhi $2
189
190 ; 64R6: dmodu $2, $4, $5
191 ; 64R6: teq $5, $zero, 7
192
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000193 ; MM32: lw $25, %call16(__umoddi3)($2)
194
195 ; MM64: dmodu $2, $4, $5
196 ; MM64: teq $5, $zero, 7
197
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000198 %r = urem i64 %a, %b
199 ret i64 %r
200}
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000201
202define signext i128 @urem_i128(i128 signext %a, i128 signext %b) {
203entry:
204 ; ALL-LABEL: urem_i128:
205
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000206 ; GP32: lw $25, %call16(__umodti3)($gp)
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000207
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000208 ; GP64-NOT-R6: ld $25, %call16(__umodti3)($gp)
Vasileios Kalintirisd10ce392016-04-14 09:13:13 +0000209 ; 64R6: ld $25, %call16(__umodti3)($gp)
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000210
Simon Dardisf1148202016-08-24 13:00:47 +0000211 ; MM32: lw $25, %call16(__umodti3)($16)
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000212
213 ; MM64: ld $25, %call16(__umodti3)($2)
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000214
215 %r = urem i128 %a, %b
216 ret i128 %r
217}