public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH AutoFDO/3]Set profile_count accordingly for AutoFDO.
@ 2018-10-31  8:37 bin.cheng
  2018-10-31  9:49 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: bin.cheng @ 2018-10-31  8:37 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 484 bytes --]

Hi,
This is a simple patch setting profile_count with according precision category in
AutoFDO, as well as setting profile_count for exit basic block.

Bootstrap and test on x86_64 in patch set.  Is it OK?

Thanks,
bin
2018-10-31  Bin Cheng  <bin.cheng@linux.alibaba.com>

	* auto-profile.c (afdo_calculate_branch_prob): Convert profile_count
	to afdo precision quality.
	(afdo_callsite_hot_enough_for_early_inline): Ditto.
	(afdo_annotate_cfg): Set profile_count for exit basic block.

[-- Attachment #2: 0003-Set-profile-count-accordingly-for-AutoFDO.patch --]
[-- Type: application/octet-stream, Size: 1896 bytes --]

From c88da703e3b514969027951946dd2a1fb78ec31a Mon Sep 17 00:00:00 2001
From: "chengbin.cb" <bin.cheng@linux.alibaba.com>
Date: Wed, 10 Oct 2018 16:10:20 +0800
Subject: [PATCH 3/4] Set profile count accordingly for AutoFDO.

---
 gcc/auto-profile.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c
index 9316f4c477b..cde4f41c1d9 100644
--- a/gcc/auto-profile.c
+++ b/gcc/auto-profile.c
@@ -1400,7 +1400,7 @@ afdo_calculate_branch_prob (bb_set *annotated_bb, edge_set *annotated_edge)
     edge e;
     edge_iterator ei;
     int num_unknown_succ = 0;
-    profile_count total_count = profile_count::zero ();
+    profile_count total_count = profile_count::zero ().afdo ();
 
     FOR_EACH_EDGE (e, ei, bb->succs)
     {
@@ -1507,6 +1507,7 @@ afdo_annotate_cfg (const stmt_set &promoted_stmts)
      = profile_count::from_gcov_type (s->head_count ()).afdo ();
   ENTRY_BLOCK_PTR_FOR_FN (cfun)->count
      = profile_count::from_gcov_type (s->head_count ()).afdo ();
+  EXIT_BLOCK_PTR_FOR_FN (cfun)->count = profile_count::zero ().afdo ();
   profile_count max_count = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count;
 
   FOR_EACH_BB_FN (bb, cfun)
@@ -1686,11 +1687,12 @@ afdo_callsite_hot_enough_for_early_inline (struct cgraph_edge *edge)
   if (count > 0)
     {
       bool is_hot;
+      profile_count pcount = profile_count::from_gcov_type (count).afdo ();
       gcov_summary *saved_profile_info = profile_info;
       /* At early inline stage, profile_info is not set yet. We need to
          temporarily set it to afdo_profile_info to calculate hotness.  */
       profile_info = autofdo::afdo_profile_info;
-      is_hot = maybe_hot_count_p (NULL, profile_count::from_gcov_type (count));
+      is_hot = maybe_hot_count_p (NULL, pcount);
       profile_info = saved_profile_info;
       return is_hot;
     }
-- 
2.14.4.44.g2045bb6


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

* Re: [PATCH AutoFDO/3]Set profile_count accordingly for AutoFDO.
  2018-10-31  8:37 [PATCH AutoFDO/3]Set profile_count accordingly for AutoFDO bin.cheng
@ 2018-10-31  9:49 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2018-10-31  9:49 UTC (permalink / raw)
  To: bin.cheng; +Cc: GCC Patches

On Wed, Oct 31, 2018 at 7:31 AM bin.cheng <bin.cheng@linux.alibaba.com> wrote:
>
> Hi,
> This is a simple patch setting profile_count with according precision category in
> AutoFDO, as well as setting profile_count for exit basic block.
>
> Bootstrap and test on x86_64 in patch set.  Is it OK?

OK.  It might look cleaner (and cheaper) to add a profile-quality argument
to from_gcov_type instead of calling .afdo() on the result.  Your call.

Richard.

> Thanks,
> bin
> 2018-10-31  Bin Cheng  <bin.cheng@linux.alibaba.com>
>
>         * auto-profile.c (afdo_calculate_branch_prob): Convert profile_count
>         to afdo precision quality.
>         (afdo_callsite_hot_enough_for_early_inline): Ditto.
>         (afdo_annotate_cfg): Set profile_count for exit basic block.

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

end of thread, other threads:[~2018-10-31  9:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-31  8:37 [PATCH AutoFDO/3]Set profile_count accordingly for AutoFDO bin.cheng
2018-10-31  9:49 ` Richard Biener

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