bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: Song Liu <liu.song.a23@gmail.com>,
	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, 03 Oct 2019 14:08:36 -0700	[thread overview]
Message-ID: <5d9663547acce_59e82ace6a9345b4a3@john-XPS-13-9370.notmuch> (raw)
In-Reply-To: <CAPhsuW6==Ukxjh69SVLusC=GMf=65Y2T0gLNig55obwbS-7VqQ@mail.gmail.com>

Song Liu wrote:
> 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>

Bonus points for causing me to spend the morning remembering the
differences between cmd, and, or, and test.

Also wonder if at some point we should clean up the jit a bit and
add some defines/helpers for all the open coded opcodes and such.

Acked-by: John Fastabend <john.fastabend@gmail.com>

  reply	other threads:[~2019-10-03 21:08 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 ` [PATCH bpf-next 1/2] bpf, x86: Small optimization in comparing against imm0 Song Liu
2019-10-03 21:08   ` John Fastabend [this message]
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:

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

  git send-email \
    --in-reply-to=5d9663547acce_59e82ace6a9345b4a3@john-XPS-13-9370.notmuch \
    --to=john.fastabend@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=liu.song.a23@gmail.com \
    --cc=netdev@vger.kernel.org \


* 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).