From: Richard Biener <richard.guenther@gmail.com>
To: "Maciej W. Rozycki" <macro@orcam.me.uk>
Cc: Jeff Law <jeffreyalaw@gmail.com>,
Andrew Pinski <pinskia@gmail.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
gcc-patches@gcc.gnu.org
Subject: Re: RISC-V: Add divmod instruction support
Date: Mon, 20 Feb 2023 09:11:37 +0100 [thread overview]
Message-ID: <CAFiYyc2o0Gtu63ENpnULpovNevUm6Oxb3cCBDc+Ag=GOHhauhA@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.21.2302190110550.25434@angie.orcam.me.uk>
On Sun, Feb 19, 2023 at 2:15 AM Maciej W. Rozycki <macro@orcam.me.uk> wrote:
>
> On Sat, 18 Feb 2023, Jeff Law wrote:
>
> > > Barring the fusion case, which indeed asks for a dedicated `divmod'
> > > pattern (and then I suppose a post-reload splitter or a peephole so that
> > > where one of the two results produced has eventually turned out unused, we
> > > have means to discard the unneeded machine instruction), isn't the generic
> > > transformation something for the middle end to do based on RTX costs?
> > I originally though the same way you did Maciej.
> >
> > The problem is you don't see it as a divmod in expand_divmod unless you expose
> > a divmod optab. See tree-ssa-mathopts.cc's divmod handling.
>
> That's the kind of stuff I'd expect to happen at the tree level though,
> before expand.
The GIMPLE pass forming divmod could indeed choose to emit the
div + mul/sub sequence instead if an actual divmod pattern isn't available.
It could even generate some fake mul/sub/mod RTXen to cost the two
variants against each other but I seriously doubt any uarch that implements
division/modulo has a slower mul/sub.
Richard.
>
> Maciej
next prev parent reply other threads:[~2023-02-20 10:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-17 14:02 Matevos Mehrabyan
2023-02-18 18:26 ` Palmer Dabbelt
2023-02-18 18:42 ` Andrew Pinski
2023-02-18 19:26 ` Palmer Dabbelt
2023-02-18 19:31 ` Maciej W. Rozycki
2023-02-18 20:57 ` Prathamesh Kulkarni
2023-02-18 21:07 ` Jeff Law
2023-02-19 1:14 ` Maciej W. Rozycki
2023-02-20 8:11 ` Richard Biener [this message]
2023-02-20 13:32 ` Alexander Monakov
2023-02-28 12:54 ` Maciej W. Rozycki
2023-02-18 21:06 ` Jeff Law
2023-02-18 21:30 ` Palmer Dabbelt
2023-02-18 21:57 ` Jeff Law
2023-02-20 1:27 ` Andrew Waterman
2023-04-28 20:09 ` Jeff Law
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='CAFiYyc2o0Gtu63ENpnULpovNevUm6Oxb3cCBDc+Ag=GOHhauhA@mail.gmail.com' \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jeffreyalaw@gmail.com \
--cc=macro@orcam.me.uk \
--cc=palmer@dabbelt.com \
--cc=pinskia@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.
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).