public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Siddhesh Poyarekar <siddhesh@gotplt.org>
To: Noah Goldstein <goldstein.w.n@gmail.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH v1 1/3] string: Add len=0 to {w}memcmp{eq} tests and benchtests
Date: Mon, 31 Oct 2022 09:19:29 -0400	[thread overview]
Message-ID: <68b73e71-3806-91ba-ef48-69db951a45a8@gotplt.org> (raw)
In-Reply-To: <20221029201959.4082193-1-goldstein.w.n@gmail.com>

LGTM.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

On 2022-10-29 16:19, Noah Goldstein via Libc-alpha wrote:
> len=0 is valid and fairly common so should be tested.
> ---
>   benchtests/bench-memcmp.c | 18 +++++++++---------
>   string/test-memcmp.c      | 16 ++++++++++------
>   2 files changed, 19 insertions(+), 15 deletions(-)
> 
> diff --git a/benchtests/bench-memcmp.c b/benchtests/bench-memcmp.c
> index d64eaa992e..b2816baebe 100644
> --- a/benchtests/bench-memcmp.c
> +++ b/benchtests/bench-memcmp.c
> @@ -63,7 +63,7 @@ IMPL (MEMCMP, 1)
>   
>   static void
>   do_one_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s1,
> -	     const CHAR *s2, size_t len, int exp_result)
> +	     const CHAR *s2, size_t len)
>   {
>     size_t i, iters = INNER_LOOP_ITERS_LARGE;
>     timing_t start, stop, cur;
> @@ -87,9 +87,6 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len,
>     size_t i;
>     CHAR *s1, *s2;
>   
> -  if (len == 0)
> -    return;
> -
>     align1 &= (4096 - CHARBYTES);
>     if (align1 + (len + 1) * CHARBYTES >= page_size)
>       return;
> @@ -111,13 +108,16 @@ do_test (json_ctx_t *json_ctx, size_t align1, size_t align2, size_t len,
>     for (i = 0; i < len; i++)
>       s1[i] = s2[i] = 1 + (23 << ((CHARBYTES - 1) * 8)) * i % MAX_CHAR;
>   
> -  s1[len] = align1;
> -  s2[len] = align2;
> -  s2[len - 1] -= exp_result;
> +  if (len)
> +    {
> +      s1[len] = align1;
> +      s2[len] = align2;
> +      s2[len - 1] -= exp_result;
> +    }
>   
>     FOR_EACH_IMPL (impl, 0)
>       {
> -      do_one_test (json_ctx, impl, s1, s2, len, exp_result);
> +      do_one_test (json_ctx, impl, s1, s2, len);
>       }
>   
>     json_array_end (json_ctx);
> @@ -147,7 +147,7 @@ test_main (void)
>     json_array_end (&json_ctx);
>   
>     json_array_begin (&json_ctx, "results");
> -  for (i = 1; i < 32; ++i)
> +  for (i = 0; i < 32; ++i)
>       {
>         do_test (&json_ctx, i * CHARBYTES, i * CHARBYTES, i, 0);
>         do_test (&json_ctx, i * CHARBYTES, i * CHARBYTES, i, 1);
> diff --git a/string/test-memcmp.c b/string/test-memcmp.c
> index 181b689f68..18d8b0d9f1 100644
> --- a/string/test-memcmp.c
> +++ b/string/test-memcmp.c
> @@ -117,9 +117,6 @@ do_test (size_t align1, size_t align2, size_t len, int exp_result)
>     size_t i;
>     CHAR *s1, *s2;
>   
> -  if (len == 0)
> -    return;
> -
>     align1 &= (4096 - CHARBYTES);
>     if (align1 + (len + 1) * CHARBYTES >= page_size)
>       return;
> @@ -134,9 +131,16 @@ do_test (size_t align1, size_t align2, size_t len, int exp_result)
>     for (i = 0; i < len; i++)
>       s1[i] = s2[i] = 1 + (23 << ((CHARBYTES - 1) * 8)) * i % CHAR__MAX;
>   
> -  s1[len] = align1;
> -  s2[len] = align2;
> -  s2[len - 1] -= exp_result;
> +  if (len)
> +    {
> +      s1[len] = align1;
> +      s2[len] = align2;
> +      s2[len - 1] -= exp_result;
> +    }
> +  else
> +    {
> +      exp_result = 0;
> +    }
>   
>     FOR_EACH_IMPL (impl, 0)
>       do_one_test (impl, s1, s2, len, exp_result);

      parent reply	other threads:[~2022-10-31 13:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-29 20:19 Noah Goldstein
2022-10-29 20:19 ` [PATCH v1 2/3] x86: Use VMM API in memcmp-evex-movbe.S and minor changes Noah Goldstein
2022-10-31 15:47   ` H.J. Lu
2022-10-29 20:19 ` [PATCH v1 3/3] x86: Use VMM API in memcmpeq-evex.S " Noah Goldstein
2022-10-31 15:48   ` H.J. Lu
2022-10-31 16:42     ` Noah Goldstein
2022-10-31 13:19 ` Siddhesh Poyarekar [this message]

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=68b73e71-3806-91ba-ef48-69db951a45a8@gotplt.org \
    --to=siddhesh@gotplt.org \
    --cc=goldstein.w.n@gmail.com \
    --cc=libc-alpha@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).