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=1693404499; bh=2rPjSj4uwqIpKtOZtB9CZIjdRYw0Gfa1l2U++6sPXLI=; h=References:In-Reply-To:From:Date:Subject:To:Cc; b=g07yWZlvRC0xVnKrJ2qCKZuJqL/F7wK5UDSGolEsBIfnPlQsCRz6SvpmavEL7pHT7 VG7dmix+TihOirgxoD8te1QG4deqBs8GR/ASkE8mUerDj0uTmOCA2/MGHHH/fwohxu S5hyIdxcJsKUFiX75uvwXJejS4XuuV7DngxaOnC5kxm+Lnvitep01LCj9XJISGgJm5 kv9YKuy3p2yGxyuwZoMpI2kMqt4jcaAVRRyE72NmsNVoHzxm3RfJlt5fBqS8+dnP0l 2Ixs7mI8LmRC8LRcqNBZnaXoztPSg5bYvj8eSOd4SA25+SUGykEVerCD4oI6/jHOSV 3xYxM2ahr/1Mg== Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by gnuweeb.org (Postfix) with ESMTPSA id 5C43224B337 for ; Wed, 30 Aug 2023 21:08:19 +0700 (WIB) Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-4ff9b389677so8761509e87.3 for ; Wed, 30 Aug 2023 07:08:19 -0700 (PDT) X-Gm-Message-State: AOJu0YyQ+VjAoDq6h8mt2IlUYaCQXh61S6zjQ3QjOCkP0eS0e+56CymE IRfOXSC5Vlpb7nDMqyZrUQ78nK9W98wWImJek9w= X-Google-Smtp-Source: AGHT+IEbVPGFfSyhPzFLepWZwQvMOr16fe1WwB+fGC2q4nCTtbZAeJaaXsWM58fM5+tjMmjOPDmmCUJBM9ZOrGCQ0wE= X-Received: by 2002:a05:6512:402a:b0:500:9977:bdce with SMTP id br42-20020a056512402a00b005009977bdcemr1945766lfb.62.1693404497078; Wed, 30 Aug 2023 07:08:17 -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:08:05 +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: > +".section .text.nolibc_memset\n" > +".weak memset\n" > +"memset:\n" > + "movq %rsi, %rax\n" > + "movq %rdx, %rcx\n" > + "movq %rdi, %rdx\n" > + "rep stosb\n" > + "movq %rdx, %rax\n" > + "retq\n" The first instruction could be: movl %esi, %eax That's smaller. Also, the second argument of memset() is an int anyway, so there is no need to have a full 64-bit copy of %rsi in %rax. -- Viro