public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@ucw.cz>
To: law@redhat.com, gcc-patches@gcc.gnu.org
Subject: Fix profile updatin in tree-ssa-threadupdate
Date: Thu, 05 Dec 2019 10:12:00 -0000	[thread overview]
Message-ID: <20191205101204.2obitkvozbxbtu4l@kam.mff.cuni.cz> (raw)

Hi,
this patch makes tree-ssa-threadupdate to not leave basic blocks with
undefined counts in the program.  

create_block_for_threading sets counts as follows:

  /* Zero out the profile, since the block is unreachable for now.  */
  rd->dup_blocks[count]->count = profile_count::uninitialized ();

which is usually set to correct count in update_profile. However
template_blocks are not seen by it and thus this patch calculates the
profile while redirecting edgs to it.

Bootstrapped/regtested x86_64-linux and also checked that the profile is
correct. Does it make sense?  There is no testcase since I plan to
commit sanity check that triggers several times during the testsuite and
bootstrap w/o this patch.

Honza

	* tree-ssa-threadupdate.c
Index: tree-ssa-threadupdate.c
===================================================================
--- tree-ssa-threadupdate.c	(revision 278959)
+++ tree-ssa-threadupdate.c	(working copy)
@@ -1286,6 +1286,10 @@ ssa_redirect_edges (struct redirection_d
 	  /* Redirect the incoming edge (possibly to the joiner block) to the
 	     appropriate duplicate block.  */
 	  e2 = redirect_edge_and_branch (e, rd->dup_blocks[0]);
+	  if (single_pred_p (rd->dup_blocks[0]))
+	    rd->dup_blocks[0]->count = e2->count ();
+	  else
+	    rd->dup_blocks[0]->count = rd->dup_blocks[0]->count + e2->count ();
 	  gcc_assert (e == e2);
 	  flush_pending_stmts (e2);
 	}

             reply	other threads:[~2019-12-05 10:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-05 10:12 Jan Hubicka [this message]
2019-12-06 22:11 ` Jeff Law

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=20191205101204.2obitkvozbxbtu4l@kam.mff.cuni.cz \
    --to=hubicka@ucw.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    /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: link
Be 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).