Re: [PATCH RFC 2/2] LoongArch: BPF: Eliminate zero/sign extensions for 32-bit operations
Tiezhu Yang <[email protected]> Mon, 27 Jul 2026 10:48:25 +0800
| Newsgroups | dev.linux.lists.loongarch,org.kernel.vger.bpf,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On 2026/7/26 下午5:23, Hengqi Chen wrote: > On Sat, Jul 11, 2026 at 6:17 PM Tiezhu Yang <[email protected]> wrote: >> >> Eliminate frequent and redundant zero-extensions and sign-extensions >> for 32-bit operations. This prevents potential functional bugs caused >> by incorrect extension selections and reduces runtime overhead. ... >> @@ -741,28 +725,32 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext >> switch (code) { >> /* dst = src */ >> case BPF_ALU | BPF_MOV | BPF_X: >> + if (imm == 1) { >> + emit_insn(ctx, lu32id, reg, 0); > > reg ? > >> + break; ... >> /* dst = dst & imm */ >> case BPF_ALU | BPF_AND | BPF_K: >> + if (is_unsigned_imm12(imm)) { >> + emit_insn(ctx, andi, dst, dst, imm); >> + } else { >> + move_imm(ctx, t1, imm); >> + emit_insn(ctx, and, dst, dst, t1); >> + } >> + emit_insn(ctx, addiw, dst, dst, 0); > > break; ? Thanks for your review. As mentioned in the cover letter, this hasn't been tested. I just want to confirm that this is the correct direction. The long-term goal is to eliminate frequent and redundant zero-extensions and sign-extensions, but there are still some issues to sort out. I will send the formal patch once all problems are fixed. For now, I will send out the stable and verified patches first this week. Thanks, Tiezhu