diff options
author | Daniel Borkmann <daniel@iogearbox.net> | 2018-02-23 19:07:58 -0500 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2018-02-24 01:50:00 -0500 |
commit | 88e69a1fcc1e67dec3025af64736a84532528242 (patch) | |
tree | 3b7969431a064be0e3079257d01f895bf5692f97 /arch/x86/net | |
parent | ee07862f7b4594d390b978f6636a6a6191632ab3 (diff) |
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: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'arch/x86/net')
-rw-r--r-- | arch/x86/net/bpf_jit_comp.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index 4923d92f918d..4bc36bd1b97a 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c | |||
@@ -640,7 +640,11 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image, | |||
640 | case BPF_RSH: b3 = 0xE8; break; | 640 | case BPF_RSH: b3 = 0xE8; break; |
641 | case BPF_ARSH: b3 = 0xF8; break; | 641 | case BPF_ARSH: b3 = 0xF8; break; |
642 | } | 642 | } |
643 | EMIT3(0xC1, add_1reg(b3, dst_reg), imm32); | 643 | |
644 | if (imm32 == 1) | ||
645 | EMIT2(0xD1, add_1reg(b3, dst_reg)); | ||
646 | else | ||
647 | EMIT3(0xC1, add_1reg(b3, dst_reg), imm32); | ||
644 | break; | 648 | break; |
645 | 649 | ||
646 | case BPF_ALU | BPF_LSH | BPF_X: | 650 | case BPF_ALU | BPF_LSH | BPF_X: |