public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@ucw.cz>
To: gcc-patches@gcc.gnu.org
Subject: Cleanup force_edge_cold
Date: Fri, 7 Jul 2023 19:23:26 +0200	[thread overview]
Message-ID: <ZKhKDsbYPGpWEARA@kam.mff.cuni.cz> (raw)

Hi,
we can use the new set_edge_probability_and_rescale_others here.

Bootstrapped/regtested x86_64-linux, comitted.

Honza

gcc/ChangeLog:

	* predict.cc (force_edge_cold): Use
	set_edge_probability_and_rescale_others; improve dumps.

diff --git a/gcc/predict.cc b/gcc/predict.cc
index d65c26f0ab2..1aa4c25eb70 100644
--- a/gcc/predict.cc
+++ b/gcc/predict.cc
@@ -4421,21 +4421,16 @@ force_edge_cold (edge e, bool impossible)
      there.  */
   else if (prob_sum > profile_probability::never ())
     {
-      if (!(e->probability < goal))
-	e->probability = goal;
-
-      profile_probability prob_comp = prob_sum / e->probability.invert ();
-
       if (dump_file && (dump_flags & TDF_DETAILS))
-	fprintf (dump_file, "Making edge %i->%i %s by redistributing "
-		 "probability to other edges.\n",
-		 e->src->index, e->dest->index,
-		 impossible ? "impossible" : "cold");
-      FOR_EACH_EDGE (e2, ei, e->src->succs)
-	if (e2 != e)
-	  {
-	    e2->probability /= prob_comp;
-	  }
+	{
+	  fprintf (dump_file, "Making edge %i->%i %s by redistributing "
+		   "probability to other edges. Original probability: ",
+		   e->src->index, e->dest->index,
+		   impossible ? "impossible" : "cold");
+	  e->probability.dump (dump_file);
+	  fprintf (dump_file, "\n");
+	}
+      set_edge_probability_and_rescale_others (e, goal);
       if (current_ir_type () != IR_GIMPLE
 	  && e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun))
 	update_br_prob_note (e->src);

                 reply	other threads:[~2023-07-07 17:23 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=ZKhKDsbYPGpWEARA@kam.mff.cuni.cz \
    --to=hubicka@ucw.cz \
    --cc=gcc-patches@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: 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).