bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Song Liu <liu.song.a23@gmail.com>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: Alexei Starovoitov <ast@kernel.org>, bpf <bpf@vger.kernel.org>,
	Networking <netdev@vger.kernel.org>
Subject: Re: [PATCH bpf-next 1/2] bpf, x86: Small optimization in comparing against imm0
Date: Thu, 3 Oct 2019 13:52:14 -0700	[thread overview]
Message-ID: <CAPhsuW6==Ukxjh69SVLusC=GMf=65Y2T0gLNig55obwbS-7VqQ@mail.gmail.com> (raw)
In-Reply-To: <20191002234512.25902-1-daniel@iogearbox.net>

On Wed, Oct 2, 2019 at 5:30 PM Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> Replace 'cmp reg, 0' with 'test reg, reg' for comparisons against
> zero. Saves 1 byte of instruction encoding per occurrence. The flag
> results of test 'reg, reg' are identical to 'cmp reg, 0' in all
> cases except for AF which we don't use/care about. In terms of
> macro-fusibility in combination with a subsequent conditional jump
> instruction, both have the same properties for the jumps used in
> the JIT translation. For example, same JITed Cilium program can
> shrink a bit from e.g. 12,455 to 12,317 bytes as tests with 0 are
> used quite frequently.
>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

Acked-by: Song Liu <songliubraving@fb.com>

  parent reply	other threads:[~2019-10-03 20:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-02 23:45 [PATCH bpf-next 1/2] bpf, x86: Small optimization in comparing against imm0 Daniel Borkmann
2019-10-02 23:45 ` [PATCH bpf-next 2/2] bpf: Add loop test case with 32 bit reg comparison against 0 Daniel Borkmann
2019-10-03 20:56   ` Song Liu
2019-10-03 20:52 ` Song Liu [this message]
2019-10-03 21:08   ` [PATCH bpf-next 1/2] bpf, x86: Small optimization in comparing against imm0 John Fastabend
2019-10-04 19:36     ` Alexei Starovoitov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPhsuW6==Ukxjh69SVLusC=GMf=65Y2T0gLNig55obwbS-7VqQ@mail.gmail.com' \
    --to=liu.song.a23@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).