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 ; int or(int a, int b)
64 ; int xor(int a, int b)
74 ; int and(int a, int b)
84 ; int sll(int a, int b)
94 ; unsigned srl(unsigned a, unsigned b)
99 ; unsigned srl_i(unsigned a, unsigned b)
104 ; int sra(int a, int b)
109 ; int sra_i(int a, int b)
119 ; Function Attrs: norecurse nounwind readnone
120 define dso_local i32 @mov(i32 returned %a) local_unnamed_addr #0 {
123 ; CHECK: w{{[0-9]+}} = w{{[0-9]+}}
126 ; Function Attrs: norecurse nounwind readnone
127 define dso_local i32 @mov_ri() local_unnamed_addr #0 {
130 ; CHECK: w{{[0-9]+}} = 255
133 ; Function Attrs: norecurse nounwind readnone
134 define dso_local i32 @add(i32 %a, i32 %b) local_unnamed_addr #0 {
136 %add = add nsw i32 %b, %a
137 ; CHECK: w{{[0-9]+}} += w{{[0-9]+}}
141 ; Function Attrs: norecurse nounwind readnone
142 define dso_local i32 @add_i(i32 %a) local_unnamed_addr #0 {
144 %add = add nsw i32 %a, 2147483647
145 ; CHECK: w{{[0-9]+}} += 2147483647
149 ; Function Attrs: norecurse nounwind readnone
150 define dso_local i32 @sub(i32 %a, i32 %b) local_unnamed_addr #0 {
152 %sub = sub nsw i32 %a, %b
153 ; CHECK: w{{[0-9]+}} -= w{{[0-9]+}}
157 ; Function Attrs: norecurse nounwind readnone
158 define dso_local i32 @sub_i(i32 %a) local_unnamed_addr #0 {
161 ; CHECK: w{{[0-9]+}} += 1
165 ; Function Attrs: norecurse nounwind readnone
166 define dso_local i32 @mul(i32 %a, i32 %b) local_unnamed_addr #0 {
168 %mul = mul nsw i32 %b, %a
169 ; CHECK: w{{[0-9]+}} *= w{{[0-9]+}}
173 ; Function Attrs: norecurse nounwind readnone
174 define dso_local i32 @mul_i(i32 %a) local_unnamed_addr #0 {
176 %mul = mul nsw i32 %a, 15
177 ; CHECK: w{{[0-9]+}} *= 15
181 ; Function Attrs: norecurse nounwind readnone
182 define dso_local i32 @div(i32 %a, i32 %b) local_unnamed_addr #0 {
184 %div = udiv i32 %a, %b
185 ; CHECK: w{{[0-9]+}} /= w{{[0-9]+}}
189 ; Function Attrs: norecurse nounwind readnone
190 define dso_local i32 @div_i(i32 %a) local_unnamed_addr #0 {
192 %div = udiv i32 %a, 15
193 ; CHECK: w{{[0-9]+}} /= 15
197 ; Function Attrs: norecurse nounwind readnone
198 define dso_local i32 @or(i32 %a, i32 %b) local_unnamed_addr #0 {
201 ; CHECK: w{{[0-9]+}} |= w{{[0-9]+}}
205 ; Function Attrs: norecurse nounwind readnone
206 define dso_local i32 @or_i(i32 %a) local_unnamed_addr #0 {
209 ; CHECK: w{{[0-9]+}} |= 255
213 ; Function Attrs: norecurse nounwind readnone
214 define dso_local i32 @xor(i32 %a, i32 %b) local_unnamed_addr #0 {
216 %xor = xor i32 %b, %a
217 ; CHECK: w{{[0-9]+}} ^= w{{[0-9]+}}
221 ; Function Attrs: norecurse nounwind readnone
222 define dso_local i32 @xor_i(i32 %a) local_unnamed_addr #0 {
224 %xor = xor i32 %a, 4095
225 ; CHECK: w{{[0-9]+}} ^= 4095
229 ; Function Attrs: norecurse nounwind readnone
230 define dso_local i32 @and(i32 %a, i32 %b) local_unnamed_addr #0 {
232 %and = and i32 %b, %a
233 ; CHECK: w{{[0-9]+}} &= w{{[0-9]+}}
237 ; Function Attrs: norecurse nounwind readnone
238 define dso_local i32 @and_i(i32 %a) local_unnamed_addr #0 {
240 %and = and i32 %a, 65535
241 ; CHECK: w{{[0-9]+}} &= 65535
245 ; Function Attrs: norecurse nounwind readnone
246 define dso_local i32 @sll(i32 %a, i32 %b) local_unnamed_addr #0 {
248 %shl = shl i32 %a, %b
249 ; CHECK: w{{[0-9]+}} <<= w{{[0-9]+}}
253 ; Function Attrs: norecurse nounwind readnone
254 define dso_local i32 @sll_i(i32 %a) local_unnamed_addr #0 {
256 %shl = shl i32 %a, 17
257 ; CHECK: w{{[0-9]+}} <<= 17
261 ; Function Attrs: norecurse nounwind readnone
262 define dso_local i32 @srl(i32 %a, i32 %b) local_unnamed_addr #0 {
264 %shr = lshr i32 %a, %b
265 ; CHECK: w{{[0-9]+}} >>= w{{[0-9]+}}
269 ; Function Attrs: norecurse nounwind readnone
270 define dso_local i32 @srl_i(i32 %a, i32 %b) local_unnamed_addr #0 {
272 %shr = lshr i32 %a, 31
273 ; CHECK: w{{[0-9]+}} >>= 31
277 ; Function Attrs: norecurse nounwind readnone
278 define dso_local i32 @sra(i32 %a, i32 %b) local_unnamed_addr #0 {
280 %shr = ashr i32 %a, %b
281 ; CHECK: w{{[0-9]+}} s>>= w{{[0-9]+}}
285 ; Function Attrs: norecurse nounwind readnone
286 define dso_local i32 @sra_i(i32 %a, i32 %b) local_unnamed_addr #0 {
288 %shr = ashr i32 %a, 7
289 ; CHECK: w{{[0-9]+}} s>>= 7
293 ; Function Attrs: norecurse nounwind readnone
294 define dso_local i32 @neg(i32 %a) local_unnamed_addr #0 {
296 %sub = sub nsw i32 0, %a
297 ; CHECK: w{{[0-9]+}} = -w{{[0-9]+}}