From: Markus Wichmann <nullplan@gmx.net>
To: musl@lists.openwall.com
Cc: Viktor Reznov <yann.collet.is.not.a.perfectionist@gmail.com>
Subject: Re: [musl] [PATCH] Decreasing the number of divisions
Date: Wed, 17 Apr 2024 03:56:05 +0200 [thread overview]
Message-ID: <Zh8sNfTmTwtR4Sn1@voyager> (raw)
In-Reply-To: <kq7ozupkdpannvt6fxnltuap4bhesjot5sbqhnwe5hpvey7nht@qj3jonh36ngt>
Am Wed, Apr 17, 2024 at 01:25:18AM +0000 schrieb NRK:
> > I played around with this change on godbolt: https://godbolt.org/z/9PoGK9zae
>
> You're looking at clang -O3, if you use gcc -Os (usual for musl
> users/distros) you'll notice that gcc actually ends up emitting a div
> instruction, which are known to be slow.
>
> But I don't think trying to optimize around gcc's bad codegen is the
> right move. It's better to just not use -Os with gcc. Which musl already
> does since commit b90841e25832.
>
> - NRK
Well, yeah, if you use -Os and expect fast code, you are doing it wrong.
-Os explicitly asks for small code rather than fast. It is appropriate
for code that ends up having to fit in a ROM or a bootsector or
something, but otherwise I can't really see the point.
I remember once reading the insane claim that -Os code ends up being
faster than -O3 because the code fits in cache, but much as the OP in
this thread, there was no benchmark to actually show this. I call it
insane because -O3 is telling GCC explicitly to output the fastest code
possible, and in my experience it generally does.
Ciao,
Markus
next prev parent reply other threads:[~2024-04-17 1:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-16 13:29 Viktor Reznov
2024-04-16 14:29 ` Markus Wichmann
2024-04-17 1:25 ` NRK
2024-04-17 1:56 ` Markus Wichmann [this message]
2024-04-16 14:38 ` Rich Felker
[not found] ` <CAKs8_OKqKsLbG_Cf0DtDGeZDLdFkO1kDx6z5Fg_rQwPxPLGP6g@mail.gmail.com>
2024-04-16 16:55 ` Rich Felker
[not found] ` <CAKs8_OJ4evmTzAGVZ1Yccw+4Jj7v=RwEJWicwbSoeQwbvqav1Q@mail.gmail.com>
2024-04-17 0:09 ` [musl] " Rich Felker
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=Zh8sNfTmTwtR4Sn1@voyager \
--to=nullplan@gmx.net \
--cc=musl@lists.openwall.com \
--cc=yann.collet.is.not.a.perfectionist@gmail.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).