Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 88e69a1f authored by Daniel Borkmann's avatar Daniel Borkmann Committed by Alexei Starovoitov
Browse files

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: default avatarDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent ee07862f
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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_ARSH: b3 = 0xF8; break;
			}

			if (imm32 == 1)
				EMIT2(0xD1, add_1reg(b3, dst_reg));
			else
				EMIT3(0xC1, add_1reg(b3, dst_reg), imm32);
			break;