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)] fixed error where algorithm would ignore non-ssa names Date: Sun, 4 Sep 2022 12:23:52 +0000 (GMT) [thread overview] Message-ID: <20220904122352.C593E3858D32@sourceware.org> (raw) https://gcc.gnu.org/g:fe245814b018faba7e5095e9eeb081fd25ca23fc commit fe245814b018faba7e5095e9eeb081fd25ca23fc Author: Filip Kastl <filip.kastl@gmail.com> Date: Sun Sep 4 14:23:45 2022 +0200 fixed error where algorithm would ignore non-ssa names Diff: --- gcc/sccp.cc | 69 +++++++++++++++++++------------------------------------------ 1 file changed, 21 insertions(+), 48 deletions(-) diff --git a/gcc/sccp.cc b/gcc/sccp.cc index a4b332e0c29..4dcedc293fd 100644 --- a/gcc/sccp.cc +++ b/gcc/sccp.cc @@ -219,7 +219,7 @@ tarjan_compute_sccs (vec<gphi *> phis) { tree op_var = gimple_phi_arg_def (phi, j); if (TREE_CODE (op_var) != SSA_NAME) - continue; /* Skip arguments that aren't SSA names. */ + continue; /* Skip any operand that isn't an SSA name. */ gimple *op_stmt = SSA_NAME_DEF_STMT (op_var); @@ -260,7 +260,7 @@ tarjan_compute_sccs (vec<gphi *> phis) tree op_var = gimple_phi_arg_def (phi, j); // TODO Same code // twice (iterator?) if (TREE_CODE (op_var) != SSA_NAME) - continue; /* Skip arguments that aren't SSA names. */ + continue; /* Skip any operand that isn't an SSA name. */ gimple *op_stmt = SSA_NAME_DEF_STMT (op_var); @@ -352,8 +352,14 @@ remove_zero_uses_phis () gphi *phi = pi.phi (); tree ssa_name = gimple_phi_result (phi); if (has_zero_uses (ssa_name)) - /* Note that remove_phi_node() also frees SSA name. */ - remove_phi_node (&pi, true); + { + /* Note that remove_phi_node() also frees SSA name. */ + remove_phi_node (&pi, true); + + // DEBUG + unsigned version = SSA_NAME_VERSION (ssa_name); + std::cerr << "Removed " << version << std::endl; + } else gsi_next (&pi); } @@ -376,18 +382,20 @@ process_scc (vec<gphi *> scc) unsigned i; for (i = 0; i < gimple_phi_num_args (phi); i++) { + // Check if operand is a phi from scc + bool op_in_scc = false; tree op = gimple_phi_arg_def (phi, i); - if (TREE_CODE (op) != SSA_NAME) - continue; /* Skip arguments that aren't SSA names. */ - gimple *op_stmt = SSA_NAME_DEF_STMT (op); - - // Check if operand is a phi from scc (TODO Efficiency) - bool op_in_scc = false; - for (gphi *foo : scc) + if (TREE_CODE (op) == SSA_NAME) { - if (op_stmt == foo) - op_in_scc = true; + gimple *op_stmt = SSA_NAME_DEF_STMT (op); + + // TODO Efficiency + for (gphi *foo : scc) + { + if (op_stmt == foo) + op_in_scc = true; + } } if (!op_in_scc) @@ -408,7 +416,6 @@ process_scc (vec<gphi *> scc) replace_scc_by_value (scc, outer_ops.pop()); else if (outer_ops.length () > 1) { - std::cerr << inner.length () << std::endl; remove_redundant_phis (inner); } } @@ -459,40 +466,6 @@ pass_sccp::execute (function *) { init_sccp (); remove_redundant_phis (get_all_normal_phis ()); - - /* - // DEBUG - basic_block bb; - FOR_EACH_BB_FN (bb, cfun) - { - debug_bb (bb); - gphi_iterator pi; - std::cerr << "PHI LIST" << std::endl; - for (pi = gsi_start_phis (bb); !gsi_end_p (pi); gsi_next (&pi)) - { - gphi *phi = pi.phi (); - debug_gimple_stmt (phi); - } - std::cerr << std::endl << std::endl; - } - */ - - /* - std::cerr << "function:" << std::endl; - for (vec<gphi *> scc : sccs) - { - std::cerr << "scc:" << std::endl; - for (gphi *phi : scc) - { - tree ssa_name = gimple_phi_result (phi); - unsigned vnum = SSA_NAME_VERSION (ssa_name); - std::cerr << vnum << std::endl; - } - std::cerr << std::endl; - } - std::cerr << std::endl; - */ - finalize_sccp (); return 0;
next reply other threads:[~2022-09-04 12:23 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-09-04 12:23 Filip Kastl [this message] 2023-02-15 10:14 Filip Kastl
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=20220904122352.C593E3858D32@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).