public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/kubaneko/heads/histogram)] Do not instrument loops with known number of iterations and with no instrumentable exits. Date: Mon, 1 May 2023 21:51:00 +0000 (GMT) [thread overview] Message-ID: <20230501215100.246FE3858D1E@sourceware.org> (raw) https://gcc.gnu.org/g:b37d3aa26581cc6145ee8be6c82ad81f203f313a commit b37d3aa26581cc6145ee8be6c82ad81f203f313a Author: Honza <jh@ryzen3.suse.cz> Date: Mon May 1 23:50:31 2023 +0200 Do not instrument loops with known number of iterations and with no instrumentable exits. Diff: --- gcc/profile.cc | 5 ++++- gcc/value-prof.cc | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/gcc/profile.cc b/gcc/profile.cc index d2b8dfcadc1..4e3f74dfe1d 100644 --- a/gcc/profile.cc +++ b/gcc/profile.cc @@ -66,6 +66,7 @@ along with GCC; see the file COPYING3. If not see #include "cfgloop.h" #include "sreal.h" #include "file-prefix-map.h" +#include "tree-scalar-evolution.h" #include "profile.h" @@ -1227,7 +1228,8 @@ branch_prob (bool thunk) total_num_times_called++; calculate_dominance_info (CDI_DOMINATORS); - loop_optimizer_init (LOOPS_HAVE_SIMPLE_LATCHES); + loop_optimizer_init (LOOPS_NORMAL); + scev_initialize (); flow_call_edges_add (NULL); add_noreturn_fake_exit_edges (); @@ -1590,6 +1592,7 @@ branch_prob (bool thunk) values.release (); free_edge_list (el); coverage_end_function (lineno_checksum, cfg_checksum); + scev_finalize (); if (flag_branch_probabilities && (profile_status_for_fn (cfun) == PROFILE_READ)) { diff --git a/gcc/value-prof.cc b/gcc/value-prof.cc index 5e029c811e2..f85e83388b7 100644 --- a/gcc/value-prof.cc +++ b/gcc/value-prof.cc @@ -44,6 +44,8 @@ along with GCC; see the file COPYING3. If not see #include "builtins.h" #include "cfgloop.h" #include "tree-ssa-loop-manip.h" +#include "tree-ssa-loop.h" +#include "tree-ssa-loop-niter.h" /* In this file value profile based optimizations are placed. Currently the following optimizations are implemented (for more detailed descriptions @@ -1952,6 +1954,38 @@ gimple_histogram_values_to_profile (function *fun, histogram_values *values) { tree var; gimple_stmt_iterator gsi; + edge exit_edge = NULL; + auto_vec<edge> exits = get_loop_exit_edges (loop); + bool complex_exit = false; + bool exit_found = false; + + /* If loop has only exits that can not be instrumented, + we can not profile histograms. */ + for (auto exit : exits) + if (exit->flags & EDGE_FAKE) + ; + else if (exit->flags & EDGE_COMPLEX) + complex_exit = true; + else + { + if (!exit_found) + exit_edge = exit; + else + exit_edge = NULL; + exit_found = true; + break; + } + if (!exit_found) + continue; + + /* If there is only one non-fake exit edge, see if we know number of + iterations. */ + tree niter; + edge ex; + if (!complex_exit && exit_edge + && (niter = find_loop_niter (loop, &ex)) + && TREE_CODE (niter) == INTEGER_CST) + continue; gsi = gsi_start_bb (loop->latch); create_iv (build_int_cst_type (get_gcov_type (), 0),
reply other threads:[~2023-05-01 21:51 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230501215100.246FE3858D1E@sourceware.org \ --to=hubicka@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).