From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7880) id C0D813858D33; Thu, 16 Feb 2023 16:26:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C0D813858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676564794; bh=0M7Xpna6YfnuXPcY6jpmla5ztGo3atUBe8lnXDMF5zM=; h=From:To:Subject:Date:From; b=C/tKb+fbbJH7O4Fr7yhNFPa+g22K9jAUjWXD+nwCX1x3ca0zumqnaaxzfTgU7BBoQ PDNmS/PsjYwt73cgSBxYkCYW0BuMK+XctefrAePdp6fEYWPO1R/7J9TJwraFTXKRIe sAq2tOc2lXlSYnkjquSHNy1Iuq0XqFVhQHi4uMD4= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Ondrej Kubanek To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/kubaneko/heads/histogram)] loop counter prototype X-Act-Checkin: gcc X-Git-Author: Ondrej Kubanek X-Git-Refname: refs/users/kubaneko/heads/histogram X-Git-Oldrev: bbc5593cc87f02b7d11eb9b01037e229b62b656a X-Git-Newrev: d208f89f5754737f170fa8fef8197ddb8c51782c Message-Id: <20230216162634.C0D813858D33@sourceware.org> Date: Thu, 16 Feb 2023 16:26:34 +0000 (GMT) List-Id: https://gcc.gnu.org/g:d208f89f5754737f170fa8fef8197ddb8c51782c commit d208f89f5754737f170fa8fef8197ddb8c51782c Author: Ondrej Kubanek 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 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 (); }