From: Florian Weimer <fweimer@redhat.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
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, 04 Jan 2021 16:47:06 +0100 [thread overview]
Message-ID: <87wnwsk8lh.fsf@oldenburg2.str.redhat.com> (raw)
In-Reply-To: <CAMe9rOqENAGBdV6Kuz+4dW5aoR3CR38-qyqiN76jcWhETUt8Cw@mail.gmail.com> (H. J. Lu's message of "Mon, 4 Jan 2021 07:27:16 -0800")
* 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).
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.
Thanks,
Florian
--
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill
next prev parent reply other threads:[~2021-01-04 15:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-04 15:17 H.J. Lu
2021-01-04 15:22 ` Florian Weimer
2021-01-04 15:27 ` H.J. Lu
2021-01-04 15:47 ` Florian Weimer [this message]
2021-01-04 15:54 ` H.J. Lu
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=87wnwsk8lh.fsf@oldenburg2.str.redhat.com \
--to=fweimer@redhat.com \
--cc=hjl.tools@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).