From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED, URIBL_DBL_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1693405498; bh=SAJ852dwJOFVNABFj7uHiWKS/atHcQIwsECyB7d1znc=; h=References:In-Reply-To:From:Date:Subject:To:Cc; b=Nx4p3rNN+N6CNu2n5GDBlIYBZ8fiLlVvDVj2BeDp24yOet/R0NXvwDv0FYgfVK26d Tz+/xKcX0ujHa4GwPSJnj1dbQSmUUd+tYuYlEPZbkIVR/fpMex9buASLrN6APCTthV xC8mEYsRc4deRyXGfdllAVFEyEcwHlRGUkImeuaP8lgysFa6H3+W9icQRjxunrHcTh /dV8r2Fo71cW7vST5S08+Kur8iL2HItOTbMwxH+Wx83NhhoCLD4BZs30jyuUPdl6Zd 82y6cGuIQnAQPNYls1pSbXe4sqEkwriQo0CWUaYeShQBKtCrneyNgrdgFazxjUzXyv 0z+Qf59pkwjsw== Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) by gnuweeb.org (Postfix) with ESMTPSA id 8B31224B345 for ; Wed, 30 Aug 2023 21:24:58 +0700 (WIB) Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-4ff09632194so9014782e87.2 for ; Wed, 30 Aug 2023 07:24:58 -0700 (PDT) X-Gm-Message-State: AOJu0YwSPNPHOk/ilXb+ve5wER/uOBRAB5+rhxxvTBcxF8cBbaDGv0hs ZZs4VYrMp3G5G4BzH8WzD6LqD3ei2+L1ft65pYY= X-Google-Smtp-Source: AGHT+IFwyvEFmlcIBHrmZQn42+yIboqEIJDG4VYbfKktDwqPz1Jn9RP7oE8EChawUezFFdIIwfqn0RqmwhDh/I9taes= X-Received: by 2002:a05:6512:3603:b0:4ff:834b:e01b with SMTP id f3-20020a056512360300b004ff834be01bmr1639153lfs.19.1693405496395; Wed, 30 Aug 2023 07:24:56 -0700 (PDT) MIME-Version: 1.0 References: <20230830135726.1939997-1-ammarfaizi2@gnuweeb.org> <20230830135726.1939997-3-ammarfaizi2@gnuweeb.org> In-Reply-To: <20230830135726.1939997-3-ammarfaizi2@gnuweeb.org> From: Alviro Iskandar Setiawan Date: Wed, 30 Aug 2023 21:24:45 +0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH v1 2/5] tools/nolibc: x86-64: Use `rep stosb` for `memset()` To: Ammar Faizi Cc: Willy Tarreau , =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= , Nicholas Rosenberg , Michael William Jonathan , "GNU/Weeb Mailing List" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: On Wed, Aug 30, 2023 at 8:57=E2=80=AFPM Ammar Faizi wrote: > 00000000000010b1 : > 10b1: 48 89 f0 mov %rsi,%rax > 10b4: 48 89 d1 mov %rdx,%rcx > 10b7: 48 89 fa mov %rdi,%rdx > 10ba: f3 aa rep stos %al,%es:(%rdi) > 10bc: 48 89 d0 mov %rdx,%rax > 10bf: c3 ret Just a small idea to shrink this more, "mov %rdi, %rdx" and "mov %rdx, %rax" can be replaced with "push %rdi" and "pop %rax" (they are just a byte). So we can save 4 bytes more. 0000000000001500 : 1500: 48 89 f0 mov %rsi,%rax 1503: 48 89 d1 mov %rdx,%rcx 1506: 57 push %rdi 1507: f3 aa rep stos %al,%es:(%rdi) 1509: 58 pop %rax 150a: c3 ret But I know you don't like it because it costs extra memory access. -- Viro