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: lea %s1, 1431655766
153 ; CHECK-NEXT: muls.l %s0, %s0, %s1
154 ; CHECK-NEXT: srl %s1, %s0, 63
155 ; CHECK-NEXT: srl %s0, %s0, 32
156 ; CHECK-NEXT: adds.w.sx %s0, %s0, %s1
157 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
158 ; CHECK-NEXT: b.l.t (, %s10)
163 ; Function Attrs: norecurse nounwind readnone
164 define i128 @divu128ri(i128) {
165 ; CHECK-LABEL: divu128ri:
166 ; CHECK: .LBB{{[0-9]+}}_2:
167 ; CHECK-NEXT: lea %s2, __udivti3@lo
168 ; CHECK-NEXT: and %s2, %s2, (32)0
169 ; CHECK-NEXT: lea.sl %s12, __udivti3@hi(, %s2)
170 ; CHECK-NEXT: or %s2, 3, (0)1
171 ; CHECK-NEXT: or %s3, 0, (0)1
172 ; CHECK-NEXT: bsic %s10, (, %s12)
173 ; CHECK-NEXT: or %s11, 0, %s9
178 ; Function Attrs: norecurse nounwind readnone
179 define i64 @divu64ri(i64 %a, i64 %b) {
180 ; CHECK-LABEL: divu64ri:
182 ; CHECK-NEXT: divu.l %s0, %s0, (62)0
183 ; CHECK-NEXT: b.l.t (, %s10)
188 ; Function Attrs: norecurse nounwind readnone
189 define zeroext i32 @divu32ri(i32 zeroext %a, i32 zeroext %b) {
190 ; CHECK-LABEL: divu32ri:
192 ; CHECK-NEXT: lea %s1, -1431655765
193 ; CHECK-NEXT: and %s1, %s1, (32)0
194 ; CHECK-NEXT: muls.l %s0, %s0, %s1
195 ; CHECK-NEXT: srl %s0, %s0, 33
196 ; CHECK-NEXT: b.l.t (, %s10)
201 ; Function Attrs: norecurse nounwind readnone
202 define i128 @divi128li(i128) {
203 ; CHECK-LABEL: divi128li:
204 ; CHECK: .LBB{{[0-9]+}}_2:
205 ; CHECK-NEXT: or %s3, 0, %s1
206 ; CHECK-NEXT: or %s2, 0, %s0
207 ; CHECK-NEXT: lea %s0, __divti3@lo
208 ; CHECK-NEXT: and %s0, %s0, (32)0
209 ; CHECK-NEXT: lea.sl %s12, __divti3@hi(, %s0)
210 ; CHECK-NEXT: or %s0, 3, (0)1
211 ; CHECK-NEXT: or %s1, 0, (0)1
212 ; CHECK-NEXT: bsic %s10, (, %s12)
213 ; CHECK-NEXT: or %s11, 0, %s9
218 ; Function Attrs: norecurse nounwind readnone
219 define i64 @divi64li(i64 %a, i64 %b) {
220 ; CHECK-LABEL: divi64li:
222 ; CHECK-NEXT: divs.l %s0, 3, %s1
223 ; CHECK-NEXT: b.l.t (, %s10)
228 ; Function Attrs: norecurse nounwind readnone
229 define signext i32 @divi32li(i32 signext %a, i32 signext %b) {
230 ; CHECK-LABEL: divi32li:
232 ; CHECK-NEXT: divs.w.sx %s0, 3, %s1
233 ; CHECK-NEXT: adds.w.sx %s0, %s0, (0)1
234 ; CHECK-NEXT: b.l.t (, %s10)
239 ; Function Attrs: norecurse nounwind readnone
240 define i128 @divu128li(i128) {
241 ; CHECK-LABEL: divu128li:
242 ; CHECK: .LBB{{[0-9]+}}_2:
243 ; CHECK-NEXT: or %s3, 0, %s1
244 ; CHECK-NEXT: or %s2, 0, %s0
245 ; CHECK-NEXT: lea %s0, __udivti3@lo
246 ; CHECK-NEXT: and %s0, %s0, (32)0
247 ; CHECK-NEXT: lea.sl %s12, __udivti3@hi(, %s0)
248 ; CHECK-NEXT: or %s0, 3, (0)1
249 ; CHECK-NEXT: or %s1, 0, (0)1
250 ; CHECK-NEXT: bsic %s10, (, %s12)
251 ; CHECK-NEXT: or %s11, 0, %s9
256 ; Function Attrs: norecurse nounwind readnone
257 define i64 @divu64li(i64 %a, i64 %b) {
258 ; CHECK-LABEL: divu64li:
260 ; CHECK-NEXT: divu.l %s0, 3, %s1
261 ; CHECK-NEXT: b.l.t (, %s10)
266 ; Function Attrs: norecurse nounwind readnone
267 define zeroext i32 @divu32li(i32 zeroext %a, i32 zeroext %b) {
268 ; CHECK-LABEL: divu32li:
270 ; CHECK-NEXT: divu.w %s0, 3, %s1
271 ; CHECK-NEXT: adds.w.zx %s0, %s0, (0)1
272 ; CHECK-NEXT: b.l.t (, %s10)