1 ; RUN: llc < %s -mtriple=ve-unknown-unknown | FileCheck %s
3 ; Function Attrs: norecurse nounwind readnone
4 define i128 @remi128(i128 %a, i128 %b) {
5 ; CHECK-LABEL: remi128:
6 ; CHECK: .LBB{{[0-9]+}}_2:
7 ; CHECK-NEXT: lea %s4, __modti3@lo
8 ; CHECK-NEXT: and %s4, %s4, (32)0
9 ; CHECK-NEXT: lea.sl %s12, __modti3@hi(, %s4)
10 ; CHECK-NEXT: bsic %s10, (, %s12)
11 ; CHECK-NEXT: or %s11, 0, %s9
16 ; Function Attrs: norecurse nounwind readnone
17 define i64 @remi64(i64 %a, i64 %b) {
18 ; CHECK-LABEL: remi64:
20 ; CHECK-NEXT: divs.l %s2, %s0, %s1
21 ; CHECK-NEXT: muls.l %s1, %s2, %s1
22 ; CHECK-NEXT: subs.l %s0, %s0, %s1
23 ; CHECK-NEXT: b.l.t (, %s10)
28 ; Function Attrs: norecurse nounwind readnone
29 define signext i32 @remi32(i32 signext %a, i32 signext %b) {
30 ; CHECK-LABEL: remi32:
32 ; CHECK-NEXT: divs.w.sx %s2, %s0, %s1
33 ; CHECK-NEXT: muls.w.sx %s1, %s2, %s1
34 ; CHECK-NEXT: subs.w.sx %s0, %s0, %s1
35 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
36 ; CHECK-NEXT: b.l.t (, %s10)
41 ; Function Attrs: norecurse nounwind readnone
42 define i128 @remu128(i128 %a, i128 %b) {
43 ; CHECK-LABEL: remu128:
44 ; CHECK: .LBB{{[0-9]+}}_2:
45 ; CHECK-NEXT: lea %s4, __umodti3@lo
46 ; CHECK-NEXT: and %s4, %s4, (32)0
47 ; CHECK-NEXT: lea.sl %s12, __umodti3@hi(, %s4)
48 ; CHECK-NEXT: bsic %s10, (, %s12)
49 ; CHECK-NEXT: or %s11, 0, %s9
54 ; Function Attrs: norecurse nounwind readnone
55 define i64 @remu64(i64 %a, i64 %b) {
56 ; CHECK-LABEL: remu64:
58 ; CHECK-NEXT: divu.l %s2, %s0, %s1
59 ; CHECK-NEXT: muls.l %s1, %s2, %s1
60 ; CHECK-NEXT: subs.l %s0, %s0, %s1
61 ; CHECK-NEXT: b.l.t (, %s10)
66 ; Function Attrs: norecurse nounwind readnone
67 define zeroext i32 @remu32(i32 zeroext %a, i32 zeroext %b) {
68 ; CHECK-LABEL: remu32:
70 ; CHECK-NEXT: divu.w %s2, %s0, %s1
71 ; CHECK-NEXT: muls.w.sx %s1, %s2, %s1
72 ; CHECK-NEXT: subs.w.sx %s0, %s0, %s1
73 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
74 ; CHECK-NEXT: b.l.t (, %s10)
79 ; Function Attrs: norecurse nounwind readnone
80 define signext i16 @remi16(i16 signext %a, i16 signext %b) {
81 ; CHECK-LABEL: remi16:
83 ; CHECK-NEXT: divs.w.sx %s2, %s0, %s1
84 ; CHECK-NEXT: muls.w.sx %s1, %s2, %s1
85 ; CHECK-NEXT: subs.w.sx %s0, %s0, %s1
86 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
87 ; CHECK-NEXT: b.l.t (, %s10)
88 %a32 = sext i16 %a to i32
89 %b32 = sext i16 %b to i32
90 %r32 = srem i32 %a32, %b32
91 %r = trunc i32 %r32 to i16
95 ; Function Attrs: norecurse nounwind readnone
96 define zeroext i16 @remu16(i16 zeroext %a, i16 zeroext %b) {
97 ; CHECK-LABEL: remu16:
99 ; CHECK-NEXT: divu.w %s2, %s0, %s1
100 ; CHECK-NEXT: muls.w.sx %s1, %s2, %s1
101 ; CHECK-NEXT: subs.w.sx %s0, %s0, %s1
102 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
103 ; CHECK-NEXT: b.l.t (, %s10)
108 ; Function Attrs: norecurse nounwind readnone
109 define signext i8 @remi8(i8 signext %a, i8 signext %b) {
110 ; CHECK-LABEL: remi8:
112 ; CHECK-NEXT: divs.w.sx %s2, %s0, %s1
113 ; CHECK-NEXT: muls.w.sx %s1, %s2, %s1
114 ; CHECK-NEXT: subs.w.sx %s0, %s0, %s1
115 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
116 ; CHECK-NEXT: b.l.t (, %s10)
117 %a32 = sext i8 %a to i32
118 %b32 = sext i8 %b to i32
119 %r32 = srem i32 %a32, %b32
120 %r = trunc i32 %r32 to i8
124 ; Function Attrs: norecurse nounwind readnone
125 define zeroext i8 @remu8(i8 zeroext %a, i8 zeroext %b) {
126 ; CHECK-LABEL: remu8:
128 ; CHECK-NEXT: divu.w %s2, %s0, %s1
129 ; CHECK-NEXT: muls.w.sx %s1, %s2, %s1
130 ; CHECK-NEXT: subs.w.sx %s0, %s0, %s1
131 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
132 ; CHECK-NEXT: b.l.t (, %s10)
137 ; Function Attrs: norecurse nounwind readnone
138 define i128 @remi128ri(i128 %a) {
139 ; CHECK-LABEL: remi128ri:
140 ; CHECK: .LBB{{[0-9]+}}_2:
141 ; CHECK-NEXT: lea %s2, __modti3@lo
142 ; CHECK-NEXT: and %s2, %s2, (32)0
143 ; CHECK-NEXT: lea.sl %s12, __modti3@hi(, %s2)
144 ; CHECK-NEXT: or %s2, 3, (0)1
145 ; CHECK-NEXT: or %s3, 0, (0)1
146 ; CHECK-NEXT: bsic %s10, (, %s12)
147 ; CHECK-NEXT: or %s11, 0, %s9
152 ; Function Attrs: norecurse nounwind readnone
153 define i64 @remi64ri(i64 %a) {
154 ; CHECK-LABEL: remi64ri:
156 ; CHECK-NEXT: divs.l %s1, %s0, (62)0
157 ; CHECK-NEXT: muls.l %s1, 3, %s1
158 ; CHECK-NEXT: subs.l %s0, %s0, %s1
159 ; CHECK-NEXT: b.l.t (, %s10)
164 ; Function Attrs: norecurse nounwind readnone
165 define signext i32 @remi32ri(i32 signext %a) {
166 ; CHECK-LABEL: remi32ri:
168 ; CHECK-NEXT: divs.w.sx %s1, %s0, (62)0
169 ; CHECK-NEXT: muls.w.sx %s1, 3, %s1
170 ; CHECK-NEXT: subs.w.sx %s0, %s0, %s1
171 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
172 ; CHECK-NEXT: b.l.t (, %s10)
177 ; Function Attrs: norecurse nounwind readnone
178 define i128 @remu128ri(i128 %a) {
179 ; CHECK-LABEL: remu128ri:
180 ; CHECK: .LBB{{[0-9]+}}_2:
181 ; CHECK-NEXT: lea %s2, __umodti3@lo
182 ; CHECK-NEXT: and %s2, %s2, (32)0
183 ; CHECK-NEXT: lea.sl %s12, __umodti3@hi(, %s2)
184 ; CHECK-NEXT: or %s2, 3, (0)1
185 ; CHECK-NEXT: or %s3, 0, (0)1
186 ; CHECK-NEXT: bsic %s10, (, %s12)
187 ; CHECK-NEXT: or %s11, 0, %s9
192 ; Function Attrs: norecurse nounwind readnone
193 define i64 @remu64ri(i64 %a) {
194 ; CHECK-LABEL: remu64ri:
196 ; CHECK-NEXT: divu.l %s1, %s0, (62)0
197 ; CHECK-NEXT: muls.l %s1, 3, %s1
198 ; CHECK-NEXT: subs.l %s0, %s0, %s1
199 ; CHECK-NEXT: b.l.t (, %s10)
204 ; Function Attrs: norecurse nounwind readnone
205 define zeroext i32 @remu32ri(i32 zeroext %a) {
206 ; CHECK-LABEL: remu32ri:
208 ; CHECK-NEXT: divu.w %s1, %s0, (62)0
209 ; CHECK-NEXT: muls.w.sx %s1, 3, %s1
210 ; CHECK-NEXT: subs.w.sx %s0, %s0, %s1
211 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
212 ; CHECK-NEXT: b.l.t (, %s10)
217 ; Function Attrs: norecurse nounwind readnone
218 define i128 @remi128li(i128 %a) {
219 ; CHECK-LABEL: remi128li:
220 ; CHECK: .LBB{{[0-9]+}}_2:
221 ; CHECK-NEXT: or %s3, 0, %s1
222 ; CHECK-NEXT: or %s2, 0, %s0
223 ; CHECK-NEXT: lea %s0, __modti3@lo
224 ; CHECK-NEXT: and %s0, %s0, (32)0
225 ; CHECK-NEXT: lea.sl %s12, __modti3@hi(, %s0)
226 ; CHECK-NEXT: or %s0, 3, (0)1
227 ; CHECK-NEXT: or %s1, 0, (0)1
228 ; CHECK-NEXT: bsic %s10, (, %s12)
229 ; CHECK-NEXT: or %s11, 0, %s9
234 ; Function Attrs: norecurse nounwind readnone
235 define i64 @remi64li(i64 %a, i64 %b) {
236 ; CHECK-LABEL: remi64li:
238 ; CHECK-NEXT: divs.l %s0, 3, %s1
239 ; CHECK-NEXT: muls.l %s0, %s0, %s1
240 ; CHECK-NEXT: subs.l %s0, 3, %s0
241 ; CHECK-NEXT: b.l.t (, %s10)
246 ; Function Attrs: norecurse nounwind readnone
247 define signext i32 @remi32li(i32 signext %a, i32 signext %b) {
248 ; CHECK-LABEL: remi32li:
250 ; CHECK-NEXT: divs.w.sx %s0, 3, %s1
251 ; CHECK-NEXT: muls.w.sx %s0, %s0, %s1
252 ; CHECK-NEXT: subs.w.sx %s0, 3, %s0
253 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
254 ; CHECK-NEXT: b.l.t (, %s10)
259 ; Function Attrs: norecurse nounwind readnone
260 define i128 @remu128li(i128) {
261 ; CHECK-LABEL: remu128li:
262 ; CHECK: .LBB{{[0-9]+}}_2:
263 ; CHECK-NEXT: or %s3, 0, %s1
264 ; CHECK-NEXT: or %s2, 0, %s0
265 ; CHECK-NEXT: lea %s0, __umodti3@lo
266 ; CHECK-NEXT: and %s0, %s0, (32)0
267 ; CHECK-NEXT: lea.sl %s12, __umodti3@hi(, %s0)
268 ; CHECK-NEXT: or %s0, 3, (0)1
269 ; CHECK-NEXT: or %s1, 0, (0)1
270 ; CHECK-NEXT: bsic %s10, (, %s12)
271 ; CHECK-NEXT: or %s11, 0, %s9
276 ; Function Attrs: norecurse nounwind readnone
277 define i64 @remu64li(i64 %a, i64 %b) {
278 ; CHECK-LABEL: remu64li:
280 ; CHECK-NEXT: divu.l %s0, 3, %s1
281 ; CHECK-NEXT: muls.l %s0, %s0, %s1
282 ; CHECK-NEXT: subs.l %s0, 3, %s0
283 ; CHECK-NEXT: b.l.t (, %s10)
288 ; Function Attrs: norecurse nounwind readnone
289 define zeroext i32 @remu32li(i32 zeroext %a, i32 zeroext %b) {
290 ; CHECK-LABEL: remu32li:
292 ; CHECK-NEXT: divu.w %s0, 3, %s1
293 ; CHECK-NEXT: muls.w.sx %s0, %s0, %s1
294 ; CHECK-NEXT: subs.w.sx %s0, 3, %s0
295 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
296 ; CHECK-NEXT: b.l.t (, %s10)