提交 88e69a1f 编写于 作者: D Daniel Borkmann 提交者: Alexei Starovoitov

bpf, x64: save one byte per shl/shr/sar when imm is 1

When we shift by one, we can use a different encoding where imm
is not explicitly needed, which saves 1 byte per such op.
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
上级 ee07862f
...@@ -640,6 +640,10 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image, ...@@ -640,6 +640,10 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image,
case BPF_RSH: b3 = 0xE8; break; case BPF_RSH: b3 = 0xE8; break;
case BPF_ARSH: b3 = 0xF8; break; case BPF_ARSH: b3 = 0xF8; break;
} }
if (imm32 == 1)
EMIT2(0xD1, add_1reg(b3, dst_reg));
else
EMIT3(0xC1, add_1reg(b3, dst_reg), imm32); EMIT3(0xC1, add_1reg(b3, dst_reg), imm32);
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册