public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/pheeck/heads/sccp)] Recursive DFS of PHIs with debug_reachable_phi
@ 2022-06-12 8:02 Filip Kastl
0 siblings, 0 replies; 2+ messages in thread
From: Filip Kastl @ 2022-06-12 8:02 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:6636fc691288342e56e7d446e6ede7f97a60f7b3
commit 6636fc691288342e56e7d446e6ede7f97a60f7b3
Author: Filip Kastl <filip.kastl@gmail.com>
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 <iostream>
#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
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [gcc(refs/users/pheeck/heads/sccp)] Recursive DFS of PHIs with debug_reachable_phi
@ 2023-02-15 10:13 Filip Kastl
0 siblings, 0 replies; 2+ messages in thread
From: Filip Kastl @ 2023-02-15 10:13 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:883bdf26a9f6d430b548372b5740f9b3834b8b99
commit 883bdf26a9f6d430b548372b5740f9b3834b8b99
Author: Filip Kastl <filip.kastl@gmail.com>
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 <iostream>
#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
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-02-15 10:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-12 8:02 [gcc(refs/users/pheeck/heads/sccp)] Recursive DFS of PHIs with debug_reachable_phi Filip Kastl
2023-02-15 10:13 Filip Kastl
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).