From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6359C10F14 for ; Thu, 3 Oct 2019 20:52:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7D799215EA for ; Thu, 3 Oct 2019 20:52:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jv0u/kP1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729551AbfJCUw1 (ORCPT ); Thu, 3 Oct 2019 16:52:27 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:36170 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727587AbfJCUw0 (ORCPT ); Thu, 3 Oct 2019 16:52:26 -0400 Received: by mail-qt1-f194.google.com with SMTP id o12so5609171qtf.3; Thu, 03 Oct 2019 13:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Fd92yCGjcK8Q9vbQjHTIvNq1EPtzw5PFxZpME5UvlKc=; b=jv0u/kP1kYnE3p1bQFj8W5PnzbxjxEdOcfHiMWUIgzj9NeaWD0QvucgMPJTIjUiDfX Yz33koSB4JoEUcpTfU/pKw1NIN6QVlnxWIr/+NtTQ3ZbW+dSKC+IIrL1H63v/qx0RVVJ YJE21hl4SbOuPqv4moDqgjtSopd8XakZ1JYMbGfQm0lal1lb67ubtQR2+t8VCsj4wnEt KFLpIJJZayZwaRjt4vFd7GURK37gatmNVqGhxHogG46auKD/kmZumMvHZg41QZRzp/sV SpDnVVaaEGPWphLDC+Yxubdocxr3buLmE6kOYnsWULa/IyP/GfG8ScauweEmX9zRlTjx MqpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Fd92yCGjcK8Q9vbQjHTIvNq1EPtzw5PFxZpME5UvlKc=; b=t1f76omWIXPd2zFGyjpS1w8dq0hDMBPzJjBkY1UbztPA3Ey50g87+Ibmfnp8cDvDRt ATwdZMycncwrELMK7QEPFI7BAxw0GUR/+wvw9TpqVaqTdwrC1KzAA+WRP++bAVVwcR0k OiNIhkAcTNwVVxVwZ+j30RdFCpvbMItPCQmXyAQKCOaJgNe977BGgX6WWX1Tp8lAKeRF qxcLQ0U/kZ9z3kvmLIbLicKgqqbbQOitlLuSKAKNhBI+g6MplDbvl5Ni7EGyIlMF0xis GN2g1vLKcfOWyNAhMlPklrmME3+VIct3mOvt7h1ILQCo5JO2TzbtkPobKIfSGdZ0PZUK wGPA== X-Gm-Message-State: APjAAAVd5Xn7L77iRHcQ+g3H1foZ/6DUa1JWMkzzNA6tq3xhRk9ow4Ts sFJpvnOatNizZ1Scc+nzC3ktIfvwRqfy4pn4Ryo= X-Google-Smtp-Source: APXvYqxkv8rerDFWmbferqiZ2NDV+sLIi1PoseuP0HFJ9xlnB0nxFAs/FkN6WkNd6Gkur5s1Iy8OBbho4cCA4VMX9wI= X-Received: by 2002:ac8:37cb:: with SMTP id e11mr12491917qtc.22.1570135945995; Thu, 03 Oct 2019 13:52:25 -0700 (PDT) MIME-Version: 1.0 References: <20191002234512.25902-1-daniel@iogearbox.net> In-Reply-To: <20191002234512.25902-1-daniel@iogearbox.net> From: Song Liu Date: Thu, 3 Oct 2019 13:52:14 -0700 Message-ID: Subject: Re: [PATCH bpf-next 1/2] bpf, x86: Small optimization in comparing against imm0 To: Daniel Borkmann Cc: Alexei Starovoitov , bpf , Networking Content-Type: text/plain; charset="UTF-8" Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Wed, Oct 2, 2019 at 5:30 PM Daniel Borkmann 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 Acked-by: Song Liu