From: Richard Biener <richard.guenther@gmail.com>
To: Andrew Pinski <apinski@marvell.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] PHIOPT: Add dump for match and simplify and early phiopt
Date: Mon, 28 Aug 2023 09:08:38 +0200 [thread overview]
Message-ID: <CAFiYyc3+KOm=pKmV7ugui2ZLsMn3E58-3HJ1caQ0f3E-AkBkXA@mail.gmail.com> (raw)
In-Reply-To: <20230826021458.3624086-1-apinski@marvell.com>
On Sat, Aug 26, 2023 at 4:16 AM Andrew Pinski via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> This adds dump on the full result of the match-and-simplify
> for phiopt and specifically to know if we are rejecting something
> due to being in early phi-opt.
>
> OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
OK.
Richard.
> gcc/ChangeLog:
>
> * tree-ssa-phiopt.cc (gimple_simplify_phiopt): Add dump information
> when resimplify returns true.
> (match_simplify_replacement): Print only if accepted the match-and-simplify
> result rather than the full sequence.
> ---
> gcc/tree-ssa-phiopt.cc | 70 ++++++++++++++++++++++++++----------------
> 1 file changed, 44 insertions(+), 26 deletions(-)
>
> diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
> index 7e63fb115db..9993bbe5b76 100644
> --- a/gcc/tree-ssa-phiopt.cc
> +++ b/gcc/tree-ssa-phiopt.cc
> @@ -499,7 +499,6 @@ gimple_simplify_phiopt (bool early_p, tree type, gimple *comp_stmt,
> tree arg0, tree arg1,
> gimple_seq *seq)
> {
> - tree result;
> gimple_seq seq1 = NULL;
> enum tree_code comp_code = gimple_cond_code (comp_stmt);
> location_t loc = gimple_location (comp_stmt);
> @@ -529,18 +528,29 @@ gimple_simplify_phiopt (bool early_p, tree type, gimple *comp_stmt,
>
> if (op.resimplify (&seq1, follow_all_ssa_edges))
> {
> - /* Early we want only to allow some generated tree codes. */
> - if (!early_p
> - || phiopt_early_allow (seq1, op))
> + bool allowed = !early_p || phiopt_early_allow (seq1, op);
> + tree result = maybe_push_res_to_seq (&op, &seq1);
> + if (dump_file && (dump_flags & TDF_FOLDING))
> {
> - result = maybe_push_res_to_seq (&op, &seq1);
> + fprintf (dump_file, "\nphiopt match-simplify back:\n");
> + if (seq1)
> + print_gimple_seq (dump_file, seq1, 0, TDF_VOPS|TDF_MEMSYMS);
> + fprintf (dump_file, "result: ");
> if (result)
> - {
> - if (loc != UNKNOWN_LOCATION)
> - annotate_all_with_location (seq1, loc);
> - gimple_seq_add_seq_without_update (seq, seq1);
> - return result;
> - }
> + print_generic_expr (dump_file, result);
> + else
> + fprintf (dump_file, " (none)");
> + fprintf (dump_file, "\n");
> + if (!allowed)
> + fprintf (dump_file, "rejected because early\n");
> + }
> + /* Early we want only to allow some generated tree codes. */
> + if (allowed && result)
> + {
> + if (loc != UNKNOWN_LOCATION)
> + annotate_all_with_location (seq1, loc);
> + gimple_seq_add_seq_without_update (seq, seq1);
> + return result;
> }
> }
> gimple_seq_discard (seq1);
> @@ -572,18 +582,29 @@ gimple_simplify_phiopt (bool early_p, tree type, gimple *comp_stmt,
>
> if (op1.resimplify (&seq1, follow_all_ssa_edges))
> {
> - /* Early we want only to allow some generated tree codes. */
> - if (!early_p
> - || phiopt_early_allow (seq1, op1))
> + bool allowed = !early_p || phiopt_early_allow (seq1, op1);
> + tree result = maybe_push_res_to_seq (&op1, &seq1);
> + if (dump_file && (dump_flags & TDF_FOLDING))
> {
> - result = maybe_push_res_to_seq (&op1, &seq1);
> + fprintf (dump_file, "\nphiopt match-simplify back:\n");
> + if (seq1)
> + print_gimple_seq (dump_file, seq1, 0, TDF_VOPS|TDF_MEMSYMS);
> + fprintf (dump_file, "result: ");
> if (result)
> - {
> - if (loc != UNKNOWN_LOCATION)
> - annotate_all_with_location (seq1, loc);
> - gimple_seq_add_seq_without_update (seq, seq1);
> - return result;
> - }
> + print_generic_expr (dump_file, result);
> + else
> + fprintf (dump_file, " (none)");
> + fprintf (dump_file, "\n");
> + if (!allowed)
> + fprintf (dump_file, "rejected because early\n");
> + }
> + /* Early we want only to allow some generated tree codes. */
> + if (allowed && result)
> + {
> + if (loc != UNKNOWN_LOCATION)
> + annotate_all_with_location (seq1, loc);
> + gimple_seq_add_seq_without_update (seq, seq1);
> + return result;
> }
> }
> gimple_seq_discard (seq1);
> @@ -855,6 +876,8 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb,
>
> if (!result)
> return false;
> + if (dump_file && (dump_flags & TDF_FOLDING))
> + fprintf (dump_file, "accepted the phiopt match-simplify.\n");
>
> auto_bitmap exprs_maybe_dce;
>
> @@ -881,11 +904,6 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb,
> if (name && TREE_CODE (name) == SSA_NAME)
> bitmap_set_bit (exprs_maybe_dce, SSA_NAME_VERSION (name));
> }
> - if (dump_file && (dump_flags & TDF_FOLDING))
> - {
> - fprintf (dump_file, "Folded into the sequence:\n");
> - print_gimple_seq (dump_file, seq, 0, TDF_VOPS|TDF_MEMSYMS);
> - }
> gsi_insert_seq_before (&gsi, seq, GSI_CONTINUE_LINKING);
> }
>
> --
> 2.31.1
>
prev parent reply other threads:[~2023-08-28 7:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-26 2:14 Andrew Pinski
2023-08-28 7:08 ` Richard Biener [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='CAFiYyc3+KOm=pKmV7ugui2ZLsMn3E58-3HJ1caQ0f3E-AkBkXA@mail.gmail.com' \
--to=richard.guenther@gmail.com \
--cc=apinski@marvell.com \
--cc=gcc-patches@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).