From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7879) id 7DA53383D82A; Sun, 12 Jun 2022 08:02:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7DA53383D82A MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Filip Kastl To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/pheeck/heads/sccp)] Recursive DFS of PHIs with debug_reachable_phi X-Act-Checkin: gcc X-Git-Author: Filip Kastl X-Git-Refname: refs/users/pheeck/heads/sccp X-Git-Oldrev: a56778f32bfb171b64008366da13958a376f9f9f X-Git-Newrev: 6636fc691288342e56e7d446e6ede7f97a60f7b3 Message-Id: <20220612080200.7DA53383D82A@sourceware.org> Date: Sun, 12 Jun 2022 08:02:00 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jun 2022 08:02:00 -0000 https://gcc.gnu.org/g:6636fc691288342e56e7d446e6ede7f97a60f7b3 commit 6636fc691288342e56e7d446e6ede7f97a60f7b3 Author: Filip Kastl Date: Sun Jun 12 10:01:43 2022 +0200 Recursive DFS of PHIs with debug_reachable_phi Diff: --- gcc/sccp.cc | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 6 deletions(-) diff --git a/gcc/sccp.cc b/gcc/sccp.cc index c959436955e..42763a565e1 100644 --- a/gcc/sccp.cc +++ b/gcc/sccp.cc @@ -30,7 +30,62 @@ along with GCC; see the file COPYING3. If not see #include "tree-pass.h" #include "gimple-iterator.h" +#include #include "gimple-pretty-print.h" +#include "bitmap.h" +#include "sbitmap.h" + +#include "backend.h" +#include "cfghooks.h" +#include "ssa.h" +#include "tree-ssa.h" +#include "fold-const.h" +#include "calls.h" +#include "cfganal.h" +#include "tree-eh.h" +#include "gimplify.h" +#include "gimple-iterator.h" +#include "tree-cfg.h" +#include "tree-ssa-loop-niter.h" +#include "tree-into-ssa.h" +#include "tree-dfa.h" +#include "cfgloop.h" +#include "tree-scalar-evolution.h" +#include "tree-ssa-propagate.h" +#include "gimple-fold.h" + +/* TODO Smaz. */ +static sbitmap visited; + +/* Initialize structures used for sccp. */ + +static void +init_sccp (void) +{ + visited = sbitmap_alloc (num_ssa_names); +} + +/* TODO Smaz. */ + +static void debug_reachable_phi(gimple* phi) +{ + debug_gimple_stmt (phi); + + unsigned int i; + for (i = 0; i < gimple_phi_num_args (phi); i++) + { + tree op = gimple_phi_arg_def (phi, i); + // TODO Nerozbije se tohle někdy? + gimple *stmt = SSA_NAME_DEF_STMT (op); + int ver = SSA_NAME_VERSION (op); + if (gimple_code (stmt) == GIMPLE_PHI && + !bitmap_bit_p (visited, ver)) + { + bitmap_set_bit (visited, ver); + debug_reachable_phi (stmt); + } + } +} /* TODO Popisek passu */ @@ -66,16 +121,20 @@ pass_sccp::execute (function *) { basic_block bb; + init_sccp (); + FOR_EACH_BB_FN (bb, cfun) { - gphi_iterator i; + gphi_iterator pi; - for (i = gsi_start_phis (bb); !gsi_end_p (i); gsi_next (&i)) + for (pi = gsi_start_phis (bb); !gsi_end_p (pi); gsi_next (&pi)) { - gphi *phi = i.phi (); - - debug_gimple_stmt (phi); // debug phi na obrazovku - // dump_gimple_stmt ... do souboru + gphi *phi = pi.phi (); + // TODO Filtrovat stmts jako v copyprop + // Ale to asi budu muset filtrovat stmts, ne phi + bitmap_clear (visited); + debug_reachable_phi (phi); + std::cerr << std::endl; // Blank line } }