From: Segher Boessenkool <segher@kernel.crashing.org>
To: Pat Haugen <pthaugen@linux.ibm.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
"Kewen.Lin" <linkw@linux.ibm.com>,
David Edelsohn <dje.gcc@gmail.com>,
Peter Bergner <bergner@linux.ibm.com>
Subject: Re: [PATCH, rs6000] Tweak modulo define_insns to eliminate register copy
Date: Mon, 27 Feb 2023 11:08:35 -0600 [thread overview]
Message-ID: <20230227170835.GA25951@gate.crashing.org> (raw)
In-Reply-To: <3cad2a5e-dd68-2fbe-d52b-e077a7405623@linux.ibm.com>
Hi!
On Mon, Feb 27, 2023 at 09:11:37AM -0600, Pat Haugen wrote:
> The define_insns for the modulo operation currently force the target
> register
> to a distinct reg in preparation for a possible future peephole combining
> div/mod. But this can lead to cases of a needless copy being inserted. Fixed
> with the following patch.
Have you verified those peepholes still match?
Do those peepholes actually improve performance? On new CPUs? The code
here says
;; On machines with modulo support, do a combined div/mod the old fashioned
;; method, since the multiply/subtract is faster than doing the mod instruction
;; after a divide.
but that really should not be true: we can do the div and mod in
parallel (except in SMT4 perhaps, which we never schedule for anyway),
so that should always be strictly faster.
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/mod-no_copy.c
> @@ -0,0 +1,17 @@
> +/* { dg-do compile { target { powerpc*-*-* } } } */
All files in gcc.target/powerpc/ test for this already. Just leave off
the target clause here?
> +/* { dg-require-effective-target powerpc_p9modulo_ok } */
Leave out this line, because ...
> +/* { dg-options "-mdejagnu-cpu=power9 -O2" } */
... the -mcpu= forces it to true always.
> +/* Verify r3 is used as source and target, no copy inserted. */
> +/* { dg-final { scan-assembler-not {\mmr\M} } } */
That is probably good enough, yeah, since the test results in only a
handful of insns.
Segher
next prev parent reply other threads:[~2023-02-27 17:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-27 15:11 Pat Haugen
2023-02-27 17:08 ` Segher Boessenkool [this message]
2023-02-27 20:12 ` Pat Haugen
2023-02-27 20:53 ` Segher Boessenkool
2023-02-27 22:03 ` Pat Haugen
2023-02-27 22:30 ` Segher Boessenkool
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=20230227170835.GA25951@gate.crashing.org \
--to=segher@kernel.crashing.org \
--cc=bergner@linux.ibm.com \
--cc=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=linkw@linux.ibm.com \
--cc=pthaugen@linux.ibm.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).