NFP BPF JIT compiler is doing a couple of small optimizations when jitting ALU imm instructions, some of these optimizations could save code-gen, for example: A & -1 = A A | 0 = A A ^ 0 = A However, for ALU32, high 32-bit of the 64-bit register should still be cleared according to ISA semantics.
Unified · Split
| @@ -1291,15 +1291,10 @@ wrp_alu64_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta, · 1290 unmodified lines | ||
| 1291 | 1291 | |
| 1292 | 1292 | static int |
| 1293 | 1293 | wrp_alu32_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta, |
| 1294 | − enum alu_op alu_op, bool skip) | |
| 1294 | + enum alu_op alu_op) | |
| 1295 | 1295 | { |
| 1296 | 1296 | const struct bpf_insn *insn = &meta->insn; |
| 1297 | 1297 | |
| 1298 | − if (skip) { | |
| 1299 | − meta->skip = true; | |
| 1300 | − return 0; | |
| 1301 | − } | |
| 1302 | − | |
| 1303 | 1298 | wrp_alu_imm(nfp_prog, insn->dst_reg * 2, alu_op, insn->imm); |
| 1304 | 1299 | wrp_immed(nfp_prog, reg_both(insn->dst_reg * 2 + 1), 0); |
| 1305 | 1300 | |
| @@ -2309,7 +2304,7 @@ static int xor_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) · 1003 unmodified lines | ||
| 2309 | 2304 | |
| 2310 | 2305 | static int xor_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) |
| 2311 | 2306 | { |
| 2312 | − return wrp_alu32_imm(nfp_prog, meta, ALU_OP_XOR, !meta->insn.imm); | |
| 2307 | + return wrp_alu32_imm(nfp_prog, meta, ALU_OP_XOR); | |
| 2313 | 2308 | } |
| 2314 | 2309 | |
| 2315 | 2310 | static int and_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) |
| @@ -2319,7 +2314,7 @@ static int and_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) · 3 unmodified lines | ||
| 2319 | 2314 | |
| 2320 | 2315 | static int and_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) |
| 2321 | 2316 | { |
| 2322 | − return wrp_alu32_imm(nfp_prog, meta, ALU_OP_AND, !~meta->insn.imm); | |
| 2317 | + return wrp_alu32_imm(nfp_prog, meta, ALU_OP_AND); | |
| 2323 | 2318 | } |
| 2324 | 2319 | |
| 2325 | 2320 | static int or_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) |
| @@ -2329,7 +2324,7 @@ static int or_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) · 3 unmodified lines | ||
| 2329 | 2324 | |
| 2330 | 2325 | static int or_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) |
| 2331 | 2326 | { |
| 2332 | − return wrp_alu32_imm(nfp_prog, meta, ALU_OP_OR, !meta->insn.imm); | |
| 2327 | + return wrp_alu32_imm(nfp_prog, meta, ALU_OP_OR); | |
| 2333 | 2328 | } |
| 2334 | 2329 | |
| 2335 | 2330 | static int add_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) |
| @@ -2339,7 +2334,7 @@ static int add_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) · 3 unmodified lines | ||
| 2339 | 2334 | |
| 2340 | 2335 | static int add_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) |
| 2341 | 2336 | { |
| 2342 | − return wrp_alu32_imm(nfp_prog, meta, ALU_OP_ADD, !meta->insn.imm); | |
| 2337 | + return wrp_alu32_imm(nfp_prog, meta, ALU_OP_ADD); | |
| 2343 | 2338 | } |
| 2344 | 2339 | |
| 2345 | 2340 | static int sub_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) |
| @@ -2349,7 +2344,7 @@ static int sub_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) · 3 unmodified lines | ||
| 2349 | 2344 | |
| 2350 | 2345 | static int sub_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) |
| 2351 | 2346 | { |
| 2352 | − return wrp_alu32_imm(nfp_prog, meta, ALU_OP_SUB, !meta->insn.imm); | |
| 2347 | + return wrp_alu32_imm(nfp_prog, meta, ALU_OP_SUB); | |
| 2353 | 2348 | } |
| 2354 | 2349 | |
| 2355 | 2350 | static int mul_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) |