From: Richard Biener <richard.guenther@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] DSE: Use the constant source if possible
Date: Mon, 23 May 2022 12:38:06 +0200 [thread overview]
Message-ID: <CAFiYyc2N720wQiSo8mj2W4e1Um-fnX+eGuhPRVuyQyRHFd4t2g@mail.gmail.com> (raw)
In-Reply-To: <20220521030120.1977551-1-hjl.tools@gmail.com>
On Sat, May 21, 2022 at 5:02 AM H.J. Lu via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> When recording store for RTL dead store elimination, check if the source
> register is set only once to a constant. If yes, record the constant
> as the store source. It eliminates unrolled zero stores after memset 0
> in a loop where a vector register is used as the zero store source.
>
> gcc/
>
> PR rtl-optimization/105638
> * dse.cc (record_store): Use the constant source if the source
> register is set only once.
>
> gcc/testsuite/
>
> PR rtl-optimization/105638
> * g++.target/i386/pr105638.C: New test.
> ---
> gcc/dse.cc | 19 ++++++++++
> gcc/testsuite/g++.target/i386/pr105638.C | 44 ++++++++++++++++++++++++
> 2 files changed, 63 insertions(+)
> create mode 100644 gcc/testsuite/g++.target/i386/pr105638.C
>
> diff --git a/gcc/dse.cc b/gcc/dse.cc
> index 30c11cee034..0433dd3d846 100644
> --- a/gcc/dse.cc
> +++ b/gcc/dse.cc
> @@ -1508,6 +1508,25 @@ record_store (rtx body, bb_info_t bb_info)
>
> if (tem && CONSTANT_P (tem))
> const_rhs = tem;
> + else
> + {
> + /* If RHS is set only once to a constant, set CONST_RHS
> + to the constant. */
> + df_ref def = DF_REG_DEF_CHAIN (REGNO (rhs));
> + if (def != nullptr
> + && !DF_REF_IS_ARTIFICIAL (def)
> + && !DF_REF_NEXT_REG (def))
> + {
> + rtx_insn *def_insn = DF_REF_INSN (def);
> + rtx def_body = PATTERN (def_insn);
> + if (GET_CODE (def_body) == SET)
> + {
> + rtx def_src = SET_SRC (def_body);
> + if (CONSTANT_P (def_src))
> + const_rhs = def_src;
doesn't DSE have its own tracking of stored values? Shouldn't we
improve _that_ if it is not enough? I also wonder if you need to
verify the SET isn't partial?
Richard.
> + }
> + }
> + }
> }
> }
>
> diff --git a/gcc/testsuite/g++.target/i386/pr105638.C b/gcc/testsuite/g++.target/i386/pr105638.C
> new file mode 100644
> index 00000000000..ff40a459de1
> --- /dev/null
> +++ b/gcc/testsuite/g++.target/i386/pr105638.C
> @@ -0,0 +1,44 @@
> +/* { dg-do compile { target { ! ia32 } } } */
> +/* { dg-options "-std=gnu++20 -O2 -march=skylake" } */
> +/* { dg-final { scan-assembler-not "vpxor" } } */
> +
> +#include <stdint.h>
> +#include <vector>
> +#include <tr1/array>
> +
> +class FastBoard {
> +public:
> + typedef std::pair<int, int> movescore_t;
> + typedef std::tr1::array<movescore_t, 24> scoredlist_t;
> +
> +protected:
> + std::vector<int> m_critical;
> +
> + int m_boardsize;
> +};
> +
> +class FastState {
> +public:
> + FastBoard board;
> +
> + int movenum;
> +protected:
> + FastBoard::scoredlist_t scoredmoves;
> +};
> +
> +class KoState : public FastState {
> +private:
> + std::vector<uint64_t> ko_hash_history;
> + std::vector<uint64_t> hash_history;
> +};
> +
> +class GameState : public KoState {
> +public:
> + void foo ();
> +private:
> + std::vector<KoState> game_history;
> +};
> +
> +void GameState::foo() {
> + game_history.resize(movenum);
> +}
> --
> 2.36.1
>
next prev parent reply other threads:[~2022-05-23 10:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-21 3:01 H.J. Lu
2022-05-23 10:38 ` Richard Biener [this message]
2022-05-23 18:34 ` [PATCH v2] DSE: Use the constant store " H.J. Lu
2022-05-24 6:42 ` Richard Biener
2022-05-24 20:10 ` H.J. Lu
2022-05-25 9:22 ` Richard Biener
2022-05-25 9:30 ` Richard Sandiford
2022-05-25 19:01 ` H.J. Lu
2022-05-25 7:30 ` Richard Sandiford
2022-05-25 18:56 ` H.J. Lu
2022-05-26 15:14 ` Richard Sandiford
2022-05-26 20:43 ` [PATCH v3] " H.J. Lu
2022-05-28 18:37 ` Jeff Law
2022-05-29 21:43 ` H.J. Lu
2022-05-29 22:55 ` Jeff Law
2022-05-30 8:28 ` Richard Sandiford
2022-05-30 22:58 ` Jeff Law
2022-05-30 8:35 ` Richard Sandiford
2022-05-31 17:12 ` [PATCH v4] " H.J. Lu
2022-06-01 7:20 ` Richard Sandiford
2022-06-01 21:07 ` H.J. Lu
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=CAFiYyc2N720wQiSo8mj2W4e1Um-fnX+eGuhPRVuyQyRHFd4t2g@mail.gmail.com \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hjl.tools@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).