1 ; RUN: llc < %s -mtriple=ve-unknown-unknown | FileCheck %s
3 ; Function Attrs: norecurse nounwind readnone
4 define i128 @divi128(i128, i128) {
5 ; CHECK-LABEL: divi128:
6 ; CHECK: .LBB{{[0-9]+}}_2:
7 ; CHECK-NEXT: lea %s4, __divti3@lo
8 ; CHECK-NEXT: and %s4, %s4, (32)0
9 ; CHECK-NEXT: lea.sl %s12, __divti3@hi(, %s4)
10 ; CHECK-NEXT: bsic %s10, (, %s12)
11 ; CHECK-NEXT: or %s11, 0, %s9
16 ; Function Attrs: norecurse nounwind readnone
17 define i64 @divi64(i64 %a, i64 %b) {
18 ; CHECK-LABEL: divi64:
20 ; CHECK-NEXT: divs.l %s0, %s0, %s1
21 ; CHECK-NEXT: b.l.t (, %s10)
26 ; Function Attrs: norecurse nounwind readnone
27 define signext i32 @divi32(i32 signext %a, i32 signext %b) {
28 ; CHECK-LABEL: divi32:
30 ; CHECK-NEXT: divs.w.sx %s0, %s0, %s1
31 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
32 ; CHECK-NEXT: b.l.t (, %s10)
37 ; Function Attrs: norecurse nounwind readnone
38 define i128 @divu128(i128, i128) {
39 ; CHECK-LABEL: divu128:
40 ; CHECK: .LBB{{[0-9]+}}_2:
41 ; CHECK-NEXT: lea %s4, __udivti3@lo
42 ; CHECK-NEXT: and %s4, %s4, (32)0
43 ; CHECK-NEXT: lea.sl %s12, __udivti3@hi(, %s4)
44 ; CHECK-NEXT: bsic %s10, (, %s12)
45 ; CHECK-NEXT: or %s11, 0, %s9
50 ; Function Attrs: norecurse nounwind readnone
51 define i64 @divu64(i64 %a, i64 %b) {
52 ; CHECK-LABEL: divu64:
54 ; CHECK-NEXT: divu.l %s0, %s0, %s1
55 ; CHECK-NEXT: b.l.t (, %s10)
60 ; Function Attrs: norecurse nounwind readnone
61 define zeroext i32 @divu32(i32 zeroext %a, i32 zeroext %b) {
62 ; CHECK-LABEL: divu32:
64 ; CHECK-NEXT: divu.w %s0, %s0, %s1
65 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
66 ; CHECK-NEXT: b.l.t (, %s10)
71 ; Function Attrs: norecurse nounwind readnone
72 define signext i16 @divi16(i16 signext %a, i16 signext %b) {
73 ; CHECK-LABEL: divi16:
75 ; CHECK-NEXT: divs.w.sx %s0, %s0, %s1
76 ; CHECK-NEXT: sll %s0, %s0, 48
77 ; CHECK-NEXT: sra.l %s0, %s0, 48
78 ; CHECK-NEXT: b.l.t (, %s10)
79 %a32 = sext i16 %a to i32
80 %b32 = sext i16 %b to i32
81 %r32 = sdiv i32 %a32, %b32
82 %r = trunc i32 %r32 to i16
86 ; Function Attrs: norecurse nounwind readnone
87 define zeroext i16 @divu16(i16 zeroext %a, i16 zeroext %b) {
88 ; CHECK-LABEL: divu16:
90 ; CHECK-NEXT: divu.w %s0, %s0, %s1
91 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
92 ; CHECK-NEXT: b.l.t (, %s10)
97 ; Function Attrs: norecurse nounwind readnone
98 define signext i8 @divi8(i8 signext %a, i8 signext %b) {
101 ; CHECK-NEXT: divs.w.sx %s0, %s0, %s1
102 ; CHECK-NEXT: sll %s0, %s0, 56
103 ; CHECK-NEXT: sra.l %s0, %s0, 56
104 ; CHECK-NEXT: b.l.t (, %s10)
105 %a32 = sext i8 %a to i32
106 %b32 = sext i8 %b to i32
107 %r32 = sdiv i32 %a32, %b32
108 %r = trunc i32 %r32 to i8
112 ; Function Attrs: norecurse nounwind readnone
113 define zeroext i8 @divu8(i8 zeroext %a, i8 zeroext %b) {
114 ; CHECK-LABEL: divu8:
116 ; CHECK-NEXT: divu.w %s0, %s0, %s1
117 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
118 ; CHECK-NEXT: b.l.t (, %s10)
123 ; Function Attrs: norecurse nounwind readnone
124 define i128 @divi128ri(i128) {
125 ; CHECK-LABEL: divi128ri:
126 ; CHECK: .LBB{{[0-9]+}}_2:
127 ; CHECK-NEXT: lea %s2, __divti3@lo
128 ; CHECK-NEXT: and %s2, %s2, (32)0
129 ; CHECK-NEXT: lea.sl %s12, __divti3@hi(, %s2)
130 ; CHECK-NEXT: or %s2, 3, (0)1
131 ; CHECK-NEXT: or %s3, 0, (0)1
132 ; CHECK-NEXT: bsic %s10, (, %s12)
133 ; CHECK-NEXT: or %s11, 0, %s9
138 ; Function Attrs: norecurse nounwind readnone
139 define i64 @divi64ri(i64 %a, i64 %b) {
140 ; CHECK-LABEL: divi64ri:
142 ; CHECK-NEXT: divs.l %s0, %s0, (62)0
143 ; CHECK-NEXT: b.l.t (, %s10)
148 ; Function Attrs: norecurse nounwind readnone
149 define signext i32 @divi32ri(i32 signext %a, i32 signext %b) {
150 ; CHECK-LABEL: divi32ri:
152 ; CHECK-NEXT: divs.w.sx %s0, %s0, (62)0
153 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
154 ; CHECK-NEXT: b.l.t (, %s10)
159 ; Function Attrs: norecurse nounwind readnone
160 define i128 @divu128ri(i128) {
161 ; CHECK-LABEL: divu128ri:
162 ; CHECK: .LBB{{[0-9]+}}_2:
163 ; CHECK-NEXT: lea %s2, __udivti3@lo
164 ; CHECK-NEXT: and %s2, %s2, (32)0
165 ; CHECK-NEXT: lea.sl %s12, __udivti3@hi(, %s2)
166 ; CHECK-NEXT: or %s2, 3, (0)1
167 ; CHECK-NEXT: or %s3, 0, (0)1
168 ; CHECK-NEXT: bsic %s10, (, %s12)
169 ; CHECK-NEXT: or %s11, 0, %s9
174 ; Function Attrs: norecurse nounwind readnone
175 define i64 @divu64ri(i64 %a, i64 %b) {
176 ; CHECK-LABEL: divu64ri:
178 ; CHECK-NEXT: divu.l %s0, %s0, (62)0
179 ; CHECK-NEXT: b.l.t (, %s10)
184 ; Function Attrs: norecurse nounwind readnone
185 define zeroext i32 @divu32ri(i32 zeroext %a, i32 zeroext %b) {
186 ; CHECK-LABEL: divu32ri:
188 ; CHECK-NEXT: divu.w %s0, %s0, (62)0
189 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
190 ; CHECK-NEXT: b.l.t (, %s10)
195 ; Function Attrs: norecurse nounwind readnone
196 define i128 @divi128li(i128) {
197 ; CHECK-LABEL: divi128li:
198 ; CHECK: .LBB{{[0-9]+}}_2:
199 ; CHECK-NEXT: or %s3, 0, %s1
200 ; CHECK-NEXT: or %s2, 0, %s0
201 ; CHECK-NEXT: lea %s0, __divti3@lo
202 ; CHECK-NEXT: and %s0, %s0, (32)0
203 ; CHECK-NEXT: lea.sl %s12, __divti3@hi(, %s0)
204 ; CHECK-NEXT: or %s0, 3, (0)1
205 ; CHECK-NEXT: or %s1, 0, (0)1
206 ; CHECK-NEXT: bsic %s10, (, %s12)
207 ; CHECK-NEXT: or %s11, 0, %s9
212 ; Function Attrs: norecurse nounwind readnone
213 define i64 @divi64li(i64 %a, i64 %b) {
214 ; CHECK-LABEL: divi64li:
216 ; CHECK-NEXT: divs.l %s0, 3, %s1
217 ; CHECK-NEXT: b.l.t (, %s10)
222 ; Function Attrs: norecurse nounwind readnone
223 define signext i32 @divi32li(i32 signext %a, i32 signext %b) {
224 ; CHECK-LABEL: divi32li:
226 ; CHECK-NEXT: divs.w.sx %s0, 3, %s1
227 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
228 ; CHECK-NEXT: b.l.t (, %s10)
233 ; Function Attrs: norecurse nounwind readnone
234 define i128 @divu128li(i128) {
235 ; CHECK-LABEL: divu128li:
236 ; CHECK: .LBB{{[0-9]+}}_2:
237 ; CHECK-NEXT: or %s3, 0, %s1
238 ; CHECK-NEXT: or %s2, 0, %s0
239 ; CHECK-NEXT: lea %s0, __udivti3@lo
240 ; CHECK-NEXT: and %s0, %s0, (32)0
241 ; CHECK-NEXT: lea.sl %s12, __udivti3@hi(, %s0)
242 ; CHECK-NEXT: or %s0, 3, (0)1
243 ; CHECK-NEXT: or %s1, 0, (0)1
244 ; CHECK-NEXT: bsic %s10, (, %s12)
245 ; CHECK-NEXT: or %s11, 0, %s9
250 ; Function Attrs: norecurse nounwind readnone
251 define i64 @divu64li(i64 %a, i64 %b) {
252 ; CHECK-LABEL: divu64li:
254 ; CHECK-NEXT: divu.l %s0, 3, %s1
255 ; CHECK-NEXT: b.l.t (, %s10)
260 ; Function Attrs: norecurse nounwind readnone
261 define zeroext i32 @divu32li(i32 zeroext %a, i32 zeroext %b) {
262 ; CHECK-LABEL: divu32li:
264 ; CHECK-NEXT: divu.w %s0, 3, %s1
265 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
266 ; CHECK-NEXT: b.l.t (, %s10)