Skip to content

Commit 2148a57

Browse files
seehearfeelKernel Patches Daemon
authored andcommitted
LoongArch: BPF: Optimize sign-extention mov instructions
For 8-bit and 16-bit sign-extention mov instructions, it can use the native instructions ext.w.b and ext.w.h directly, no need to use the temporary t1 register, just remove the redundant operations. Here are the test results: # modprobe test_bpf test_range=81,84 # dmesg -t | tail -5 test_bpf: #81 ALU_MOVSX | BPF_B jited:1 5 PASS test_bpf: #82 ALU_MOVSX | BPF_H jited:1 5 PASS test_bpf: #83 ALU64_MOVSX | BPF_B jited:1 5 PASS test_bpf: #84 ALU64_MOVSX | BPF_H jited:1 5 PASS test_bpf: Summary: 4 PASSED, 0 FAILED, [4/4 JIT'ed] Signed-off-by: Tiezhu Yang <[email protected]>
1 parent 8f9c214 commit 2148a57

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

arch/loongarch/net/bpf_jit.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,13 +527,11 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext
527527
emit_zext_32(ctx, dst, is32);
528528
break;
529529
case 8:
530-
move_reg(ctx, t1, src);
531-
emit_insn(ctx, extwb, dst, t1);
530+
emit_insn(ctx, extwb, dst, src);
532531
emit_zext_32(ctx, dst, is32);
533532
break;
534533
case 16:
535-
move_reg(ctx, t1, src);
536-
emit_insn(ctx, extwh, dst, t1);
534+
emit_insn(ctx, extwh, dst, src);
537535
emit_zext_32(ctx, dst, is32);
538536
break;
539537
case 32:

0 commit comments

Comments
 (0)