diff options
author | Jie Meng <jmeng@fb.com> | 2021-10-01 20:56:26 -0700 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2021-10-06 15:24:36 +0200 |
commit | 57a610f1c58fa493315e1c24eef6d992cdf4c4a9 (patch) | |
tree | b19776aea72a4c4a6bf2d48e8cebccd281375f6d /tools/lib | |
parent | 0640c77c46cb84328d5e08aa85a781a60be8b02b (diff) | |
download | linux-57a610f1c58fa493315e1c24eef6d992cdf4c4a9.tar.gz |
bpf, x64: Save bytes for DIV by reducing reg copies
Instead of unconditionally performing push/pop on %rax/%rdx in case of
division/modulo, we can save a few bytes in case of destination register
being either BPF r0 (%rax) or r3 (%rdx) since the result is written in
there anyway.
Also, we do not need to copy the source to %r11 unless the source is either
%rax, %rdx or an immediate.
For example, before the patch:
22: push %rax
23: push %rdx
24: mov %rsi,%r11
27: xor %edx,%edx
29: div %r11
2c: mov %rax,%r11
2f: pop %rdx
30: pop %rax
31: mov %r11,%rax
After:
22: push %rdx
23: xor %edx,%edx
25: div %rsi
28: pop %rdx
Signed-off-by: Jie Meng <jmeng@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20211002035626.2041910-1-jmeng@fb.com
Diffstat (limited to 'tools/lib')
0 files changed, 0 insertions, 0 deletions