mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Robert Clausecker <fuz@fuz.su>
To: musl@lists.openwall.com
Subject: Re: [musl] [PATCH] add memcmpeq: memcmp that returns length of first mismatch
Date: Thu, 29 Feb 2024 01:57:48 +0100	[thread overview]
Message-ID: <Zd_WjNcFLBWFkAIG@fuz.su> (raw)
In-Reply-To: <Pine.BSM.4.64L.2402290007490.1531@herc.mirbsd.org>

Greetings,

Am Thu, Feb 29, 2024 at 12:10:05AM +0000 schrieb Thorsten Glaser:
> Pedro Falcato dixit:
> 
> >Small note: This isn't quite true for remotely modern x86, unaligned
> 
> It’s very much true, e.g. it breaks atomicity (ok, not relevant
> *here*, but in general).
> 
> AIUI, even modern amd64 chips of all vendors are reverting to
> optimising rep movsb/lodsb instead again, for stringops.

That is not the case.  REP MOVSB and friends have a high startup latency,
so you only want to use them for large-ish blocks.  Too large and all of
the sudden AVX-512 is faster again.  For small blocks however, you do not
want to use this instruction.  It's indeed much better to do a pair of
overlapping stores.  They do not perform crazy well, but it's still better
than all alternatives.

Also note that REP LODSB is pretty useless; did you perhaps mean REP STOSB?

Source: have spent a good part of last year implementing <string.h> in
x86 assembly for FreeBSD's libc.

> Of course the status on other architectures should be sufficient to
> not use unaligned accesses.

Yours,
Robert Clausecker

-- 
()  ascii ribbon campaign - for an encoding-agnostic world
/\  - against html email  - against proprietary attachments

  reply	other threads:[~2024-02-29  0:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27 14:07 James Tirta Halim
2024-02-27 14:49 ` Rich Felker
2024-02-27 14:51   ` Rich Felker
2024-02-28  4:40     ` Markus Wichmann
2024-02-28 23:14       ` Thorsten Glaser
2024-02-29  0:02         ` Pedro Falcato
2024-02-29  0:10           ` Thorsten Glaser
2024-02-29  0:57             ` Robert Clausecker [this message]
2024-02-29  1:13               ` Pedro Falcato
2024-02-29  4:19         ` Markus Wichmann

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=Zd_WjNcFLBWFkAIG@fuz.su \
    --to=fuz@fuz.su \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).