1 ; RUN: llc -O2 -march=bpfel -mattr=+alu32 < %s | FileCheck %s
2 ; RUN: llc -O2 -march=bpfel -mcpu=v3 < %s | FileCheck %s
14 ; int add(int a, int b)
21 ; return a + 0x7fffffff;
24 ; int sub(int a, int b)
31 ; return a - 0xffffffff;
34 ; int mul(int a, int b)
44 ; unsigned div(unsigned a, unsigned b)
49 ; unsigned div_i(unsigned a)
54 ; unsigned rem(unsigned a, unsigned b)
59 ; unsigned rem_i(unsigned a)
64 ; int or(int a, int b)
74 ; int xor(int a, int b)
84 ; int and(int a, int b)
94 ; int sll(int a, int b)
104 ; unsigned srl(unsigned a, unsigned b)
109 ; unsigned srl_i(unsigned a, unsigned b)
114 ; int sra(int a, int b)
119 ; int sra_i(int a, int b)
129 ; Function Attrs: norecurse nounwind readnone
130 define dso_local i32 @mov(i32 returned %a) local_unnamed_addr #0 {
133 ; CHECK: w{{[0-9]+}} = w{{[0-9]+}}
136 ; Function Attrs: norecurse nounwind readnone
137 define dso_local i32 @mov_ri() local_unnamed_addr #0 {
140 ; CHECK: w{{[0-9]+}} = 255
143 ; Function Attrs: norecurse nounwind readnone
144 define dso_local i32 @add(i32 %a, i32 %b) local_unnamed_addr #0 {
146 %add = add nsw i32 %b, %a
147 ; CHECK: w{{[0-9]+}} += w{{[0-9]+}}
151 ; Function Attrs: norecurse nounwind readnone
152 define dso_local i32 @add_i(i32 %a) local_unnamed_addr #0 {
154 %add = add nsw i32 %a, 2147483647
155 ; CHECK: w{{[0-9]+}} += 2147483647
159 ; Function Attrs: norecurse nounwind readnone
160 define dso_local i32 @sub(i32 %a, i32 %b) local_unnamed_addr #0 {
162 %sub = sub nsw i32 %a, %b
163 ; CHECK: w{{[0-9]+}} -= w{{[0-9]+}}
167 ; Function Attrs: norecurse nounwind readnone
168 define dso_local i32 @sub_i(i32 %a) local_unnamed_addr #0 {
171 ; CHECK: w{{[0-9]+}} += 1
175 ; Function Attrs: norecurse nounwind readnone
176 define dso_local i32 @mul(i32 %a, i32 %b) local_unnamed_addr #0 {
178 %mul = mul nsw i32 %b, %a
179 ; CHECK: w{{[0-9]+}} *= w{{[0-9]+}}
183 ; Function Attrs: norecurse nounwind readnone
184 define dso_local i32 @mul_i(i32 %a) local_unnamed_addr #0 {
186 %mul = mul nsw i32 %a, 15
187 ; CHECK: w{{[0-9]+}} *= 15
191 ; Function Attrs: norecurse nounwind readnone
192 define dso_local i32 @div(i32 %a, i32 %b) local_unnamed_addr #0 {
194 %div = udiv i32 %a, %b
195 ; CHECK: w{{[0-9]+}} /= w{{[0-9]+}}
199 ; Function Attrs: norecurse nounwind readnone
200 define dso_local i32 @div_i(i32 %a) local_unnamed_addr #0 {
202 %div = udiv i32 %a, 15
203 ; CHECK-NOT: w{{[0-9]+}} /= 15
207 ; Function Attrs: norecurse nounwind readnone
208 define dso_local i32 @rem(i32 %a, i32 %b) local_unnamed_addr #0 {
210 %rem = urem i32 %a, %b
211 ; CHECK: w{{[0-9]+}} %= w{{[0-9]+}}
215 ; Function Attrs: norecurse nounwind readnone
216 define dso_local i32 @rem_i(i32 %a) local_unnamed_addr #0 {
218 %rem = urem i32 %a, 15
219 ; CHECK-NOT: w{{[0-9]+}} %= 15
223 ; Function Attrs: norecurse nounwind readnone
224 define dso_local i32 @or(i32 %a, i32 %b) local_unnamed_addr #0 {
227 ; CHECK: w{{[0-9]+}} |= w{{[0-9]+}}
231 ; Function Attrs: norecurse nounwind readnone
232 define dso_local i32 @or_i(i32 %a) local_unnamed_addr #0 {
235 ; CHECK: w{{[0-9]+}} |= 255
239 ; Function Attrs: norecurse nounwind readnone
240 define dso_local i32 @xor(i32 %a, i32 %b) local_unnamed_addr #0 {
242 %xor = xor i32 %b, %a
243 ; CHECK: w{{[0-9]+}} ^= w{{[0-9]+}}
247 ; Function Attrs: norecurse nounwind readnone
248 define dso_local i32 @xor_i(i32 %a) local_unnamed_addr #0 {
250 %xor = xor i32 %a, 4095
251 ; CHECK: w{{[0-9]+}} ^= 4095
255 ; Function Attrs: norecurse nounwind readnone
256 define dso_local i32 @and(i32 %a, i32 %b) local_unnamed_addr #0 {
258 %and = and i32 %b, %a
259 ; CHECK: w{{[0-9]+}} &= w{{[0-9]+}}
263 ; Function Attrs: norecurse nounwind readnone
264 define dso_local i32 @and_i(i32 %a) local_unnamed_addr #0 {
266 %and = and i32 %a, 65535
267 ; CHECK: w{{[0-9]+}} &= 65535
271 ; Function Attrs: norecurse nounwind readnone
272 define dso_local i32 @sll(i32 %a, i32 %b) local_unnamed_addr #0 {
274 %shl = shl i32 %a, %b
275 ; CHECK: w{{[0-9]+}} <<= w{{[0-9]+}}
279 ; Function Attrs: norecurse nounwind readnone
280 define dso_local i32 @sll_i(i32 %a) local_unnamed_addr #0 {
282 %shl = shl i32 %a, 17
283 ; CHECK: w{{[0-9]+}} <<= 17
287 ; Function Attrs: norecurse nounwind readnone
288 define dso_local i32 @srl(i32 %a, i32 %b) local_unnamed_addr #0 {
290 %shr = lshr i32 %a, %b
291 ; CHECK: w{{[0-9]+}} >>= w{{[0-9]+}}
295 ; Function Attrs: norecurse nounwind readnone
296 define dso_local i32 @srl_i(i32 %a, i32 %b) local_unnamed_addr #0 {
298 %shr = lshr i32 %a, 31
299 ; CHECK: w{{[0-9]+}} >>= 31
303 ; Function Attrs: norecurse nounwind readnone
304 define dso_local i32 @sra(i32 %a, i32 %b) local_unnamed_addr #0 {
306 %shr = ashr i32 %a, %b
307 ; CHECK: w{{[0-9]+}} s>>= w{{[0-9]+}}
311 ; Function Attrs: norecurse nounwind readnone
312 define dso_local i32 @sra_i(i32 %a, i32 %b) local_unnamed_addr #0 {
314 %shr = ashr i32 %a, 7
315 ; CHECK: w{{[0-9]+}} s>>= 7
319 ; Function Attrs: norecurse nounwind readnone
320 define dso_local i32 @neg(i32 %a) local_unnamed_addr #0 {
322 %sub = sub nsw i32 0, %a
323 ; CHECK: w{{[0-9]+}} = -w{{[0-9]+}}