* [PATCH 1/2] PHIOPT: small cleanup in match_simplify_replacement @ 2023-04-17 22:17 Andrew Pinski 2023-04-17 22:17 ` [PATCH 2/2] PHIOPT: add folding/simplification detail to the dump Andrew Pinski 2023-04-18 6:24 ` [PATCH 1/2] PHIOPT: small cleanup in match_simplify_replacement Richard Biener 0 siblings, 2 replies; 4+ messages in thread From: Andrew Pinski @ 2023-04-17 22:17 UTC (permalink / raw) To: gcc-patches; +Cc: Andrew Pinski We know that the statement we are moving is already have a SSA_NAME on the lhs so we don't need to check that and can also just call reset_flow_sensitive_info with the name we already got. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * tree-ssa-phiopt.cc (match_simplify_replacement): Simplify code that does the movement slightly. --- gcc/tree-ssa-phiopt.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 16acd2f1894..4ddb4d5db90 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -1094,11 +1094,10 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, tree name = gimple_get_lhs (stmt_to_move); // Mark the name to be renamed if there is one. - if (name && TREE_CODE (name) == SSA_NAME) - bitmap_set_bit (inserted_exprs, SSA_NAME_VERSION (name)); + bitmap_set_bit (inserted_exprs, SSA_NAME_VERSION (name)); gimple_stmt_iterator gsi1 = gsi_for_stmt (stmt_to_move); gsi_move_before (&gsi1, &gsi); - reset_flow_sensitive_info (gimple_assign_lhs (stmt_to_move)); + reset_flow_sensitive_info (name); } replace_phi_edge_with_variable (cond_bb, e1, phi, result, inserted_exprs); -- 2.31.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] PHIOPT: add folding/simplification detail to the dump 2023-04-17 22:17 [PATCH 1/2] PHIOPT: small cleanup in match_simplify_replacement Andrew Pinski @ 2023-04-17 22:17 ` Andrew Pinski 2023-04-18 6:24 ` Richard Biener 2023-04-18 6:24 ` [PATCH 1/2] PHIOPT: small cleanup in match_simplify_replacement Richard Biener 1 sibling, 1 reply; 4+ messages in thread From: Andrew Pinski @ 2023-04-17 22:17 UTC (permalink / raw) To: gcc-patches; +Cc: Andrew Pinski While debugging PHI-OPT with match-and-simplify, I found that adding more dumping to the debug dumps made it easier to understand what was going on rather than stepping in the debugger so this adds them. Note I used TDF_FOLDING rather than TDF_DETAILS as these debug messages can be chatty and only needed if you are debugging match and simplify with PHI-OPT and match and simplify uses TDF_FOLDING as its check. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * tree-ssa-phiopt.cc (gimple_simplify_phiopt): Dump the expression that is being tried when TDF_FOLDING is true. (phiopt_worker::match_simplify_replacement): Dump the sequence which was created by gimple_simplify_phiopt when TDF_FOLDING is true. --- gcc/tree-ssa-phiopt.cc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 4ddb4d5db90..616b5778602 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -916,6 +916,18 @@ gimple_simplify_phiopt (bool early_p, tree type, gimple *comp_stmt, "a != 0". */ tree cond = build2_loc (loc, comp_code, boolean_type_node, cmp0, cmp1); + + if (dump_file && (dump_flags & TDF_FOLDING)) + { + fprintf (dump_file, "\nphiopt match-simplify trying:\n\t"); + print_generic_expr (dump_file, cond); + fprintf (dump_file, " ? "); + print_generic_expr (dump_file, arg0); + fprintf (dump_file, " : "); + print_generic_expr (dump_file, arg1); + fprintf (dump_file, "\n"); + } + gimple_match_op op (gimple_match_cond::UNCOND, COND_EXPR, type, cond, arg0, arg1); @@ -947,6 +959,18 @@ gimple_simplify_phiopt (bool early_p, tree type, gimple *comp_stmt, cond = build2_loc (loc, comp_code, boolean_type_node, cmp0, cmp1); + + if (dump_file && (dump_flags & TDF_FOLDING)) + { + fprintf (dump_file, "\nphiopt match-simplify trying:\n\t"); + print_generic_expr (dump_file, cond); + fprintf (dump_file, " ? "); + print_generic_expr (dump_file, arg1); + fprintf (dump_file, " : "); + print_generic_expr (dump_file, arg0); + fprintf (dump_file, "\n"); + } + gimple_match_op op1 (gimple_match_cond::UNCOND, COND_EXPR, type, cond, arg1, arg0); @@ -1078,6 +1102,11 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, if (name && TREE_CODE (name) == SSA_NAME) bitmap_set_bit (inserted_exprs, 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] PHIOPT: add folding/simplification detail to the dump 2023-04-17 22:17 ` [PATCH 2/2] PHIOPT: add folding/simplification detail to the dump Andrew Pinski @ 2023-04-18 6:24 ` Richard Biener 0 siblings, 0 replies; 4+ messages in thread From: Richard Biener @ 2023-04-18 6:24 UTC (permalink / raw) To: Andrew Pinski; +Cc: gcc-patches On Tue, Apr 18, 2023 at 12:18 AM Andrew Pinski via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > While debugging PHI-OPT with match-and-simplify, > I found that adding more dumping to the debug dumps made > it easier to understand what was going on rather than stepping in > the debugger so this adds them. Note I used TDF_FOLDING rather > than TDF_DETAILS as these debug messages can be chatty and > only needed if you are debugging match and simplify > with PHI-OPT and match and simplify uses TDF_FOLDING as > its check. > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. OK. > gcc/ChangeLog: > > * tree-ssa-phiopt.cc (gimple_simplify_phiopt): Dump > the expression that is being tried when TDF_FOLDING > is true. > (phiopt_worker::match_simplify_replacement): Dump > the sequence which was created by gimple_simplify_phiopt > when TDF_FOLDING is true. > --- > gcc/tree-ssa-phiopt.cc | 29 +++++++++++++++++++++++++++++ > 1 file changed, 29 insertions(+) > > diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc > index 4ddb4d5db90..616b5778602 100644 > --- a/gcc/tree-ssa-phiopt.cc > +++ b/gcc/tree-ssa-phiopt.cc > @@ -916,6 +916,18 @@ gimple_simplify_phiopt (bool early_p, tree type, gimple *comp_stmt, > "a != 0". */ > tree cond = build2_loc (loc, comp_code, boolean_type_node, > cmp0, cmp1); > + > + if (dump_file && (dump_flags & TDF_FOLDING)) > + { > + fprintf (dump_file, "\nphiopt match-simplify trying:\n\t"); > + print_generic_expr (dump_file, cond); > + fprintf (dump_file, " ? "); > + print_generic_expr (dump_file, arg0); > + fprintf (dump_file, " : "); > + print_generic_expr (dump_file, arg1); > + fprintf (dump_file, "\n"); > + } > + > gimple_match_op op (gimple_match_cond::UNCOND, > COND_EXPR, type, cond, arg0, arg1); > > @@ -947,6 +959,18 @@ gimple_simplify_phiopt (bool early_p, tree type, gimple *comp_stmt, > cond = build2_loc (loc, > comp_code, boolean_type_node, > cmp0, cmp1); > + > + if (dump_file && (dump_flags & TDF_FOLDING)) > + { > + fprintf (dump_file, "\nphiopt match-simplify trying:\n\t"); > + print_generic_expr (dump_file, cond); > + fprintf (dump_file, " ? "); > + print_generic_expr (dump_file, arg1); > + fprintf (dump_file, " : "); > + print_generic_expr (dump_file, arg0); > + fprintf (dump_file, "\n"); > + } > + > gimple_match_op op1 (gimple_match_cond::UNCOND, > COND_EXPR, type, cond, arg1, arg0); > > @@ -1078,6 +1102,11 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, > if (name && TREE_CODE (name) == SSA_NAME) > bitmap_set_bit (inserted_exprs, 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 > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] PHIOPT: small cleanup in match_simplify_replacement 2023-04-17 22:17 [PATCH 1/2] PHIOPT: small cleanup in match_simplify_replacement Andrew Pinski 2023-04-17 22:17 ` [PATCH 2/2] PHIOPT: add folding/simplification detail to the dump Andrew Pinski @ 2023-04-18 6:24 ` Richard Biener 1 sibling, 0 replies; 4+ messages in thread From: Richard Biener @ 2023-04-18 6:24 UTC (permalink / raw) To: Andrew Pinski; +Cc: gcc-patches On Tue, Apr 18, 2023 at 12:18 AM Andrew Pinski via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > We know that the statement we are moving is already > have a SSA_NAME on the lhs so we don't need to > check that and can also just call reset_flow_sensitive_info > with the name we already got. > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. OK. > gcc/ChangeLog: > > * tree-ssa-phiopt.cc (match_simplify_replacement): > Simplify code that does the movement slightly. > --- > gcc/tree-ssa-phiopt.cc | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc > index 16acd2f1894..4ddb4d5db90 100644 > --- a/gcc/tree-ssa-phiopt.cc > +++ b/gcc/tree-ssa-phiopt.cc > @@ -1094,11 +1094,10 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb, > > tree name = gimple_get_lhs (stmt_to_move); > // Mark the name to be renamed if there is one. > - if (name && TREE_CODE (name) == SSA_NAME) > - bitmap_set_bit (inserted_exprs, SSA_NAME_VERSION (name)); > + bitmap_set_bit (inserted_exprs, SSA_NAME_VERSION (name)); > gimple_stmt_iterator gsi1 = gsi_for_stmt (stmt_to_move); > gsi_move_before (&gsi1, &gsi); > - reset_flow_sensitive_info (gimple_assign_lhs (stmt_to_move)); > + reset_flow_sensitive_info (name); > } > > replace_phi_edge_with_variable (cond_bb, e1, phi, result, inserted_exprs); > -- > 2.31.1 > ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-18 6:24 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-04-17 22:17 [PATCH 1/2] PHIOPT: small cleanup in match_simplify_replacement Andrew Pinski 2023-04-17 22:17 ` [PATCH 2/2] PHIOPT: add folding/simplification detail to the dump Andrew Pinski 2023-04-18 6:24 ` Richard Biener 2023-04-18 6:24 ` [PATCH 1/2] PHIOPT: small cleanup in match_simplify_replacement Richard Biener
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).