From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7879) id B49D63858412; Wed, 15 Feb 2023 10:13:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B49D63858412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676455984; bh=1xHZAmAPKcXsQ/WMfyVC772hQ4QfOaBzQBNIVCVQkfI=; h=From:To:Subject:Date:From; b=rHCyQXjrzx8sSSrhnKrCKNL+NFMFQ1uZm6uZiJp18dN77mcpRBEUgC72aH3mR0aTn /d8SDVyt4p9jC7KHm3PjVDmxA40w5kWhTVNZoE4kd0mfa8ItlwchlAKgSIWLdij2MW 90cKgXIarxYW5G/pHObczO5x7g+TfpKQN5OMJM3U= 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: 940b3c51bb3e8ffafad3433f3ffab3df9a35f460 X-Git-Newrev: 883bdf26a9f6d430b548372b5740f9b3834b8b99 Message-Id: <20230215101304.B49D63858412@sourceware.org> Date: Wed, 15 Feb 2023 10:13:04 +0000 (GMT) List-Id: https://gcc.gnu.org/g:883bdf26a9f6d430b548372b5740f9b3834b8b99 commit 883bdf26a9f6d430b548372b5740f9b3834b8b99 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 } }