public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Filip Kastl <pheeck@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/pheeck/heads/sccp)] now clearing all flags Date: Tue, 21 Feb 2023 12:23:57 +0000 (GMT) [thread overview] Message-ID: <20230221122357.900D03855C30@sourceware.org> (raw) https://gcc.gnu.org/g:35bd6e6a52e31502c1320831496e5a98b303e75e commit 35bd6e6a52e31502c1320831496e5a98b303e75e Author: Filip Kastl <filip.kastl@gmail.com> Date: Tue Feb 21 13:23:50 2023 +0100 now clearing all flags Diff: --- gcc/sccp.cc | 125 +++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 103 insertions(+), 22 deletions(-) diff --git a/gcc/sccp.cc b/gcc/sccp.cc index 6deb0d68bfa..aeed5b822d3 100644 --- a/gcc/sccp.cc +++ b/gcc/sccp.cc @@ -79,7 +79,13 @@ stmt_may_generate_copy (gimple *stmt) /* No OCCURS_IN_ABNORMAL_PHI SSA names in lhs nor rhs. */ if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_phi_result (phi))) - return false; + { + /* + debug_gimple_stmt (stmt); // DEBUG + std::cerr << "1" << std::endl; // DEBUG + */ + return false; + } unsigned i; for (i = 0; i < gimple_phi_num_args (phi); i++) @@ -87,34 +93,80 @@ stmt_may_generate_copy (gimple *stmt) tree op = gimple_phi_arg_def (phi, i); if (TREE_CODE (op) == SSA_NAME && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (op)) - return false; + { + /* + debug_gimple_stmt (stmt); // DEBUG + std::cerr << "2" << std::endl; // DEBUG + */ + return false; + } } + /* + debug_gimple_stmt (stmt); // DEBUG + std::cerr << "ok" << std::endl; // DEBUG + */ return true; } if (gimple_code (stmt) != GIMPLE_ASSIGN) - return false; + { + /* + debug_gimple_stmt (stmt); // DEBUG + std::cerr << "3" << std::endl; // DEBUG + */ + return false; + } /* If the statement has volatile operands, it won't generate a useful copy. */ if (gimple_has_volatile_ops (stmt)) - return false; // TODO Maybe doesn't have to be here + { + /* + debug_gimple_stmt (stmt); // DEBUG + std::cerr << "4" << std::endl; // DEBUG + */ + return false; // TODO Maybe doesn't have to be here + } /* Statements with loads and/or stores will never generate a useful copy. */ if (gimple_store_p (stmt) || gimple_assign_load_p (stmt)) - return false; + { + /* + debug_gimple_stmt (stmt); // DEBUG + std::cerr << "5" << std::endl; // DEBUG + */ + return false; + } if (!gimple_assign_single_p (stmt)) - return false; + { + /* + debug_gimple_stmt (stmt); // DEBUG + std::cerr << "6" << std::endl; // DEBUG + */ + return false; + } tree lhs = gimple_assign_lhs (stmt); if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs)) - return false; + { + /* + debug_gimple_stmt (stmt); // DEBUG + std::cerr << "7" << std::endl; // DEBUG + */ + return false; + } /* If the assignment is from a constant it generates a useful copy. */ if (is_gimple_min_invariant (gimple_assign_rhs1 (stmt))) - return true; + { + /* + debug_gimple_stmt (stmt); // DEBUG + std::cerr << "ok" << std::endl; // DEBUG + */ + return true; + } /* Otherwise, the only statements that generate useful copies are assignments whose single SSA use doesn't flow through abnormal @@ -123,9 +175,37 @@ stmt_may_generate_copy (gimple *stmt) /* TODO Comment. */ if (!is_gimple_val (gimple_assign_rhs1 (stmt))) - return false; + { + /* + debug_gimple_stmt (stmt); // DEBUG + std::cerr << "8" << std::endl; // DEBUG + */ + return false; + } + + if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs)) + { + /* + debug_gimple_stmt (stmt); // DEBUG + std::cerr << "9" << std::endl; // DEBUG + */ + return false; + } + + if (!rhs) + { + /* + debug_gimple_stmt (stmt); // DEBUG + std::cerr << "10" << std::endl; // DEBUG + */ + return false; + } - return (rhs && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs)); + /* + debug_gimple_stmt (stmt); // DEBUG + std::cerr << "ok" << std::endl; // DEBUG + */ + return true; } /* Set 'using' flag of gimple statement to true. @@ -372,10 +452,6 @@ may_propagate (tree get_replaced, tree replace_by) static void replace_use_by (tree get_replaced, tree replace_by) { - if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (get_replaced) - && TREE_CODE (replace_by) == SSA_NAME) - SSA_NAME_OCCURS_IN_ABNORMAL_PHI (replace_by) = 1; - /* Replace each occurence of 'get_replaced' by 'replace_by'. */ use_operand_p use_p; imm_use_iterator iter; @@ -408,10 +484,12 @@ static void replace_scc_by_value (vec<gimple *> scc, tree replace_by) { // DEBUG + /* if (scc.length () >= 1) { std::cerr << "Replacing SCC of length " << scc.length () << std::endl; } + */ for (gimple *stmt : scc) { @@ -569,10 +647,7 @@ get_all_stmt_may_generate_copy (void) { gimple *s = gsi_stmt (gsi); if (stmt_may_generate_copy (s)) - { - result.safe_push (s); - //debug_gimple_stmt (s); // DEBUG - } + result.safe_push (s); } gphi_iterator pi; @@ -580,13 +655,12 @@ get_all_stmt_may_generate_copy (void) { gimple *s = pi.phi (); if (stmt_may_generate_copy (s)) - { - result.safe_push (s); - //debug_gimple_stmt (s); // DEBUG - } + result.safe_push (s); } } + //std::cerr << std::endl << "- - - -" << std::endl << std::endl; // DEBUG + return result; } @@ -605,6 +679,13 @@ init_sccp (void) gimple* stmt = gsi_stmt (gsi); tarjan_clear_using (stmt); } + + gphi_iterator pi; + for (pi = gsi_start_phis (bb); !gsi_end_p (pi); gsi_next (&pi)) + { + gimple *stmt = pi.phi (); + tarjan_clear_using (stmt); + } } }
reply other threads:[~2023-02-21 12:23 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230221122357.900D03855C30@sourceware.org \ --to=pheeck@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).