public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/kubaneko/heads/histogram)] loop counter prototype
@ 2023-02-23 23:20 Ondrej Kubanek
  0 siblings, 0 replies; 2+ messages in thread
From: Ondrej Kubanek @ 2023-02-23 23:20 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:773f935c430b55ba72da1c8b809c5b266770a702

commit 773f935c430b55ba72da1c8b809c5b266770a702
Author: Ondrej Kubanek <kubanek0ondrej@gmail.com>
Date:   Wed Jul 27 14:00:47 2022 +0200

    loop counter prototype

Diff:
---
 gcc/value-prof.cc | 36 +++++++++++++++++++++++++++++++-----
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git a/gcc/value-prof.cc b/gcc/value-prof.cc
index fe414cbacfd..bb0a752ce30 100644
--- a/gcc/value-prof.cc
+++ b/gcc/value-prof.cc
@@ -42,6 +42,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimple-pretty-print.h"
 #include "dumpfile.h"
 #include "builtins.h"
+#include "cfgloop.h"
+#include "tree-ssa-loop-manip.h"
 
 /* In this file value profile based optimizations are placed.  Currently the
    following optimizations are implemented (for more detailed descriptions
@@ -1913,6 +1915,30 @@ gimple_stringops_values_to_profile (gimple *gs, histogram_values *values)
 						     stmt, dest));
 }
 
+static void
+gimple_histogram_values_to_profile(function *fun, histogram_values * values){
+    for (auto loop : loops_list (fun, 0)){
+         tree var;
+         gimple_stmt_iterator gsi;
+         gsi = gsi_last_bb (loop->latch);
+         create_iv (build_int_cst_type (var, 0), build_int_cst (var, 1), NULL_TREE,
+             loop, &gsi, true, &var, NULL);
+         auto_vec<edge> exits = get_loop_exit_edges (loop);
+         for ( auto exit : exits ){
+              if (single_pred_p (exit->dest)){
+                values->safe_push (gimple_alloc_histogram_value (fun,
+                                         HIST_TYPE_HISTOGRAM,
+                                         exit->src, var));
+              }
+             //pridate ulozeni var do histogramu na zacated basic blocku exit->dest
+             // TREE_TYPE (name)
+               else
+               {
+               }
+         }
+    }
+}
+
 /* Find values inside STMT for that we want to measure histograms and adds
    them to list VALUES.  */
 
@@ -1932,8 +1958,8 @@ gimple_find_values_to_profile (histogram_values *values)
   unsigned i;
   histogram_value hist = NULL;
   values->create (0);
-
   FOR_EACH_BB_FN (bb, cfun)
+    gimple_histogram_values_to_profile(cfun, values);
     for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
       gimple_values_to_profile (gsi_stmt (gsi), values);
 
@@ -1948,10 +1974,6 @@ gimple_find_values_to_profile (histogram_values *values)
 	  hist->n_counters = hist->hdata.intvl.steps + 2;
 	  break;
 
-
-	case HIST_TYPE_HISTOGRAM:
-	  hist->n_counters = 69;
-	  break;
 	case HIST_TYPE_POW2:
 	  hist->n_counters = 2;
 	  break;
@@ -1973,6 +1995,10 @@ gimple_find_values_to_profile (histogram_values *values)
 	  hist->n_counters = 1;
 	  break;
 
+	case HIST_TYPE_HISTOGRAM:
+	  hist->n_counters = 69;
+	  break;
+
 	default:
 	  gcc_unreachable ();
 	}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gcc(refs/users/kubaneko/heads/histogram)] loop counter prototype
@ 2023-02-16 16:26 Ondrej Kubanek
  0 siblings, 0 replies; 2+ messages in thread
From: Ondrej Kubanek @ 2023-02-16 16:26 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d208f89f5754737f170fa8fef8197ddb8c51782c

commit d208f89f5754737f170fa8fef8197ddb8c51782c
Author: Ondrej Kubanek <kubanek0ondrej@gmail.com>
Date:   Wed Jul 27 14:00:47 2022 +0200

    loop counter prototype

Diff:
---
 gcc/value-prof.cc | 36 +++++++++++++++++++++++++++++++-----
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git a/gcc/value-prof.cc b/gcc/value-prof.cc
index 80b17f56661..06a584b392a 100644
--- a/gcc/value-prof.cc
+++ b/gcc/value-prof.cc
@@ -42,6 +42,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimple-pretty-print.h"
 #include "dumpfile.h"
 #include "builtins.h"
+#include "cfgloop.h"
+#include "tree-ssa-loop-manip.h"
 
 /* In this file value profile based optimizations are placed.  Currently the
    following optimizations are implemented (for more detailed descriptions
@@ -1913,6 +1915,30 @@ gimple_stringops_values_to_profile (gimple *gs, histogram_values *values)
 						     stmt, dest));
 }
 
+static void
+gimple_histogram_values_to_profile(function *fun, histogram_values * values){
+    for (auto loop : loops_list (fun, 0)){
+         tree var;
+         gimple_stmt_iterator gsi;
+         gsi = gsi_last_bb (loop->latch);
+         create_iv (build_int_cst_type (var, 0), build_int_cst (var, 1), NULL_TREE,
+             loop, &gsi, true, &var, NULL);
+         auto_vec<edge> exits = get_loop_exit_edges (loop);
+         for ( auto exit : exits ){
+              if (single_pred_p (exit->dest)){
+                values->safe_push (gimple_alloc_histogram_value (fun,
+                                         HIST_TYPE_HISTOGRAM,
+                                         exit->src, var));
+              }
+             //pridate ulozeni var do histogramu na zacated basic blocku exit->dest
+             // TREE_TYPE (name)
+               else
+               {
+               }
+         }
+    }
+}
+
 /* Find values inside STMT for that we want to measure histograms and adds
    them to list VALUES.  */
 
@@ -1932,8 +1958,8 @@ gimple_find_values_to_profile (histogram_values *values)
   unsigned i;
   histogram_value hist = NULL;
   values->create (0);
-
   FOR_EACH_BB_FN (bb, cfun)
+    gimple_histogram_values_to_profile(cfun, values);
     for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
       gimple_values_to_profile (gsi_stmt (gsi), values);
 
@@ -1948,10 +1974,6 @@ gimple_find_values_to_profile (histogram_values *values)
 	  hist->n_counters = hist->hdata.intvl.steps + 2;
 	  break;
 
-
-	case HIST_TYPE_HISTOGRAM:
-	  hist->n_counters = 69;
-	  break;
 	case HIST_TYPE_POW2:
 	  hist->n_counters = 2;
 	  break;
@@ -1973,6 +1995,10 @@ gimple_find_values_to_profile (histogram_values *values)
 	  hist->n_counters = 1;
 	  break;
 
+	case HIST_TYPE_HISTOGRAM:
+	  hist->n_counters = 69;
+	  break;
+
 	default:
 	  gcc_unreachable ();
 	}

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-23 23:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-23 23:20 [gcc(refs/users/kubaneko/heads/histogram)] loop counter prototype Ondrej Kubanek
  -- strict thread matches above, loose matches on Subject: below --
2023-02-16 16:26 Ondrej Kubanek

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).