public inbox for libc-stable@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Florian Weimer <fweimer@redhat.com>,
	 Libc-stable Mailing List <libc-stable@sourceware.org>
Cc: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>
Subject: Re: V2 [PATCH] x86-64: Avoid rep movsb with short distance [BZ #27130]
Date: Mon, 4 Jan 2021 07:54:53 -0800	[thread overview]
Message-ID: <CAMe9rOpbyuVCKByrgrm6xgJPsiQUEuNEMZGOu_75VtWbEu1cZg@mail.gmail.com> (raw)
In-Reply-To: <87wnwsk8lh.fsf@oldenburg2.str.redhat.com>

On Mon, Jan 4, 2021 at 7:47 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > On Mon, Jan 4, 2021 at 7:22 AM Florian Weimer <fweimer@redhat.com> wrote:
> >>
> >> * H. J. Lu via Libc-alpha:
> >>
> >> >  1:
> >> > +# if AVOID_SHORT_DISTANCE_REP_MOVSB
> >> > +     movq    %rsi, %rcx
> >> > +     subq    %rdi, %rcx
> >> > +2:
> >> > +/* Avoid "rep movsb" if RCX, the distance between source and destination,
> >> > +   is N*4GB + [1..63] with N >= 0.  */
> >> > +     cmpl    $63, %ecx
> >> > +     jbe     L(more_2x_vec)  /* Avoid "rep movsb" if ECX <= 63.  */
> >> > +# endif
> >> >       mov     %RDX_LP, %RCX_LP
> >> >       rep movsb
> >> >  L(nop):
> >>
> >> Why not use _LP names here?  I think the %ecx comparison at least can
> >> give false results on x86-64 (64-bit).
> >>
> >
> > This is done on purpose since we want to avoid "rep movsb" for distances of
> > N*4GB + [1..63] with N >= 0 which include 0x100000003.
>
> Ah, and the comment is quite clear (the commit subject less so).

It isn't easy to describe it with so few letters.

> I tried to make sense of the assembler code, and I think the change is
> okay because L(movsb) is only reached when there is more to copy than
> twice the vector size.
>

That is correct.  I am checking it in.  I will backport it to release branches
next week.

Thanks.

-- 
H.J.

           reply	other threads:[~2021-01-04 15:55 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <87wnwsk8lh.fsf@oldenburg2.str.redhat.com>]

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=CAMe9rOpbyuVCKByrgrm6xgJPsiQUEuNEMZGOu_75VtWbEu1cZg@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=libc-stable@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).