public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "goswin-v-b at web dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/105521] missed optimization in modulo arithmetic
Date: Sun, 08 May 2022 12:45:41 +0000 [thread overview]
Message-ID: <bug-105521-4-ghDPxvrwcv@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-105521-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105521
--- Comment #3 from Goswin von Brederlow <goswin-v-b at web dot de> ---
(In reply to Andrew Pinski from comment #1)
> This requires having a, 64bit/32bit (and 128bit/64bit) pattern really. So
> this is both a middle-end issue and a target issue.
>
> Note there might be another bug asking for the same optimization.
>
> Also note x86_64 might be the only popular target which has this kind of div
> instruction so this might not get any attention as it is also a small
> peephole where most people don't use 128bit integers either (they are
> non-standard even).
I know m68k had a 64bit/32bit pattern but it is indeed rare.
On x86_64 a (32bit * 32bit = 64bit) % 32bit uses the 128bit/64bit DIV
instruction and two extra truncation to 32bit for the input registers. On many
cpus that is significantly (factor 3-10) slower than the 64bit/32bit version.
This could potentially affect every / and % operation and preceding *, allowing
for the faster opcodes with fewer bits to be used where the compiler can reason
about the magnitude of the arguments.
prev parent reply other threads:[~2022-05-08 12:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-08 4:08 [Bug c/105521] New: " goswin-v-b at web dot de
2022-05-08 4:38 ` [Bug target/105521] " pinskia at gcc dot gnu.org
2022-05-08 4:38 ` pinskia at gcc dot gnu.org
2022-05-08 4:40 ` pinskia at gcc dot gnu.org
2022-05-08 12:45 ` goswin-v-b at web dot de [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=bug-105521-4-ghDPxvrwcv@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.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).