public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/PR97295-profile-merging)] IPA: merge profiles more sensitively
@ 2020-10-07 10:34 Martin Liska
  0 siblings, 0 replies; only message in thread
From: Martin Liska @ 2020-10-07 10:34 UTC (permalink / raw)
  To: gcc-cvs

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

commit cfe107c647fc6703f98602a70339f0514da39726
Author: Martin Liska <mliska@suse.cz>
Date:   Wed Oct 7 12:30:27 2020 +0200

    IPA: merge profiles more sensitively
    
    During WPA we merge 2 functions where one is built with -O3
    -fprofile-use while the other one uses -O0. We end up with:
    
    prevailing node:
    
    BitwiseCast (const double aFrom)
    {
      long unsigned int temp;
      long unsigned int D.4528;
    
      <bb 2> :
      BitwiseCast (aFrom_2(D), &temp);
      _4 = temp;
      temp ={v} {CLOBBER};
    
      <bb 3> :
    <L0>:
      return _4;
    
    }
    
    merged node:
    BitwiseCast (const double aFrom)
    {
      <bb 2> [count: 1509]:
      _3 = VIEW_CONVERT_EXPR<long unsigned int>(aFrom_2(D));
      return _3;
    }
    
    What happens is that we copy dst->count = src->count.ipa() but
    we skip merging of BBs (a different CFG). Then we end up in situation
    where profile of a ENTRY_BB_FOR_FN == uninitialized while
    dst->count.quality is precise.
    
    gcc/ChangeLog:
    
            PR ipa/97295
            * ipa-utils.c (ipa_merge_profiles):

Diff:
---
 gcc/ipa-utils.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/ipa-utils.c b/gcc/ipa-utils.c
index 23e7f714306..fe2149069be 100644
--- a/gcc/ipa-utils.c
+++ b/gcc/ipa-utils.c
@@ -437,10 +437,7 @@ ipa_merge_profiles (struct cgraph_node *dst,
   else if (dst->count.ipa ().initialized_p ())
     ;
   else if (src->count.ipa ().initialized_p ())
-    {
-      copy_counts = true;
-      dst->count = src->count.ipa ();
-    }
+    copy_counts = true;
 
   /* If no updating needed return early.  */
   if (dst->count == orig_count)
@@ -620,6 +617,9 @@ ipa_merge_profiles (struct cgraph_node *dst,
       bool dstscale = !copy_counts
 		      && dstnum.initialized_p () && !(dstnum == dstden);
 
+      if (copy_counts)
+	dst->count = src->count.ipa ();
+
       /* TODO: merge also statement histograms.  */
       FOR_ALL_BB_FN (srcbb, srccfun)
 	{


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-10-07 10:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-07 10:34 [gcc(refs/users/marxin/heads/PR97295-profile-merging)] IPA: merge profiles more sensitively Martin Liska

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