diff mbox series

Drop edge counts from CFG

Message ID 20171019151116.GA81559@kam.mff.cuni.cz
State New
Headers show
Series Drop edge counts from CFG | expand

Commit Message

Jan Hubicka Oct. 19, 2017, 3:11 p.m. UTC
Hi,
this is penultimate patch to convert CFG to new profile_count/probability
infrastructure.  The patch simply drops counts from edges as they can be
determined by applying edge's probability to source BB count. In most case
updating needed is converting e->count use to e->count() but there are
non-trivial changes to updating of profile after threading and propagation of
BBs known to be never executed.  

In the next step I will drop BB frequencies (and add extra mode to profile_count
for count being guessed and local to function) which will allow more cleanups
and then check for profile updating bugs.

Bootstrapped/regtested x86_64-linux, I will commit it after bit of extra
testing.

2017-10-19  Jan Hubicka  <hubicka@ucw.cz>

	* asan.c (create_cond_insert_point): Do not update edge count.
	* auto-profile.c (afdo_propagate_edge): Update for edge count removal.
	(afdo_propagate_circuit): Likewise.
	(afdo_calculate_branch_prob): Likewise.
	(afdo_annotate_cfg): Likewise.
	* basic-block.h (struct edge_def): Remove count.
	(edge_def::count): New accessor.
	* bb-reorder.c (rotate_loop): Update.
	(find_traces_1_round): Update.
	(connect_traces): Update.
	(sanitize_hot_paths): Update.
	* cfg.c (unchecked_make_edge): Update.
	(make_single_succ_edge): Update.
	(check_bb_profile): Update.
	(dump_edge_info): Update.
	(update_bb_profile_for_threading): Update.
	(scale_bbs_frequencies_int): Update.
	(scale_bbs_frequencies_gcov_type): Update.
	(scale_bbs_frequencies_profile_count): Update.
	(scale_bbs_frequencies): Update.
	* cfganal.c (connect_infinite_loops_to_exit): Update.
	* cfgbuild.c (compute_outgoing_frequencies): Update.
	(find_many_sub_basic_blocks): Update.
	* cfgcleanup.c (try_forward_edges): Update.
	(try_crossjump_to_edge): Update
	* cfgexpand.c (expand_gimple_cond): Update
	(expand_gimple_tailcall): Update
	(construct_exit_block): Update
	* cfghooks.c (verify_flow_info): Update
	(redirect_edge_succ_nodup): Update
	(split_edge): Update
	(make_forwarder_block): Update
	(duplicate_block): Update
	(account_profile_record): Update
	* cfgloop.c (find_subloop_latch_edge_by_profile): Update.
	* cfgloopanal.c (expected_loop_iterations_unbounded): Update.
	* cfgloopmanip.c (scale_loop_profile): Update.
	(loopify): Update.
	(lv_adjust_loop_entry_edge): Update.
	* cfgrtl.c (try_redirect_by_replacing_jump): Update.
	(force_nonfallthru_and_redirect): Update.
	(purge_dead_edges): Update.
	(rtl_flow_call_edges_add): Update.
	* cgraphunit.c (init_lowered_empty_function): UPdate.
	(cgraph_node::expand_thunk): UPdate.
	* gimple-pretty-print.c (dump_probability): UPdate.
	(dump_edge_probability): UPdate.
	* gimple-ssa-isolate-paths.c (isolate_path): UPdate.
	* haifa-sched.c (sched_create_recovery_edges): UPdate.
	* hsa-gen.c (convert_switch_statements): UPdate.
	* ifcvt.c (dead_or_predicable): UPdate.
	* ipa-inline-transform.c (inline_transform): UPdate.
	* ipa-split.c (split_function): UPdate.
	* ipa-utils.c (ipa_merge_profiles): UPdate.
	* loop-doloop.c (add_test): UPdate.
	* loop-unroll.c (unroll_loop_runtime_iterations): UPdate.
	* lto-streamer-in.c (input_cfg): UPdate.
	(input_function): UPdate.
	* lto-streamer-out.c (output_cfg): UPdate.
	* modulo-sched.c (sms_schedule): UPdate.
	* postreload-gcse.c (eliminate_partially_redundant_load): UPdate.
	* predict.c (maybe_hot_edge_p): UPdate.
	(unlikely_executed_edge_p): UPdate.
	(probably_never_executed_edge_p): UPdate.
	(dump_prediction): UPdate.
	(drop_profile): UPdate.
	(propagate_unlikely_bbs_forward): UPdate.
	(determine_unlikely_bbs): UPdate.
	(force_edge_cold): UPdate.
	* profile.c (compute_branch_probabilities): UPdate.
	* reg-stack.c (better_edge): UPdate.
	* shrink-wrap.c (handle_simple_exit): UPdate.
	* tracer.c (better_p): UPdate.
	* trans-mem.c (expand_transaction): UPdate.
	(split_bb_make_tm_edge): UPdate.
	* tree-call-cdce.c: UPdate.
	* tree-cfg.c (gimple_find_sub_bbs): UPdate.
	(gimple_split_edge): UPdate.
	(gimple_duplicate_sese_region): UPdate.
	(gimple_duplicate_sese_tail): UPdate.
	(gimple_flow_call_edges_add): UPdate.
	(insert_cond_bb): UPdate.
	(execute_fixup_cfg): UPdate.
	* tree-cfgcleanup.c (cleanup_control_expr_graph): UPdate.
	* tree-complex.c (expand_complex_div_wide): UPdate.
	* tree-eh.c (lower_resx): UPdate.
	(unsplit_eh): UPdate.
	(cleanup_empty_eh_move_lp): UPdate.
	* tree-inline.c (copy_edges_for_bb): UPdate.
	(freqs_to_counts): UPdate.
	(copy_cfg_body): UPdate.
	* tree-ssa-dce.c (remove_dead_stmt): UPdate.
	* tree-ssa-ifcombine.c (update_profile_after_ifcombine): UPdate.
	* tree-ssa-loop-im.c (execute_sm_if_changed): UPdate.
	* tree-ssa-loop-ivcanon.c (remove_exits_and_undefined_stmts): UPdate.
	(unloop_loops): UPdate.
	* tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): UPdate.
	* tree-ssa-loop-split.c (connect_loops): UPdate.
	(split_loop): UPdate.
	* tree-ssa-loop-unswitch.c (hoist_guard): UPdate.
	* tree-ssa-phionlycprop.c (propagate_rhs_into_lhs): UPdate.
	* tree-ssa-phiopt.c (replace_phi_edge_with_variable): UPdate.
	* tree-ssa-reassoc.c (branch_fixup): UPdate.
	* tree-ssa-tail-merge.c (replace_block_by): UPdate.
	* tree-ssa-threadupdate.c (remove_ctrl_stmt_and_useless_edges): UPdate.
	(compute_path_counts): UPdate.
	(update_profile): UPdate.
	(recompute_probabilities): UPdate.
	(update_joiner_offpath_counts): UPdate.
	(estimated_freqs_path): UPdate.
	(freqs_to_counts_path): UPdate.
	(clear_counts_path): UPdate.
	(ssa_fix_duplicate_block_edges): UPdate.
	(duplicate_thread_path): UPdate.
	* tree-switch-conversion.c (hoist_edge_and_branch_if_true): UPdate.
	(case_bit_test_cmp): UPdate.
	(collect_switch_conv_info): UPdate.
	(gen_inbound_check): UPdate.
	(do_jump_if_equal): UPdate.
	(emit_cmp_and_jump_insns): UPdate.
	* tree-tailcall.c (decrease_profile): UPdate.
	(eliminate_tail_call): UPdate.
	* tree-vect-loop-manip.c (slpeel_add_loop_guard): UPdate.
	(vect_do_peeling): UPdate.
	* tree-vect-loop.c (scale_profile_for_vect_loop): UPdate.
	* ubsan.c (ubsan_expand_null_ifn): UPdate.
	(ubsan_expand_ptr_ifn): UPdate.
	* value-prof.c (gimple_divmod_fixed_value): UPdate.
	(gimple_mod_pow2): UPdate.
	(gimple_mod_subtract): UPdate.
	(gimple_ic): UPdate.
	(gimple_stringop_fixed_value): UPdate.
diff mbox series

Patch

Index: asan.c
===================================================================
--- asan.c	(revision 253889)
+++ asan.c	(working copy)
@@ -1809,7 +1809,6 @@  create_cond_insert_point (gimple_stmt_it
   /* Set up the fallthrough basic block.  */
   e = find_edge (cond_bb, fallthru_bb);
   e->flags = EDGE_FALSE_VALUE;
-  e->count = cond_bb->count;
   e->probability = fallthrough_probability;
 
   /* Update dominance info for the newly created then_bb; note that
Index: auto-profile.c
===================================================================
--- auto-profile.c	(revision 253889)
+++ auto-profile.c	(working copy)
@@ -1234,7 +1234,7 @@  afdo_propagate_edge (bool is_succ, bb_se
       if (!is_edge_annotated (e, *annotated_edge))
 	num_unknown_edge++, unknown_edge = e;
       else
-	total_known_count += e->count;
+	total_known_count += e->count ();
 
     if (num_unknown_edge == 0)
       {
@@ -1251,7 +1251,8 @@  afdo_propagate_edge (bool is_succ, bb_se
       }
     else if (num_unknown_edge == 1 && is_bb_annotated (bb, *annotated_bb))
       {
-        unknown_edge->count = bb->count - total_known_count;
+        unknown_edge->probability
+	  = total_known_count.probability_in (bb->count);
         set_edge_annotated (unknown_edge, annotated_edge);
         changed = true;
       }
@@ -1349,15 +1350,13 @@  afdo_propagate_circuit (const bb_set &an
           if (!e->probability.initialized_p ()
 	      && !is_edge_annotated (ep, *annotated_edge))
             {
-              ep->probability = profile_probability::never ();
-              ep->count = profile_count::zero ().afdo ();
+              ep->probability = profile_probability::never ().afdo ();
               set_edge_annotated (ep, annotated_edge);
             }
         }
       if (total == 1 && !is_edge_annotated (only_one, *annotated_edge))
         {
           only_one->probability = e->probability;
-          only_one->count = e->count;
           set_edge_annotated (only_one, annotated_edge);
         }
     }
@@ -1433,23 +1432,16 @@  afdo_calculate_branch_prob (bb_set *anno
       if (!is_edge_annotated (e, *annotated_edge))
         num_unknown_succ++;
       else
-        total_count += e->count;
+        total_count += e->count ();
     }
     if (num_unknown_succ == 0 && total_count > profile_count::zero ())
       {
         FOR_EACH_EDGE (e, ei, bb->succs)
-        e->probability = e->count.probability_in (total_count);
+          e->probability = e->count ().probability_in (total_count);
       }
   }
   FOR_ALL_BB_FN (bb, cfun)
-  {
-    edge e;
-    edge_iterator ei;
-
-    FOR_EACH_EDGE (e, ei, bb->succs)
-      e->count = bb->count.apply_probability (e->probability);
     bb->aux = NULL;
-  }
 
   loop_optimizer_finalize ();
   free_dominance_info (CDI_DOMINATORS);
@@ -1551,7 +1543,7 @@  afdo_annotate_cfg (const stmt_set &promo
        counters are zero when not seen by autoFDO.  */
     bb->count = profile_count::zero ().afdo ();
     FOR_EACH_EDGE (e, ei, bb->succs)
-      e->count = profile_count::zero ().afdo ();
+      e->probability = profile_probability::uninitialized ();
 
     if (afdo_set_bb_count (bb, promoted_stmts))
       set_bb_annotated (bb, &annotated_bb);
Index: basic-block.h
===================================================================
--- basic-block.h	(revision 253889)
+++ basic-block.h	(working copy)
@@ -46,8 +46,9 @@  struct GTY((user)) edge_def {
 
   int flags;			/* see cfg-flags.def */
   profile_probability probability;
-  profile_count count;		/* Expected number of executions calculated
-				   in profile.c  */
+
+  /* Return count of edge E.  */
+  inline profile_count count () const;
 };
 
 /* Masks for edge.flags.  */
@@ -639,4 +640,10 @@  has_abnormal_call_or_eh_pred_edge_p (bas
   return false;
 }
 
+/* Return count of edge E.  */
+inline profile_count edge_def::count () const
+{
+  return src->count.apply_probability (probability);
+}
+
 #endif /* GCC_BASIC_BLOCK_H */
Index: bb-reorder.c
===================================================================
--- bb-reorder.c	(revision 253889)
+++ bb-reorder.c	(working copy)
@@ -374,11 +374,11 @@  rotate_loop (edge back_edge, struct trac
 		{
 		  /* The current edge E is also preferred.  */
 		  int freq = EDGE_FREQUENCY (e);
-		  if (freq > best_freq || e->count > best_count)
+		  if (freq > best_freq || e->count () > best_count)
 		    {
 		      best_freq = freq;
-		      if (e->count.initialized_p ())
-		        best_count = e->count;
+		      if (e->count ().initialized_p ())
+		        best_count = e->count ();
 		      best_edge = e;
 		      best_bb = bb;
 		    }
@@ -392,17 +392,17 @@  rotate_loop (edge back_edge, struct trac
 		  /* The current edge E is preferred.  */
 		  is_preferred = true;
 		  best_freq = EDGE_FREQUENCY (e);
-		  best_count = e->count;
+		  best_count = e->count ();
 		  best_edge = e;
 		  best_bb = bb;
 		}
 	      else
 		{
 		  int freq = EDGE_FREQUENCY (e);
-		  if (!best_edge || freq > best_freq || e->count > best_count)
+		  if (!best_edge || freq > best_freq || e->count () > best_count)
 		    {
 		      best_freq = freq;
-		      best_count = e->count;
+		      best_count = e->count ();
 		      best_edge = e;
 		      best_bb = bb;
 		    }
@@ -571,7 +571,7 @@  find_traces_1_round (int branch_th, int
 		  || !prob.initialized_p ()
 		  || ((prob.to_reg_br_prob_base () < branch_th
 		       || EDGE_FREQUENCY (e) < exec_th
-		      || e->count < count_th) && (!for_size)))
+		      || e->count () < count_th) && (!for_size)))
 		continue;
 
 	      /* If partitioning hot/cold basic blocks, don't consider edges
@@ -656,7 +656,7 @@  find_traces_1_round (int branch_th, int
 		      || !prob.initialized_p ()
 		      || prob.to_reg_br_prob_base () < branch_th
 		      || freq < exec_th
-		      || e->count < count_th)
+		      || e->count () < count_th)
 		    {
 		      /* When partitioning hot/cold basic blocks, make sure
 			 the cold blocks (and only the cold blocks) all get
@@ -1285,7 +1285,7 @@  connect_traces (int n_traces, struct tra
 				&& !connected[bbd[di].start_of_trace]
 				&& BB_PARTITION (e2->dest) == current_partition
 				&& EDGE_FREQUENCY (e2) >= freq_threshold
-				&& e2->count >= count_threshold
+				&& e2->count () >= count_threshold
 				&& (!best2
 				    || e2->probability > best2->probability
 				    || (e2->probability == best2->probability
@@ -1311,8 +1311,8 @@  connect_traces (int n_traces, struct tra
 		  && copy_bb_p (best->dest,
 				optimize_edge_for_speed_p (best)
 				&& EDGE_FREQUENCY (best) >= freq_threshold
-				&& (!best->count.initialized_p ()
-				    || best->count >= count_threshold)))
+				&& (!best->count ().initialized_p ()
+				    || best->count () >= count_threshold)))
 		{
 		  basic_block new_bb;
 
@@ -1528,7 +1528,7 @@  sanitize_hot_paths (bool walk_up, unsign
 
 	  /* Do not expect profile insanities when profile was not adjusted.  */
 	  if (e->probability == profile_probability::never ()
-	      || e->count == profile_count::zero ())
+	      || e->count () == profile_count::zero ())
 	    continue;
 
           if (BB_PARTITION (reach_bb) != BB_COLD_PARTITION)
@@ -1539,8 +1539,8 @@  sanitize_hot_paths (bool walk_up, unsign
           /* The following loop will look for the hottest edge via
              the edge count, if it is non-zero, then fallback to the edge
              frequency and finally the edge probability.  */
-          if (!highest_count.initialized_p () || e->count > highest_count)
-            highest_count = e->count;
+          if (!highest_count.initialized_p () || e->count () > highest_count)
+            highest_count = e->count ();
           int edge_freq = EDGE_FREQUENCY (e);
           if (edge_freq > highest_freq)
             highest_freq = edge_freq;
@@ -1563,14 +1563,14 @@  sanitize_hot_paths (bool walk_up, unsign
             continue;
 	  /* Do not expect profile insanities when profile was not adjusted.  */
 	  if (e->probability == profile_probability::never ()
-	      || e->count == profile_count::zero ())
+	      || e->count () == profile_count::zero ())
 	    continue;
           /* Select the hottest edge using the edge count, if it is non-zero,
              then fallback to the edge frequency and finally the edge
              probability.  */
           if (highest_count > 0)
             {
-              if (e->count < highest_count)
+              if (e->count () < highest_count)
                 continue;
             }
           else if (highest_freq)
Index: cfg.c
===================================================================
--- cfg.c	(revision 253889)
+++ cfg.c	(working copy)
@@ -263,7 +263,6 @@  unchecked_make_edge (basic_block src, ba
   e = ggc_cleared_alloc<edge_def> ();
   n_edges_for_fn (cfun)++;
 
-  e->count = profile_count::uninitialized ();
   e->probability = profile_probability::uninitialized ();
   e->src = src;
   e->dest = dst;
@@ -334,7 +333,6 @@  make_single_succ_edge (basic_block src,
   edge e = make_edge (src, dest, flags);
 
   e->probability = profile_probability::always ();
-  e->count = src->count;
   return e;
 }
 
@@ -445,18 +443,6 @@  check_bb_profile (basic_block bb, FILE *
 		       ";; %sInvalid sum of outgoing probabilities %.1f%%\n",
 		       s_indent, isum * 100.0 / REG_BR_PROB_BASE);
 	    }
-	  profile_count lsum = profile_count::zero ();
-	  FOR_EACH_EDGE (e, ei, bb->succs)
-	    lsum += e->count;
-	  if (EDGE_COUNT (bb->succs) && lsum.differs_from_p (bb->count))
-	    {
-	      fprintf (file, ";; %sInvalid sum of outgoing counts ",
-		       s_indent);
-	      lsum.dump (file);
-	      fprintf (file, ", should be ");
-	      bb->count.dump (file);
-	      fprintf (file, "\n");
-	    }
 	}
     }
   if (bb != ENTRY_BLOCK_PTR_FOR_FN (fun))
@@ -468,18 +454,6 @@  check_bb_profile (basic_block bb, FILE *
 	fprintf (file,
 		 ";; %sInvalid sum of incoming frequencies %i, should be %i\n",
 		 s_indent, sum, bb->frequency);
-      profile_count lsum = profile_count::zero ();
-      FOR_EACH_EDGE (e, ei, bb->preds)
-	lsum += e->count;
-      if (lsum.differs_from_p (bb->count))
-	{
-	  fprintf (file, ";; %sInvalid sum of incoming counts ",
-		   s_indent);
-	  lsum.dump (file);
-	  fprintf (file, ", should be ");
-	  bb->count.dump (file);
-	  fprintf (file, "\n");
-	}
     }
   if (BB_PARTITION (bb) == BB_COLD_PARTITION)
     {
@@ -522,10 +496,10 @@  dump_edge_info (FILE *file, edge e, dump
       fprintf (file, "] ");
     }
 
-  if (e->count.initialized_p () && do_details)
+  if (e->count ().initialized_p () && do_details)
     {
       fputs (" count:", file);
-      e->count.dump (file);
+      e->count ().dump (file);
     }
 
   if (e->flags && do_details)
@@ -941,10 +915,6 @@  update_bb_profile_for_threading (basic_b
     }
 
   gcc_assert (bb == taken_edge->src);
-  if (dump_file && taken_edge->count < count)
-    fprintf (dump_file, "edge %i->%i count became negative after threading",
-	     taken_edge->src->index, taken_edge->dest->index);
-  taken_edge->count -= count;
 }
 
 /* Multiply all frequencies of basic blocks in array BBS of length NBBS
@@ -953,7 +923,6 @@  void
 scale_bbs_frequencies_int (basic_block *bbs, int nbbs, int num, int den)
 {
   int i;
-  edge e;
   if (num < 0)
     num = 0;
 
@@ -973,14 +942,11 @@  scale_bbs_frequencies_int (basic_block *
 
   for (i = 0; i < nbbs; i++)
     {
-      edge_iterator ei;
       bbs[i]->frequency = RDIV (bbs[i]->frequency * num, den);
       /* Make sure the frequencies do not grow over BB_FREQ_MAX.  */
       if (bbs[i]->frequency > BB_FREQ_MAX)
 	bbs[i]->frequency = BB_FREQ_MAX;
       bbs[i]->count = bbs[i]->count.apply_scale (num, den);
-      FOR_EACH_EDGE (e, ei, bbs[i]->succs)
-	e->count = e->count.apply_scale (num, den);
     }
 }
 
@@ -996,7 +962,6 @@  scale_bbs_frequencies_gcov_type (basic_b
 				 gcov_type den)
 {
   int i;
-  edge e;
   gcov_type fraction = RDIV (num * 65536, den);
 
   gcc_assert (fraction >= 0);
@@ -1004,29 +969,20 @@  scale_bbs_frequencies_gcov_type (basic_b
   if (num < MAX_SAFE_MULTIPLIER)
     for (i = 0; i < nbbs; i++)
       {
-	edge_iterator ei;
 	bbs[i]->frequency = RDIV (bbs[i]->frequency * num, den);
 	if (bbs[i]->count <= MAX_SAFE_MULTIPLIER)
 	  bbs[i]->count = bbs[i]->count.apply_scale (num, den);
 	else
 	  bbs[i]->count = bbs[i]->count.apply_scale (fraction, 65536);
-	FOR_EACH_EDGE (e, ei, bbs[i]->succs)
-	  if (bbs[i]->count <= MAX_SAFE_MULTIPLIER)
-	    e->count =  e->count.apply_scale (num, den);
-	  else
-	    e->count = e->count.apply_scale (fraction, 65536);
       }
    else
     for (i = 0; i < nbbs; i++)
       {
-	edge_iterator ei;
 	if (sizeof (gcov_type) > sizeof (int))
 	  bbs[i]->frequency = RDIV (bbs[i]->frequency * num, den);
 	else
 	  bbs[i]->frequency = RDIV (bbs[i]->frequency * fraction, 65536);
 	bbs[i]->count = bbs[i]->count.apply_scale (fraction, 65536);
-	FOR_EACH_EDGE (e, ei, bbs[i]->succs)
-	  e->count = e->count.apply_scale (fraction, 65536);
       }
 }
 
@@ -1038,16 +994,12 @@  scale_bbs_frequencies_profile_count (bas
 				     profile_count num, profile_count den)
 {
   int i;
-  edge e;
 
   for (i = 0; i < nbbs; i++)
     {
-      edge_iterator ei;
       bbs[i]->frequency = RDIV (bbs[i]->frequency * num.to_gcov_type (),
 				den.to_gcov_type ());
       bbs[i]->count = bbs[i]->count.apply_scale (num, den);
-      FOR_EACH_EDGE (e, ei, bbs[i]->succs)
-	e->count =  e->count.apply_scale (num, den);
     }
 }
 
@@ -1059,15 +1011,11 @@  scale_bbs_frequencies (basic_block *bbs,
 		       profile_probability p)
 {
   int i;
-  edge e;
 
   for (i = 0; i < nbbs; i++)
     {
-      edge_iterator ei;
       bbs[i]->frequency = p.apply (bbs[i]->frequency);
       bbs[i]->count = bbs[i]->count.apply_probability (p);
-      FOR_EACH_EDGE (e, ei, bbs[i]->succs)
-	e->count =  e->count.apply_probability (p);
     }
 }
 
Index: cfganal.c
===================================================================
--- cfganal.c	(revision 253889)
+++ cfganal.c	(working copy)
@@ -612,7 +612,6 @@  connect_infinite_loops_to_exit (void)
       basic_block deadend_block = dfs_find_deadend (unvisited_block);
       edge e = make_edge (deadend_block, EXIT_BLOCK_PTR_FOR_FN (cfun),
 			  EDGE_FAKE);
-      e->count = profile_count::zero ();
       e->probability = profile_probability::never ();
       dfs.add_bb (deadend_block);
     }
Index: cfgbuild.c
===================================================================
--- cfgbuild.c	(revision 253889)
+++ cfgbuild.c	(working copy)
@@ -576,10 +576,8 @@  compute_outgoing_frequencies (basic_bloc
 	  e = BRANCH_EDGE (b);
 	  e->probability
 		 = profile_probability::from_reg_br_prob_note (probability);
-	  e->count = b->count.apply_probability (e->probability);
 	  f = FALLTHRU_EDGE (b);
 	  f->probability = e->probability.invert ();
-	  f->count = b->count - e->count;
 	  return;
 	}
       else
@@ -591,7 +589,6 @@  compute_outgoing_frequencies (basic_bloc
     {
       e = single_succ_edge (b);
       e->probability = profile_probability::always ();
-      e->count = b->count;
       return;
     }
   else
@@ -610,10 +607,6 @@  compute_outgoing_frequencies (basic_bloc
       if (complex_edge)
         guess_outgoing_edge_probabilities (b);
     }
-
-  if (b->count.initialized_p ())
-    FOR_EACH_EDGE (e, ei, b->succs)
-      e->count = b->count.apply_probability (e->probability);
 }
 
 /* Assume that some pass has inserted labels or control flow
@@ -679,9 +672,9 @@  find_many_sub_basic_blocks (sbitmap bloc
 	    bb->frequency = 0;
 	    FOR_EACH_EDGE (e, ei, bb->preds)
 	      {
-		if (e->count.initialized_p ())
+		if (e->count ().initialized_p ())
 		  {
-		    bb->count += e->count;
+		    bb->count += e->count ();
 		    initialized_src = true;
 		  }
 		else
Index: cfgcleanup.c
===================================================================
--- cfgcleanup.c	(revision 253889)
+++ cfgcleanup.c	(working copy)
@@ -558,7 +558,7 @@  try_forward_edges (int mode, basic_block
       else
 	{
 	  /* Save the values now, as the edge may get removed.  */
-	  profile_count edge_count = e->count;
+	  profile_count edge_count = e->count ();
 	  profile_probability edge_probability = e->probability;
 	  int edge_frequency;
 	  int n = 0;
@@ -616,7 +616,6 @@  try_forward_edges (int mode, basic_block
 		  t = single_succ_edge (first);
 		}
 
-	      t->count -= edge_count;
 	      first = t->dest;
 	    }
 	  while (first != target);
@@ -2129,22 +2128,16 @@  try_crossjump_to_edge (int mode, edge e1
 	    break;
 	}
 
-      s->count += s2->count;
-
       /* Take care to update possible forwarder blocks.  We verified
 	 that there is no more than one in the chain, so we can't run
 	 into infinite loop.  */
       if (FORWARDER_BLOCK_P (s->dest))
 	{
-	  single_succ_edge (s->dest)->count += s2->count;
-	  s->dest->count += s2->count;
 	  s->dest->frequency += EDGE_FREQUENCY (s);
 	}
 
       if (FORWARDER_BLOCK_P (s2->dest))
 	{
-	  single_succ_edge (s2->dest)->count -= s2->count;
-	  s2->dest->count -= s2->count;
 	  s2->dest->frequency -= EDGE_FREQUENCY (s);
 	  if (s2->dest->frequency < 0)
 	    s2->dest->frequency = 0;
Index: cfgexpand.c
===================================================================
--- cfgexpand.c	(revision 253889)
+++ cfgexpand.c	(working copy)
@@ -2507,7 +2507,7 @@  expand_gimple_cond (basic_block bb, gcon
   dest = false_edge->dest;
   redirect_edge_succ (false_edge, new_bb);
   false_edge->flags |= EDGE_FALLTHRU;
-  new_bb->count = false_edge->count;
+  new_bb->count = false_edge->count ();
   new_bb->frequency = EDGE_FREQUENCY (false_edge);
   loop_p loop = find_common_loop (bb->loop_father, dest->loop_father);
   add_bb_to_loop (new_bb, loop);
@@ -3818,7 +3818,6 @@  expand_gimple_tailcall (basic_block bb,
      the exit block.  */
 
   probability = profile_probability::never ();
-  profile_count count = profile_count::zero ();
 
   for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); )
     {
@@ -3826,12 +3825,10 @@  expand_gimple_tailcall (basic_block bb,
 	{
 	  if (e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun))
 	    {
-	      e->dest->count -= e->count;
 	      e->dest->frequency -= EDGE_FREQUENCY (e);
 	      if (e->dest->frequency < 0)
 		e->dest->frequency = 0;
 	    }
-	  count += e->count;
 	  probability += e->probability;
 	  remove_edge (e);
 	}
@@ -3861,7 +3858,6 @@  expand_gimple_tailcall (basic_block bb,
   e = make_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun), EDGE_ABNORMAL
 		 | EDGE_SIBCALL);
   e->probability = probability;
-  e->count = count;
   BB_END (bb) = last;
   update_bb_for_insn (bb);
 
@@ -5931,8 +5927,7 @@  construct_exit_block (void)
   FOR_EACH_EDGE (e2, ei, EXIT_BLOCK_PTR_FOR_FN (cfun)->preds)
     if (e2 != e)
       {
-	e->count -= e2->count;
-	exit_block->count -= e2->count;
+	exit_block->count -= e2->count ();
 	exit_block->frequency -= EDGE_FREQUENCY (e2);
       }
   if (exit_block->frequency < 0)
Index: cfghooks.c
===================================================================
--- cfghooks.c	(revision 253889)
+++ cfghooks.c	(working copy)
@@ -176,12 +191,6 @@  verify_flow_info (void)
 		     e->src->index, e->dest->index);
 	      err = 1;
 	    }
-	  if (!e->count.verify ())
-	    {
-	      error ("verify_flow_info: Wrong count of edge %i->%i",
-		     e->src->index, e->dest->index);
-	      err = 1;
-	    }
 
 	  last_visited [e->dest->index] = bb;
 
@@ -453,7 +462,6 @@  redirect_edge_succ_nodup (edge e, basic_
     {
       s->flags |= e->flags;
       s->probability += e->probability;
-      s->count += e->count;
       /* FIXME: This should be called via a hook and only for IR_GIMPLE.  */
       redirect_edge_var_map_dup (s, e);
       remove_edge (e);
@@ -632,7 +640,7 @@  basic_block
 split_edge (edge e)
 {
   basic_block ret;
-  profile_count count = e->count;
+  profile_count count = e->count ();
   int freq = EDGE_FREQUENCY (e);
   edge f;
   bool irr = (e->flags & EDGE_IRREDUCIBLE_LOOP) != 0;
@@ -649,7 +657,6 @@  split_edge (edge e)
   ret->count = count;
   ret->frequency = freq;
   single_succ_edge (ret)->probability = profile_probability::always ();
-  single_succ_edge (ret)->count = count;
 
   if (irr)
     {
@@ -878,7 +885,6 @@  make_forwarder_block (basic_block bb, bo
   dummy = fallthru->src;
   dummy->count = profile_count::zero ();
   dummy->frequency = 0;
-  fallthru->count = profile_count::zero ();
   bb = fallthru->dest;
 
   /* Redirect back edges we want to keep.  */
@@ -892,8 +898,7 @@  make_forwarder_block (basic_block bb, bo
 	  if (dummy->frequency > BB_FREQ_MAX)
 	    dummy->frequency = BB_FREQ_MAX;
 
-	  dummy->count += e->count;
-	  fallthru->count += e->count;
+	  dummy->count += e->count ();
 	  ei_next (&ei);
 	  continue;
 	}
@@ -1079,7 +1084,7 @@  duplicate_block (basic_block bb, edge e,
 {
   edge s, n;
   basic_block new_bb;
-  profile_count new_count = e ? e->count : profile_count::uninitialized ();
+  profile_count new_count = e ? e->count (): profile_count::uninitialized ();
   edge_iterator ei;
 
   if (!cfg_hooks->duplicate_block)
@@ -1103,13 +1108,6 @@  duplicate_block (basic_block bb, edge e,
 	 is no need to actually check for duplicated edges.  */
       n = unchecked_make_edge (new_bb, s->dest, s->flags);
       n->probability = s->probability;
-      if (e && bb->count > profile_count::zero ())
-	{
-	  n->count = s->count.apply_scale (new_count, bb->count);
-	  s->count -= n->count;
-	}
-      else
-	n->count = s->count;
       n->aux = s->aux;
     }
 
@@ -1473,7 +1471,7 @@  account_profile_record (struct profile_r
 	    record->num_mismatched_freq_out[after_pass]++;
 	  profile_count lsum = profile_count::zero ();
 	  FOR_EACH_EDGE (e, ei, bb->succs)
-	    lsum += e->count;
+	    lsum += e->count ();
 	  if (EDGE_COUNT (bb->succs) && (lsum.differs_from_p (bb->count)))
 	    record->num_mismatched_count_out[after_pass]++;
 	}
@@ -1489,7 +1487,7 @@  account_profile_record (struct profile_r
 	    record->num_mismatched_freq_in[after_pass]++;
 	  profile_count lsum = profile_count::zero ();
 	  FOR_EACH_EDGE (e, ei, bb->preds)
-	    lsum += e->count;
+	    lsum += e->count ();
 	  if (lsum.differs_from_p (bb->count))
 	    record->num_mismatched_count_in[after_pass]++;
 	}
Index: cfgloop.c
===================================================================
--- cfgloop.c	(revision 253889)
+++ cfgloop.c	(working copy)
@@ -599,12 +599,12 @@  find_subloop_latch_edge_by_profile (vec<
 
   FOR_EACH_VEC_ELT (latches, i, e)
     {
-      if (e->count > mcount)
+      if (e->count ()> mcount)
 	{
 	  me = e;
-	  mcount = e->count;
+	  mcount = e->count();
 	}
-      tcount += e->count;
+      tcount += e->count();
     }
 
   if (!tcount.initialized_p () || tcount < HEAVY_EDGE_MIN_SAMPLES
Index: cfgloopanal.c
===================================================================
--- cfgloopanal.c	(revision 253889)
+++ cfgloopanal.c	(working copy)
@@ -253,9 +253,9 @@  expected_loop_iterations_unbounded (cons
 
       FOR_EACH_EDGE (e, ei, loop->header->preds)
 	if (e->src == loop->latch)
-	  count_latch = e->count;
+	  count_latch = e->count ();
 	else
-	  count_in += e->count;
+	  count_in += e->count ();
 
       if (!count_latch.initialized_p ())
 	;
Index: cfgloopmanip.c
===================================================================
--- cfgloopmanip.c	(revision 253889)
+++ cfgloopmanip.c	(working copy)
@@ -546,16 +546,12 @@  scale_loop_profile (struct loop *loop, p
 
 	  /* Probability of exit must be 1/iterations.  */
 	  freq_delta = EDGE_FREQUENCY (e);
+	  count_delta = e->count ();
 	  e->probability = profile_probability::always ()
 				.apply_scale (1, iteration_bound);
 	  other_e->probability = e->probability.invert ();
 	  freq_delta -= EDGE_FREQUENCY (e);
-
-	  /* Adjust counts accordingly.  */
-	  count_delta = e->count;
-	  e->count = e->src->count.apply_probability (e->probability);
-	  other_e->count = e->src->count.apply_probability (other_e->probability);
-	  count_delta -= e->count;
+	  count_delta -= e->count ();
 
 	  /* If latch exists, change its frequency and count, since we changed
 	     probability of exit.  Theoretically we should update everything from
@@ -582,7 +578,7 @@  scale_loop_profile (struct loop *loop, p
 
 	  FOR_EACH_EDGE (e, ei, loop->header->preds)
 	    if (e->src != loop->latch)
-	      count_in += e->count;
+	      count_in += e->count ();
 
 	  if (count_in > profile_count::zero () )
 	    {
@@ -872,14 +868,12 @@  loopify (edge latch_edge, edge header_ed
   struct loop *outer = loop_outer (succ_bb->loop_father);
   int freq;
   profile_count cnt;
-  edge e;
-  edge_iterator ei;
 
   loop->header = header_edge->dest;
   loop->latch = latch_edge->src;
 
   freq = EDGE_FREQUENCY (header_edge);
-  cnt = header_edge->count;
+  cnt = header_edge->count ();
 
   /* Redirect edges.  */
   loop_redirect_edge (latch_edge, loop->header);
@@ -912,10 +906,6 @@  loopify (edge latch_edge, edge header_ed
     {
       switch_bb->frequency = freq;
       switch_bb->count = cnt;
-      FOR_EACH_EDGE (e, ei, switch_bb->succs)
-	{
-	  e->count = switch_bb->count.apply_probability (e->probability);
-	}
     }
   scale_loop_frequencies (loop, false_scale);
   scale_loop_frequencies (succ_bb->loop_father, true_scale);
@@ -1650,8 +1640,6 @@  lv_adjust_loop_entry_edge (basic_block f
 		  current_ir_type () == IR_GIMPLE ? EDGE_TRUE_VALUE : 0);
   e1->probability = then_prob;
   e->probability = else_prob;
-  e1->count = e->count.apply_probability (e1->probability);
-  e->count = e->count.apply_probability (e->probability);
 
   set_immediate_dominator (CDI_DOMINATORS, first_head, new_head);
   set_immediate_dominator (CDI_DOMINATORS, second_head, new_head);
Index: cfgrtl.c
===================================================================
--- cfgrtl.c	(revision 253889)
+++ cfgrtl.c	(working copy)
@@ -1156,7 +1156,6 @@  try_redirect_by_replacing_jump (edge e,
     e->flags = 0;
 
   e->probability = profile_probability::always ();
-  e->count = src->count;
 
   if (e->dest != target)
     redirect_edge_succ (e, target);
@@ -1505,9 +1504,7 @@  force_nonfallthru_and_redirect (edge e,
 	  int prob = XINT (note, 0);
 
 	  b->probability = profile_probability::from_reg_br_prob_note (prob);
-	  b->count = e->count.apply_probability (b->probability);
 	  e->probability -= e->probability;
-	  e->count -= b->count;
 	}
     }
 
@@ -1615,7 +1612,7 @@  force_nonfallthru_and_redirect (edge e,
   if (EDGE_COUNT (e->src->succs) >= 2 || abnormal_edge_flags || asm_goto_edge)
     {
       rtx_insn *new_head;
-      profile_count count = e->count;
+      profile_count count = e->count ();
      profile_probability probability = e->probability;
       /* Create the new structures.  */
 
@@ -1640,7 +1637,6 @@  force_nonfallthru_and_redirect (edge e,
       /* Wire edge in.  */
       new_edge = make_edge (e->src, jump_block, EDGE_FALLTHRU);
       new_edge->probability = probability;
-      new_edge->count = count;
 
       /* Redirect old edge.  */
       redirect_edge_pred (e, jump_block);
@@ -1655,13 +1651,11 @@  force_nonfallthru_and_redirect (edge e,
       if (asm_goto_edge)
 	{
 	  new_edge->probability = new_edge->probability.apply_scale (1, 2);
-	  new_edge->count = new_edge->count.apply_scale (1, 2);
 	  jump_block->count = jump_block->count.apply_scale (1, 2);
 	  jump_block->frequency /= 2;
 	  edge new_edge2 = make_edge (new_edge->src, target,
 				      e->flags & ~EDGE_FALLTHRU);
 	  new_edge2->probability = probability - new_edge->probability;
-	  new_edge2->count = count - new_edge->count;
 	}
 
       new_bb = jump_block;
@@ -3155,7 +3149,6 @@  purge_dead_edges (basic_block bb)
       if (single_succ_p (bb))
 	{
 	  single_succ_edge (bb)->probability = profile_probability::always ();
-	  single_succ_edge (bb)->count = bb->count;
 	}
       else
 	{
@@ -3168,8 +3161,6 @@  purge_dead_edges (basic_block bb)
 	  b->probability = profile_probability::from_reg_br_prob_note
 					 (XINT (note, 0));
 	  f->probability = b->probability.invert ();
-	  b->count = bb->count.apply_probability (b->probability);
-	  f->count = bb->count.apply_probability (f->probability);
 	}
 
       return purged;
@@ -3221,7 +3212,6 @@  purge_dead_edges (basic_block bb)
   gcc_assert (single_succ_p (bb));
 
   single_succ_edge (bb)->probability = profile_probability::always ();
-  single_succ_edge (bb)->count = bb->count;
 
   if (dump_file)
     fprintf (dump_file, "Purged non-fallthru edges from bb %i\n",
@@ -4906,7 +4896,6 @@  rtl_flow_call_edges_add (sbitmap blocks)
 
 	      edge ne = make_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun), EDGE_FAKE);
 	      ne->probability = profile_probability::guessed_never ();
-	      ne->count = profile_count::guessed_zero ();
 	    }
 
 	  if (insn == BB_HEAD (bb))
Index: cgraphunit.c
===================================================================
--- cgraphunit.c	(revision 253889)
+++ cgraphunit.c	(working copy)
@@ -1608,10 +1608,8 @@  init_lowered_empty_function (tree decl,
   bb->count = count;
   bb->frequency = BB_FREQ_MAX;
   e = make_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun), bb, EDGE_FALLTHRU);
-  e->count = count;
   e->probability = profile_probability::always ();
   e = make_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun), 0);
-  e->count = count;
   e->probability = profile_probability::always ();
   add_bb_to_loop (bb, ENTRY_BLOCK_PTR_FOR_FN (cfun)->loop_father);
 
@@ -1988,17 +1986,14 @@  cgraph_node::expand_thunk (bool output_a
 		  e = make_edge (bb, then_bb, EDGE_TRUE_VALUE);
 		  e->probability = profile_probability::guessed_always ()
 					.apply_scale (1, 16);
-		  e->count = count - count.apply_scale (1, 16);
 		  e = make_edge (bb, else_bb, EDGE_FALSE_VALUE);
 		  e->probability = profile_probability::guessed_always ()
 					.apply_scale (1, 16);
-		  e->count = count.apply_scale (1, 16);
 		  make_single_succ_edge (return_bb,
 					 EXIT_BLOCK_PTR_FOR_FN (cfun), 0);
 		  make_single_succ_edge (then_bb, return_bb, EDGE_FALLTHRU);
 		  e = make_edge (else_bb, return_bb, EDGE_FALLTHRU);
 		  e->probability = profile_probability::always ();
-		  e->count = count.apply_scale (1, 16);
 		  bsi = gsi_last_bb (then_bb);
 		}
 
Index: gimple-pretty-print.c
===================================================================
--- gimple-pretty-print.c	(revision 253889)
+++ gimple-pretty-print.c	(working copy)
@@ -109,7 +109,7 @@  dump_profile (int frequency, profile_cou
    by xstrdup_for_dump.  */
 
 static const char *
-dump_probability (profile_probability probability, profile_count &count)
+dump_probability (profile_probability probability)
 {
   float minimum = 0.01f;
   float fvalue = -1;
@@ -122,13 +122,10 @@  dump_probability (profile_probability pr
     }
 
   char *buf;
-  if (count.initialized_p ())
-    buf = xasprintf ("[%.2f%%] [count: %" PRId64 "]", fvalue,
-		     count.to_gcov_type ());
-  else if (probability.initialized_p ())
-    buf = xasprintf ("[%.2f%%] [count: INV]", fvalue);
+  if (probability.initialized_p ())
+    buf = xasprintf ("[%.2f%%]", fvalue);
   else
-    buf = xasprintf ("[INV] [count: INV]");
+    buf = xasprintf ("[INV]");
 
   const char *ret = xstrdup_for_dump (buf);
   free (buf);
@@ -141,7 +138,7 @@  dump_probability (profile_probability pr
 static void
 dump_edge_probability (pretty_printer *buffer, edge e)
 {
-  pp_scalar (buffer, " %s", dump_probability (e->probability, e->count));
+  pp_scalar (buffer, " %s", dump_probability (e->probability));
 }
 
 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
Index: gimple-ssa-isolate-paths.c
===================================================================
--- gimple-ssa-isolate-paths.c	(revision 253889)
+++ gimple-ssa-isolate-paths.c	(working copy)
@@ -169,7 +169,6 @@  isolate_path (basic_block bb, basic_bloc
 
       /* Update profile only when redirection is really processed.  */
       bb->frequency += EDGE_FREQUENCY (e);
-      bb->count += e->count;
     }
 
   /* There may be more than one statement in DUPLICATE which exhibits
Index: haifa-sched.c
===================================================================
--- haifa-sched.c	(revision 253889)
+++ haifa-sched.c	(working copy)
@@ -8311,11 +8311,9 @@  sched_create_recovery_edges (basic_block
      'todo_spec' variable in create_check_block_twin and
      in sel-sched.c `check_ds' in create_speculation_check.  */
   e->probability = profile_probability::very_unlikely ();
-  e->count = first_bb->count.apply_probability (e->probability);
-  rec->count = e->count;
+  rec->count = e->count ();
   rec->frequency = EDGE_FREQUENCY (e);
   e2->probability = e->probability.invert ();
-  e2->count = first_bb->count - e2->count;
 
   rtx_code_label *label = block_label (second_bb);
   rtx_jump_insn *jump = emit_jump_insn_after (targetm.gen_jump (label),
Index: hsa-gen.c
===================================================================
--- hsa-gen.c	(revision 253889)
+++ hsa-gen.c	(working copy)
@@ -6271,7 +6271,7 @@  convert_switch_statements (void)
 	    tree label = gimple_switch_label (s, i);
 	    basic_block label_bb = label_to_block_fn (func, CASE_LABEL (label));
 	    edge e = find_edge (bb, label_bb);
-	    edge_counts.safe_push (e->count);
+	    edge_counts.safe_push (e->count ());
 	    edge_probabilities.safe_push (e->probability);
 	    gphi_iterator phi_gsi;
 
@@ -6361,7 +6361,6 @@  convert_switch_statements (void)
 	    if (prob_sum.initialized_p ())
 	      new_edge->probability = edge_probabilities[i] / prob_sum;
 
-	    new_edge->count = edge_counts[i];
 	    new_edges.safe_push (new_edge);
 
 	    if (i < labels - 1)
@@ -6377,9 +6376,6 @@  convert_switch_statements (void)
 
 		edge next_edge = make_edge (cur_bb, next_bb, EDGE_FALSE_VALUE);
 		next_edge->probability = new_edge->probability.invert ();
-		next_edge->count = edge_counts[0]
-		  + sum_slice <profile_count> (edge_counts, i, labels,
-					       profile_count::zero ());
 		next_bb->frequency = EDGE_FREQUENCY (next_edge);
 		cur_bb = next_bb;
 	      }
@@ -6388,7 +6384,6 @@  convert_switch_statements (void)
 	      {
 		edge e = make_edge (cur_bb, default_label_bb, EDGE_FALSE_VALUE);
 		e->probability = new_edge->probability.invert ();
-		e->count = edge_counts[0];
 		new_edges.safe_insert (0, e);
 	      }
 	  }
Index: ifcvt.c
===================================================================
--- ifcvt.c	(revision 253889)
+++ ifcvt.c	(working copy)
@@ -5283,8 +5283,6 @@  dead_or_predicable (basic_block test_bb,
       redirect_edge_succ (BRANCH_EDGE (test_bb), new_dest);
       if (reversep)
 	{
-	  std::swap (BRANCH_EDGE (test_bb)->count,
-		     FALLTHRU_EDGE (test_bb)->count);
 	  std::swap (BRANCH_EDGE (test_bb)->probability,
 		     FALLTHRU_EDGE (test_bb)->probability);
 	  update_br_prob_note (test_bb);
Index: ipa-inline-transform.c
===================================================================
--- ipa-inline-transform.c	(revision 253889)
+++ ipa-inline-transform.c	(working copy)
@@ -692,14 +692,7 @@  inline_transform (struct cgraph_node *no
 
 	  basic_block bb;
 	  FOR_ALL_BB_FN (bb, cfun)
-	    {
-	      bb->count = bb->count.apply_scale (num, den);
-	
-	      edge e;
-	      edge_iterator ei;
-	      FOR_EACH_EDGE (e, ei, bb->succs)
-		e->count = e->count.apply_scale (num, den);
-	    }
+	    bb->count = bb->count.apply_scale (num, den);
 	  ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = node->count;
 	}
       todo = optimize_inline_calls (current_function_decl);
Index: ipa-split.c
===================================================================
--- ipa-split.c	(revision 253889)
+++ ipa-split.c	(working copy)
@@ -1285,7 +1285,6 @@  split_function (basic_block return_bb, s
 	  FOR_EACH_EDGE (e, ei, return_bb->preds)
 	    if (bitmap_bit_p (split_point->split_bbs, e->src->index))
 	      {
-		new_return_bb->count += e->count;
 		new_return_bb->frequency += EDGE_FREQUENCY (e);
 		redirect_edge_and_branch (e, new_return_bb);
 		redirected = true;
Index: ipa-utils.c
===================================================================
--- ipa-utils.c	(revision 253889)
+++ ipa-utils.c	(working copy)
@@ -524,20 +524,28 @@  ipa_merge_profiles (struct cgraph_node *
 	  unsigned int i;
 
 	  dstbb = BASIC_BLOCK_FOR_FN (dstcfun, srcbb->index);
-	  if (dstbb->count.initialized_p ())
-	    dstbb->count += srcbb->count;
-	  else
-	    dstbb->count = srcbb->count;
-	  for (i = 0; i < EDGE_COUNT (srcbb->succs); i++)
+	  if (!dstbb->count.initialized_p ())
 	    {
-	      edge srce = EDGE_SUCC (srcbb, i);
-	      edge dste = EDGE_SUCC (dstbb, i);
-	      if (dstbb->count.initialized_p ())
-	        dste->count += srce->count;
-	      else
-		dste->count = srce->count;
-	      if (dstbb->count > 0 && dste->count.initialized_p ())
-		dste->probability = dste->count.probability_in (dstbb->count);
+	      dstbb->count = srcbb->count;
+	      for (i = 0; i < EDGE_COUNT (srcbb->succs); i++)
+		{
+		  edge srce = EDGE_SUCC (srcbb, i);
+		  edge dste = EDGE_SUCC (dstbb, i);
+		  if (srce->probability.initialized_p ())
+		    dste->probability = srce->probability;
+		}
+	    }	
+	  else if (srcbb->count.initialized_p ())
+	    {
+	      for (i = 0; i < EDGE_COUNT (srcbb->succs); i++)
+		{
+		  edge srce = EDGE_SUCC (srcbb, i);
+		  edge dste = EDGE_SUCC (dstbb, i);
+		  dste->probability = 
+		    dste->probability * dstbb->count.probability_in (dstbb->count + srcbb->count)
+		    + srce->probability * srcbb->count.probability_in (dstbb->count + srcbb->count);
+		}
+	      dstbb->count += srcbb->count;
 	    }
 	}
       push_cfun (dstcfun);
Index: loop-doloop.c
===================================================================
--- loop-doloop.c	(revision 253889)
+++ loop-doloop.c	(working copy)
@@ -393,9 +393,7 @@  add_test (rtx cond, edge *e, basic_block
 
   edge e2 = make_edge (bb, dest, (*e)->flags & ~EDGE_FALLTHRU);
   e2->probability = prob;
-  e2->count = e2->src->count.apply_probability (prob);
   (*e)->probability = prob.invert ();
-  (*e)->count = (*e)->count.apply_probability (prob);
   update_br_prob_note (e2->src);
   return true;
 }
Index: loop-unroll.c
===================================================================
--- loop-unroll.c	(revision 253889)
+++ loop-unroll.c	(working copy)
@@ -977,7 +977,6 @@  unroll_loop_runtime_iterations (struct l
   iter_count = new_count = swtch->count.apply_scale (1, max_unroll + 1);
   swtch->frequency = new_freq;
   swtch->count = new_count;
-  single_succ_edge (swtch)->count = new_count;
 
   for (i = 0; i < n_peel; i++)
     {
@@ -999,7 +998,6 @@  unroll_loop_runtime_iterations (struct l
       /* Add in frequency/count of edge from switch block.  */
       preheader->frequency += iter_freq;
       preheader->count += iter_count;
-      single_succ_edge (preheader)->count = preheader->count;
       branch_code = compare_and_jump_seq (copy_rtx (niter), GEN_INT (j), EQ,
 					  block_label (preheader), p,
 					  NULL);
@@ -1011,14 +1009,12 @@  unroll_loop_runtime_iterations (struct l
       swtch = split_edge_and_insert (single_pred_edge (swtch), branch_code);
       set_immediate_dominator (CDI_DOMINATORS, preheader, swtch);
       single_succ_edge (swtch)->probability = p.invert ();
-      single_succ_edge (swtch)->count = new_count;
       new_freq += iter_freq;
       new_count += iter_count;
       swtch->frequency = new_freq;
       swtch->count = new_count;
       e = make_edge (swtch, preheader,
 		     single_succ_edge (swtch)->flags & EDGE_IRREDUCIBLE_LOOP);
-      e->count = iter_count;
       e->probability = p;
     }
 
@@ -1035,7 +1031,6 @@  unroll_loop_runtime_iterations (struct l
       /* Add in frequency/count of edge from switch block.  */
       preheader->frequency += iter_freq;
       preheader->count += iter_count;
-      single_succ_edge (preheader)->count = preheader->count;
       branch_code = compare_and_jump_seq (copy_rtx (niter), const0_rtx, EQ,
 					  block_label (preheader), p,
 					  NULL);
@@ -1044,10 +1039,8 @@  unroll_loop_runtime_iterations (struct l
       swtch = split_edge_and_insert (single_succ_edge (swtch), branch_code);
       set_immediate_dominator (CDI_DOMINATORS, preheader, swtch);
       single_succ_edge (swtch)->probability = p.invert ();
-      single_succ_edge (swtch)->count -= iter_count;
       e = make_edge (swtch, preheader,
 		     single_succ_edge (swtch)->flags & EDGE_IRREDUCIBLE_LOOP);
-      e->count = iter_count;
       e->probability = p;
     }
 
Index: lto-streamer-in.c
===================================================================
--- lto-streamer-in.c	(revision 253889)
+++ lto-streamer-in.c	(working copy)
@@ -715,8 +715,7 @@  make_new_block (struct function *fn, uns
 
 static void
 input_cfg (struct lto_input_block *ib, struct data_in *data_in,
-	   struct function *fn,
-	   int count_materialization_scale)
+	   struct function *fn)
 {
   unsigned int bb_count;
   basic_block p_bb;
@@ -756,13 +755,10 @@  input_cfg (struct lto_input_block *ib, s
 	  unsigned int edge_flags;
 	  basic_block dest;
 	  profile_probability probability;
-	  profile_count count;
 	  edge e;
 
 	  dest_index = streamer_read_uhwi (ib);
 	  probability = profile_probability::stream_in (ib);
-	  count = profile_count::stream_in (ib).apply_scale
-			 (count_materialization_scale, REG_BR_PROB_BASE);
 	  edge_flags = streamer_read_uhwi (ib);
 
 	  dest = BASIC_BLOCK_FOR_FN (fn, dest_index);
@@ -772,7 +768,6 @@  input_cfg (struct lto_input_block *ib, s
 
 	  e = make_edge (bb, dest, edge_flags);
 	  e->probability = probability;
-	  e->count = count;
 	}
 
       index = streamer_read_hwi (ib);
@@ -1070,7 +1065,7 @@  input_function (tree fn_decl, struct dat
   if (!node)
     node = cgraph_node::create (fn_decl);
   input_struct_function_base (fn, data_in, ib);
-  input_cfg (ib_cfg, data_in, fn, node->count_materialization_scale);
+  input_cfg (ib_cfg, data_in, fn);
 
   /* Read all the SSA names.  */
   input_ssa_names (ib, data_in, fn);
Index: lto-streamer-out.c
===================================================================
--- lto-streamer-out.c	(revision 253889)
+++ lto-streamer-out.c	(working copy)
@@ -1883,7 +1883,6 @@  output_cfg (struct output_block *ob, str
 	{
 	  streamer_write_uhwi (ob, e->dest->index);
 	  e->probability.stream_out (ob);
-	  e->count.stream_out (ob);
 	  streamer_write_uhwi (ob, e->flags);
 	}
     }
Index: modulo-sched.c
===================================================================
--- modulo-sched.c	(revision 253889)
+++ modulo-sched.c	(working copy)
@@ -1422,15 +1422,15 @@  sms_schedule (void)
       get_ebb_head_tail (bb, bb, &head, &tail);
       latch_edge = loop_latch_edge (loop);
       gcc_assert (single_exit (loop));
-      if (single_exit (loop)->count > profile_count::zero ())
-	trip_count = latch_edge->count.to_gcov_type ()
-		     / single_exit (loop)->count.to_gcov_type ();
+      if (single_exit (loop)->count () > profile_count::zero ())
+	trip_count = latch_edge->count ().to_gcov_type ()
+		     / single_exit (loop)->count ().to_gcov_type ();
 
       /* Perform SMS only on loops that their average count is above threshold.  */
 
-      if ( latch_edge->count > profile_count::zero ()
-          && (latch_edge->count
-	      < single_exit (loop)->count.apply_scale
+      if ( latch_edge->count () > profile_count::zero ()
+          && (latch_edge->count()
+	      < single_exit (loop)->count ().apply_scale
 				 (SMS_LOOP_AVERAGE_COUNT_THRESHOLD, 1)))
 	{
 	  if (dump_file)
@@ -1552,9 +1552,9 @@  sms_schedule (void)
 
       latch_edge = loop_latch_edge (loop);
       gcc_assert (single_exit (loop));
-      if (single_exit (loop)->count > profile_count::zero ())
-	trip_count = latch_edge->count.to_gcov_type ()
-		     / single_exit (loop)->count.to_gcov_type ();
+      if (single_exit (loop)->count ()> profile_count::zero ())
+	trip_count = latch_edge->count ().to_gcov_type ()
+		     / single_exit (loop)->count ().to_gcov_type ();
 
       if (dump_file)
 	{
Index: postreload-gcse.c
===================================================================
--- postreload-gcse.c	(revision 253889)
+++ postreload-gcse.c	(working copy)
@@ -1108,14 +1108,14 @@  eliminate_partially_redundant_load (basi
 	    avail_insn = NULL;
 	}
 
-      if (EDGE_CRITICAL_P (pred) && pred->count.initialized_p ())
-	critical_count += pred->count;
+      if (EDGE_CRITICAL_P (pred) && pred->count ().initialized_p ())
+	critical_count += pred->count ();
 
       if (avail_insn != NULL_RTX)
 	{
 	  npred_ok++;
-	  if (pred->count.initialized_p ())
-	    ok_count = ok_count + pred->count;
+	  if (pred->count ().initialized_p ())
+	    ok_count = ok_count + pred->count ();
 	  if (! set_noop_p (PATTERN (gen_move_insn (copy_rtx (dest),
 						    copy_rtx (avail_reg)))))
 	    {
@@ -1139,8 +1139,8 @@  eliminate_partially_redundant_load (basi
 	  /* Adding a load on a critical edge will cause a split.  */
 	  if (EDGE_CRITICAL_P (pred))
 	    critical_edge_split = true;
-	  if (pred->count.initialized_p ())
-	    not_ok_count = not_ok_count + pred->count;
+	  if (pred->count ().initialized_p ())
+	    not_ok_count = not_ok_count + pred->count ();
 	  unoccr = (struct unoccr *) obstack_alloc (&unoccr_obstack,
 						    sizeof (struct unoccr));
 	  unoccr->insn = NULL;
Index: predict.c
===================================================================
--- predict.c	(revision 253889)
+++ predict.c	(working copy)
@@ -203,7 +203,7 @@  maybe_hot_bb_p (struct function *fun, co
 bool
 maybe_hot_edge_p (edge e)
 {
-  if (!maybe_hot_count_p (cfun, e->count))
+  if (!maybe_hot_count_p (cfun, e->count ()))
     return false;
   return maybe_hot_frequency_p (cfun, EDGE_FREQUENCY (e));
 }
@@ -247,7 +247,7 @@  probably_never_executed_bb_p (struct fun
 static bool
 unlikely_executed_edge_p (edge e)
 {
-  return (e->count == profile_count::zero ()
+  return (e->count () == profile_count::zero ()
 	  || e->probability == profile_probability::never ())
 	 || (e->flags & (EDGE_EH | EDGE_FAKE));
 }
@@ -259,7 +259,7 @@  probably_never_executed_edge_p (struct f
 {
   if (unlikely_executed_edge_p (e))
     return true;
-  return probably_never_executed (fun, e->count, EDGE_FREQUENCY (e));
+  return probably_never_executed (fun, e->count (), EDGE_FREQUENCY (e));
 }
 
 /* Return true when current function should always be optimized for size.  */
@@ -746,8 +746,8 @@  dump_prediction (FILE *file, enum br_pre
       if (e)
 	{
 	  fprintf (file, " hit ");
-	  e->count.dump (file);
-	  fprintf (file, " (%.1f%%)", e->count.to_gcov_type() * 100.0
+	  e->count ().dump (file);
+	  fprintf (file, " (%.1f%%)", e->count ().to_gcov_type() * 100.0
 		   / bb->count.to_gcov_type ());
 	}
     }
@@ -3199,21 +3199,14 @@  drop_profile (struct cgraph_node *node,
   FOR_ALL_BB_FN (bb, fn)
     {
       bb->count = profile_count::uninitialized ();
-
-      edge_iterator ei;
-      edge e;
-      FOR_EACH_EDGE (e, ei, bb->preds)
-	e->count = profile_count::uninitialized ();
     }
 
   struct cgraph_edge *e;
   for (e = node->callees; e; e = e->next_caller)
     {
-      e->count = profile_count::uninitialized ();
       e->frequency = compute_call_stmt_bb_frequency (e->caller->decl,
 						     gimple_bb (e->call_stmt));
     }
-  node->count = profile_count::uninitialized ();
   
   profile_status_for_fn (fn)
       = (flag_guess_branch_prob ? PROFILE_GUESSED : PROFILE_ABSENT);
@@ -3396,7 +3389,7 @@  propagate_unlikely_bbs_forward (void)
 	{
 	  bb = worklist.pop ();
 	  FOR_EACH_EDGE (e, ei, bb->succs)
-	    if (!(e->count == profile_count::zero ())
+	    if (!(e->count () == profile_count::zero ())
 		&& !(e->dest->count == profile_count::zero ())
 		&& !e->dest->aux)
 	      {
@@ -3417,8 +3410,6 @@  propagate_unlikely_bbs_forward (void)
 		     bb->index);
 	  bb->count = profile_count::zero ();
 	  bb->frequency = 0;
-          FOR_EACH_EDGE (e, ei, bb->succs)
-	    e->count = profile_count::zero ();
 	}
       else
         bb->aux = NULL;
@@ -3450,20 +3441,16 @@  determine_unlikely_bbs ()
 	}
 
       if (bb->count == profile_count::zero ())
-	{
-	  bb->frequency = 0;
-          FOR_EACH_EDGE (e, ei, bb->preds)
-	    e->count = profile_count::zero ();
-	}
+        bb->frequency = 0;
 
       FOR_EACH_EDGE (e, ei, bb->succs)
-	if (!(e->count == profile_count::zero ())
+	if (!(e->probability == profile_probability::never ())
 	    && unlikely_executed_edge_p (e))
 	  {
             if (dump_file && (dump_flags & TDF_DETAILS))
 	      fprintf (dump_file, "Edge %i->%i is locally unlikely\n",
 		       bb->index, e->dest->index);
-	    e->count = profile_count::zero ();
+	    e->probability = profile_probability::never ();
 	  }
 
       gcc_checking_assert (!bb->aux);
@@ -3477,7 +3464,8 @@  determine_unlikely_bbs ()
       {
 	nsuccs[bb->index] = 0;
         FOR_EACH_EDGE (e, ei, bb->succs)
-	  if (!(e->count == profile_count::zero ()))
+	  if (!(e->probability == profile_probability::never ())
+	      && !(e->dest->count == profile_count::zero ()))
 	    nsuccs[bb->index]++;
 	if (!nsuccs[bb->index])
 	  worklist.safe_push (bb);
@@ -3511,9 +3499,9 @@  determine_unlikely_bbs ()
       bb->count = profile_count::zero ();
       bb->frequency = 0;
       FOR_EACH_EDGE (e, ei, bb->preds)
-	if (!(e->count == profile_count::zero ()))
+	if (!(e->probability == profile_probability::never ()))
 	  {
-	    e->count = profile_count::zero ();
+	    e->probability = profile_probability::never ();
 	    if (!(e->src->count == profile_count::zero ()))
 	      {
 	        nsuccs[e->src->index]--;
@@ -3928,8 +3916,6 @@  force_edge_cold (edge e, bool impossible
   profile_probability prob_sum = profile_probability::never ();
   edge_iterator ei;
   edge e2;
-  profile_count old_count = e->count;
-  profile_probability old_probability = e->probability;
   bool uninitialized_exit = false;
 
   profile_probability goal = (impossible ? profile_probability::never ()
@@ -3937,13 +3923,13 @@  force_edge_cold (edge e, bool impossible
 
   /* If edge is already improbably or cold, just return.  */
   if (e->probability <= goal
-      && (!impossible || e->count == profile_count::zero ()))
+      && (!impossible || e->count () == profile_count::zero ()))
     return;
   FOR_EACH_EDGE (e2, ei, e->src->succs)
     if (e2 != e)
       {
-	if (e2->count.initialized_p ())
-	  count_sum += e2->count;
+	if (e2->count ().initialized_p ())
+	  count_sum += e2->count ();
 	else
 	  uninitialized_exit = true;
 	if (e2->probability.initialized_p ())
@@ -3956,13 +3942,6 @@  force_edge_cold (edge e, bool impossible
     {
       if (!(e->probability < goal))
 	e->probability = goal;
-      if (impossible)
-	e->count = profile_count::zero ();
-      else if (old_probability > profile_probability::never ())
-	e->count = e->count.apply_probability (e->probability
-					       / old_probability);
-      else
-        e->count = e->count.apply_scale (1, REG_BR_PROB_BASE);
 
       profile_probability prob_comp = prob_sum / e->probability.invert ();
 
@@ -3971,12 +3950,9 @@  force_edge_cold (edge e, bool impossible
 		 "probability to other edges.\n",
 		 e->src->index, e->dest->index,
 		 impossible ? "impossible" : "cold");
-      profile_count count_sum2 = count_sum + old_count - e->count;
       FOR_EACH_EDGE (e2, ei, e->src->succs)
 	if (e2 != e)
 	  {
-	    if (count_sum > 0)
-	      e2->count.apply_scale (count_sum2, count_sum);
 	    e2->probability /= prob_comp;
 	  }
       if (current_ir_type () != IR_GIMPLE
@@ -4027,7 +4003,6 @@  force_edge_cold (edge e, bool impossible
 		fprintf (dump_file,
 			 "Making bb %i impossible and dropping count to 0.\n",
 			 e->src->index);
-	      e->count = profile_count::zero ();
 	      e->src->count = profile_count::zero ();
 	      FOR_EACH_EDGE (e2, ei, e->src->preds)
 		force_edge_cold (e2, impossible);
@@ -4050,10 +4025,10 @@  force_edge_cold (edge e, bool impossible
 		     impossible ? "impossible" : "cold");
 	  e->src->frequency = MIN (e->src->frequency, impossible ? 0 : 1);
 	  if (impossible)
-	    e->src->count = e->count = profile_count::zero ();
+	    e->src->count = profile_count::zero ();
 	  else
-	    e->src->count = e->count = e->count.apply_scale (e->src->frequency,
-							     old_frequency);
+	    e->src->count = e->count ().apply_scale (e->src->frequency,
+						     old_frequency);
 	  force_edge_cold (single_pred_edge (e->src), impossible);
 	}
       else if (dump_file && (dump_flags & TDF_DETAILS)
Index: profile.c
===================================================================
--- profile.c	(revision 253889)
+++ profile.c	(working copy)
@@ -831,12 +831,7 @@  compute_branch_probabilities (unsigned c
 
   FOR_ALL_BB_FN (bb, cfun)
     {
-      edge e;
-      edge_iterator ei;
-
       bb->count = profile_count::from_gcov_type (bb_gcov_count (bb));
-      FOR_EACH_EDGE (e, ei, bb->succs)
-        e->count = profile_count::from_gcov_type (edge_gcov_count (e));
     }
   bb_gcov_counts.release ();
   delete edge_gcov_counts;
Index: reg-stack.c
===================================================================
--- reg-stack.c	(revision 253889)
+++ reg-stack.c	(working copy)
@@ -2961,9 +2961,9 @@  better_edge (edge e1, edge e2)
   if (EDGE_FREQUENCY (e1) < EDGE_FREQUENCY (e2))
     return e2;
 
-  if (e1->count > e2->count)
+  if (e1->count () > e2->count ())
     return e1;
-  if (e1->count < e2->count)
+  if (e1->count () < e2->count ())
     return e2;
 
   /* Prefer critical edges to minimize inserting compensation code on
Index: shrink-wrap.c
===================================================================
--- shrink-wrap.c	(revision 253889)
+++ shrink-wrap.c	(working copy)
@@ -561,7 +561,6 @@  handle_simple_exit (edge e)
       BB_END (old_bb) = end;
 
       redirect_edge_succ (e, new_bb);
-      new_bb->count = e->count;
       new_bb->frequency = EDGE_FREQUENCY (e);
       e->flags |= EDGE_FALLTHRU;
 
Index: tracer.c
===================================================================
--- tracer.c	(revision 253889)
+++ tracer.c	(working copy)
@@ -132,9 +132,9 @@  count_insns (basic_block bb)
 static bool
 better_p (const_edge e1, const_edge e2)
 {
-  if (e1->count.initialized_p () && e2->count.initialized_p ()
-      && !(e1->count == e2->count))
-    return e1->count > e2->count;
+  if (e1->count ().initialized_p () && e2->count ().initialized_p ()
+      && ((e1->count () > e2->count ()) || (e1->count () < e2->count  ())))
+    return e1->count () > e2->count ();
   if (EDGE_FREQUENCY (e1) != EDGE_FREQUENCY (e2))
     return EDGE_FREQUENCY (e1) > EDGE_FREQUENCY (e2);
   /* This is needed to avoid changes in the decision after
Index: trans-mem.c
===================================================================
--- trans-mem.c	(revision 253889)
+++ trans-mem.c	(working copy)
@@ -2938,10 +2938,8 @@  expand_transaction (struct tm_region *re
       ei->probability = profile_probability::always ();
       et->probability = profile_probability::likely ();
       ef->probability = profile_probability::unlikely ();
-      et->count = test_bb->count.apply_probability (et->probability);
-      ef->count = test_bb->count.apply_probability (ef->probability);
 
-      code_bb->count = et->count;
+      code_bb->count = et->count ();
       code_bb->frequency = EDGE_FREQUENCY (et);
 
       transaction_bb = join_bb;
@@ -2975,15 +2973,11 @@  expand_transaction (struct tm_region *re
       redirect_edge_pred (fallthru_edge, test_bb);
       fallthru_edge->flags = EDGE_FALSE_VALUE;
       fallthru_edge->probability = profile_probability::very_likely ();
-      fallthru_edge->count = test_bb->count.apply_probability
-				(fallthru_edge->probability);
 
       // Abort/over edge.
       redirect_edge_pred (abort_edge, test_bb);
       abort_edge->flags = EDGE_TRUE_VALUE;
       abort_edge->probability = profile_probability::unlikely ();
-      abort_edge->count = test_bb->count.apply_probability
-				(abort_edge->probability);
 
       transaction_bb = test_bb;
     }
@@ -3011,7 +3005,7 @@  expand_transaction (struct tm_region *re
       // out of the fallthru edge.
       edge e = make_edge (transaction_bb, test_bb, fallthru_edge->flags);
       e->probability = fallthru_edge->probability;
-      test_bb->count = e->count = fallthru_edge->count;
+      test_bb->count = fallthru_edge->count ();
       test_bb->frequency = EDGE_FREQUENCY (e);
 
       // Now update the edges to the inst/uninist implementations.
@@ -3022,14 +3016,10 @@  expand_transaction (struct tm_region *re
       redirect_edge_pred (inst_edge, test_bb);
       inst_edge->flags = EDGE_FALSE_VALUE;
       inst_edge->probability = profile_probability::even ();
-      inst_edge->count
-	= test_bb->count.apply_probability (inst_edge->probability);
 
       redirect_edge_pred (uninst_edge, test_bb);
       uninst_edge->flags = EDGE_TRUE_VALUE;
       uninst_edge->probability = profile_probability::even ();
-      uninst_edge->count
-	= test_bb->count.apply_probability (uninst_edge->probability);
     }
 
   // If we have no previous special cases, and we have PHIs at the beginning
@@ -3214,10 +3204,7 @@  split_bb_make_tm_edge (gimple *stmt, bas
     }
   edge e = make_edge (bb, dest_bb, EDGE_ABNORMAL);
   if (e)
-    {
-      e->probability = profile_probability::guessed_never ();
-      e->count = profile_count::guessed_zero ();
-    }
+    e->probability = profile_probability::guessed_never ();
 
   // Record the need for the edge for the benefit of the rtl passes.
   if (cfun->gimple_df->tm_restart == NULL)
Index: tree-call-cdce.c
===================================================================
--- tree-call-cdce.c	(revision 253889)
+++ tree-call-cdce.c	(working copy)
@@ -913,21 +913,17 @@  shrink_wrap_one_built_in_call_with_conds
       gcc_assert (src_bb == nocall_edge->src);
 
       call_edge->probability = profile_probability::very_unlikely ();
-      call_edge->count
-	 = src_bb->count.apply_probability (call_edge->probability);
       nocall_edge->probability = profile_probability::always ()
 				 - call_edge->probability;
-      nocall_edge->count = src_bb->count - call_edge->count;
 
       unsigned int call_frequency
 	 = call_edge->probability.apply (src_bb->frequency);
 
-      bi_call_bb->count += call_edge->count;
+      bi_call_bb->count += call_edge->count ();
       bi_call_bb->frequency += call_frequency;
 
       if (nocall_edge->dest != join_tgt_bb)
 	{
-	  nocall_edge->dest->count = nocall_edge->count;
 	  nocall_edge->dest->frequency = src_bb->frequency - call_frequency;
 	}
     }
Index: tree-cfg.c
===================================================================
--- tree-cfg.c	(revision 253889)
+++ tree-cfg.c	(working copy)
@@ -1062,8 +1062,8 @@  gimple_find_sub_bbs (gimple_seq seq, gim
       edge_iterator ei;
       FOR_EACH_EDGE (e, ei, bb->preds)
 	{
-	  if (e->count.initialized_p ())
-	    cnt += e->count;
+	  if (e->count ().initialized_p ())
+	    cnt += e->count ();
 	  else
 	    all = false;
 	  freq += EDGE_FREQUENCY (e);
@@ -1072,8 +1072,6 @@  gimple_find_sub_bbs (gimple_seq seq, gim
       if (all || profile_status_for_fn (cfun) == PROFILE_READ)
         bb->count = cnt;
       bb->frequency = freq;
-      FOR_EACH_EDGE (e, ei, bb->succs)
-	e->count = bb->count.apply_probability (e->probability);
 
       bb = bb->next_bb;
     }
@@ -2843,7 +2841,7 @@  gimple_split_edge (edge edge_in)
 
   new_bb = create_empty_bb (after_bb);
   new_bb->frequency = EDGE_FREQUENCY (edge_in);
-  new_bb->count = edge_in->count;
+  new_bb->count = edge_in->count ();
 
   e = redirect_edge_and_branch (edge_in, new_bb);
   gcc_assert (e == edge_in);
@@ -6372,7 +6370,7 @@  gimple_duplicate_sese_region (edge entry
   if (entry->dest->count.initialized_p ())
     {
       total_count = entry->dest->count;
-      entry_count = entry->count;
+      entry_count = entry->count ();
       /* Fix up corner cases, to avoid division by zero or creation of negative
 	 frequencies.  */
       if (entry_count > total_count)
@@ -6542,7 +6540,7 @@  gimple_duplicate_sese_tail (edge entry,
   if (exit->src->count > 0)
     {
       total_count = exit->src->count;
-      exit_count = exit->count;
+      exit_count = exit->count ();
       /* Fix up corner cases, to avoid division by zero or creation of negative
 	 frequencies.  */
       if (exit_count > total_count)
@@ -6597,10 +6595,8 @@  gimple_duplicate_sese_tail (edge entry,
   sorig = single_succ_edge (switch_bb);
   sorig->flags = exits[1]->flags;
   sorig->probability = exits[1]->probability;
-  sorig->count = exits[1]->count;
   snew = make_edge (switch_bb, nentry_bb, exits[0]->flags);
   snew->probability = exits[0]->probability;
-  snew->count = exits[1]->count;
   
 
   /* Register the new edge from SWITCH_BB in loop exit lists.  */
@@ -8335,7 +8331,6 @@  gimple_flow_call_edges_add (sbitmap bloc
 		    }
 		  e = make_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun), EDGE_FAKE);
 		  e->probability = profile_probability::guessed_never ();
-		  e->count = profile_count::guessed_zero ();
 		}
 	      gsi_prev (&gsi);
 	    }
@@ -8847,14 +8842,12 @@  insert_cond_bb (basic_block bb, gimple *
   new_bb = create_empty_bb (bb);
   edge e = make_edge (bb, new_bb, EDGE_TRUE_VALUE);
   e->probability = prob;
-  e->count = bb->count.apply_probability (prob);
-  new_bb->count = e->count;
+  new_bb->count = e->count ();
   new_bb->frequency = prob.apply (bb->frequency);
   make_single_succ_edge (new_bb, fall->dest, EDGE_FALLTHRU);
 
   /* Fix edge for split bb.  */
   fall->flags = EDGE_FALSE_VALUE;
-  fall->count -= e->count;
   fall->probability -= e->probability;
 
   /* Update dominance info.  */
@@ -9252,8 +9245,6 @@  execute_fixup_cfg (void)
   basic_block bb;
   gimple_stmt_iterator gsi;
   int todo = 0;
-  edge e;
-  edge_iterator ei;
   cgraph_node *node = cgraph_node::get (current_function_decl);
   profile_count num = node->count;
   profile_count den = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count;
@@ -9266,9 +9257,6 @@  execute_fixup_cfg (void)
       ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = node->count;
       EXIT_BLOCK_PTR_FOR_FN (cfun)->count
         = EXIT_BLOCK_PTR_FOR_FN (cfun)->count.apply_scale (num, den);
-
-      FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR_FOR_FN (cfun)->succs)
-	e->count = e->count.apply_scale (num, den);
     }
 
   FOR_EACH_BB_FN (bb, cfun)
@@ -9343,10 +9331,6 @@  execute_fixup_cfg (void)
 	  gsi_next (&gsi);
 	}
 
-      if (scale)
-	FOR_EACH_EDGE (e, ei, bb->succs)
-	  e->count = e->count.apply_scale (num, den);
-
       /* If we have a basic block with no successors that does not
 	 end with a control statement or a noreturn call end it with
 	 a call to __builtin_unreachable.  This situation can occur
Index: tree-cfgcleanup.c
===================================================================
--- tree-cfgcleanup.c	(revision 253889)
+++ tree-cfgcleanup.c	(working copy)
@@ -195,7 +195,6 @@  cleanup_control_expr_graph (basic_block
 		}
 
 	      taken_edge->probability += e->probability;
-	      taken_edge->count += e->count;
 	      remove_edge_and_dominated_blocks (e);
 	      retval = true;
 	    }
Index: tree-complex.c
===================================================================
--- tree-complex.c	(revision 253889)
+++ tree-complex.c	(working copy)
@@ -1192,13 +1192,11 @@  expand_complex_div_wide (gimple_stmt_ite
 
       /* Wire the blocks together.  */
       e->flags = EDGE_TRUE_VALUE;
-      e->count = bb_true->count;
       /* TODO: With value profile we could add an historgram to determine real
 	 branch outcome.  */
       e->probability = profile_probability::even ();
       redirect_edge_succ (e, bb_true);
       edge e2 = make_edge (bb_cond, bb_false, EDGE_FALSE_VALUE);
-      e2->count = bb_false->count;
       e2->probability = profile_probability::even ();
       make_single_succ_edge (bb_true, bb_join, EDGE_FALLTHRU);
       make_single_succ_edge (bb_false, bb_join, EDGE_FALLTHRU);
Index: tree-eh.c
===================================================================
--- tree-eh.c	(revision 253889)
+++ tree-eh.c	(working copy)
@@ -3259,7 +3259,6 @@  lower_resx (basic_block bb, gresx *stmt,
 	  gcc_assert (e->flags & EDGE_EH);
 	  e->flags = (e->flags & ~EDGE_EH) | EDGE_FALLTHRU;
 	  e->probability = profile_probability::always ();
-	  e->count = bb->count;
 
 	  /* If there are no more EH users of the landing pad, delete it.  */
 	  FOR_EACH_EDGE (e, ei, e->dest->preds)
@@ -4099,7 +4098,6 @@  unsplit_eh (eh_landing_pad lp)
   redirect_edge_pred (e_out, e_in->src);
   e_out->flags = e_in->flags;
   e_out->probability = e_in->probability;
-  e_out->count = e_in->count;
   remove_edge (e_in);
 
   return true;
@@ -4292,7 +4290,6 @@  cleanup_empty_eh_move_lp (basic_block bb
   /* Clean up E_OUT for the fallthru.  */
   e_out->flags = (e_out->flags & ~EDGE_EH) | EDGE_FALLTHRU;
   e_out->probability = profile_probability::always ();
-  e_out->count = e_out->src->count;
 }
 
 /* A subroutine of cleanup_empty_eh.  Handle more complex cases of
Index: tree-inline.c
===================================================================
--- tree-inline.c	(revision 253889)
+++ tree-inline.c	(working copy)
@@ -2215,7 +2215,7 @@  update_ssa_across_abnormal_edges (basic_
    debug stmts are left after a statement that must end the basic block.  */
 
 static bool
-copy_edges_for_bb (basic_block bb, profile_count num, profile_count den,
+copy_edges_for_bb (basic_block bb,
 		   basic_block ret_bb, basic_block abnormal_goto_dest)
 {
   basic_block new_bb = (basic_block) bb->aux;
@@ -2224,8 +2224,6 @@  copy_edges_for_bb (basic_block bb, profi
   gimple_stmt_iterator si;
   int flags;
   bool need_debug_cleanup = false;
-  bool scale = num.initialized_p ()
-	       && (den > 0 || num == profile_count::zero ());
 
   /* Use the indices from the original blocks to create edges for the
      new ones.  */
@@ -2242,8 +2240,6 @@  copy_edges_for_bb (basic_block bb, profi
 	    && old_edge->dest->aux != EXIT_BLOCK_PTR_FOR_FN (cfun))
 	  flags |= EDGE_FALLTHRU;
 	new_edge = make_edge (new_bb, (basic_block) old_edge->dest->aux, flags);
-	if (scale)
-	  new_edge->count = old_edge->count.apply_scale (num, den);
 	new_edge->probability = old_edge->probability;
       }
 
@@ -2324,17 +2320,11 @@  copy_edges_for_bb (basic_block bb, profi
 		&& (e = find_edge (copy_stmt_bb,
 				   (basic_block) old_edge->dest->aux))
 		&& (e->flags & EDGE_EH))
-	      {
-		e->probability = old_edge->probability;
-		e->count = old_edge->count;
-	      }
+	      e->probability = old_edge->probability;
 	    
           FOR_EACH_EDGE (e, ei, copy_stmt_bb->succs)
 	    if ((e->flags & EDGE_EH) && !e->probability.initialized_p ())
-	      {
-	        e->probability = profile_probability::never ();
-	        e->count = profile_count::zero ();
-	      }
+	      e->probability = profile_probability::never ();
         }
 
 
@@ -2700,16 +2690,10 @@  void
 freqs_to_counts (struct cgraph_node *node, profile_count count)
 {
   basic_block bb;
-  edge_iterator ei;
-  edge e;
   struct function *fn = DECL_STRUCT_FUNCTION (node->decl);
 
   FOR_ALL_BB_FN(bb, fn)
-    {
-      bb->count = count.apply_scale (bb->frequency, BB_FREQ_MAX);
-      FOR_EACH_EDGE (e, ei, bb->succs)
-        e->count = e->src->count.apply_probability (e->probability);
-    }
+    bb->count = count.apply_scale (bb->frequency, BB_FREQ_MAX);
 }
 
 /* Make a copy of the body of FN so that it can be inserted inline in
@@ -2769,10 +2753,7 @@  copy_cfg_body (copy_body_data * id, prof
 
       FOR_EACH_EDGE (e, ei, new_entry->preds)
 	if (!e->src->aux)
-	  {
-	    incoming_frequency += EDGE_FREQUENCY (e);
-	    incoming_count += e->count;
-	  }
+	  incoming_frequency += EDGE_FREQUENCY (e);
       if (scale)
         incoming_count = incoming_count.apply_scale (num, den);
       else
@@ -2826,14 +2807,13 @@  copy_cfg_body (copy_body_data * id, prof
   FOR_ALL_BB_FN (bb, cfun_to_copy)
     if (!id->blocks_to_copy
 	|| (bb->index > 0 && bitmap_bit_p (id->blocks_to_copy, bb->index)))
-      need_debug_cleanup |= copy_edges_for_bb (bb, num, den, exit_block_map,
+      need_debug_cleanup |= copy_edges_for_bb (bb, exit_block_map,
 					       abnormal_goto_dest);
 
   if (new_entry)
     {
       edge e = make_edge (entry_block_map, (basic_block)new_entry->aux, EDGE_FALLTHRU);
       e->probability = profile_probability::always ();
-      e->count = incoming_count;
     }
 
   /* Duplicate the loop tree, if available and wanted.  */
Index: tree-ssa-dce.c
===================================================================
--- tree-ssa-dce.c	(revision 253889)
+++ tree-ssa-dce.c	(working copy)
@@ -1055,7 +1055,6 @@  remove_dead_stmt (gimple_stmt_iterator *
 	}
       gcc_assert (e);
       e->probability = profile_probability::always ();
-      e->count = bb->count;
 
       /* The edge is no longer associated with a conditional, so it does
 	 not have TRUE/FALSE flags.
Index: tree-ssa-ifcombine.c
===================================================================
--- tree-ssa-ifcombine.c	(revision 253889)
+++ tree-ssa-ifcombine.c	(working copy)
@@ -358,10 +358,7 @@  update_profile_after_ifcombine (basic_bl
      outer_cond_bb->(outer_to_inner)->inner_cond_bb->(inner_taken)
      and probability of inner_not_taken updated.  */
 
-  outer_to_inner->count = outer_cond_bb->count;
   inner_cond_bb->count = outer_cond_bb->count;
-  inner_taken->count += outer2->count;
-  outer2->count = profile_count::zero ();
 
   inner_taken->probability = outer2->probability + outer_to_inner->probability
 			     * inner_taken->probability;
Index: tree-ssa-loop-im.c
===================================================================
--- tree-ssa-loop-im.c	(revision 253889)
+++ tree-ssa-loop-im.c	(working copy)
@@ -1815,9 +1815,9 @@  execute_sm_if_changed (edge ex, tree mem
 
   if (flag_probability.initialized_p ())
     ;
-  else if (ncount == nbbs && count_sum > 0 && preheader->count >= count_sum)
+  else if (ncount == nbbs && count_sum > 0 && preheader->count () >= count_sum)
     {
-      flag_probability = count_sum.probability_in (preheader->count);
+      flag_probability = count_sum.probability_in (preheader->count ());
       if (flag_probability > cap)
 	flag_probability = cap;
     }
@@ -1881,13 +1881,11 @@  execute_sm_if_changed (edge ex, tree mem
   edge e2 = make_edge (new_bb, then_bb,
 	               EDGE_TRUE_VALUE | (irr ? EDGE_IRREDUCIBLE_LOOP : 0));
   e2->probability = flag_probability;
-  e2->count = then_bb->count;
 
   e1->flags |= EDGE_FALSE_VALUE | (irr ? EDGE_IRREDUCIBLE_LOOP : 0);
   e1->flags &= ~EDGE_FALLTHRU;
 
   e1->probability = flag_probability.invert ();
-  e1->count = new_bb->count - then_bb->count;
 
   then_old_edge = make_single_succ_edge (then_bb, old_dest,
 			     EDGE_FALLTHRU | (irr ? EDGE_IRREDUCIBLE_LOOP : 0));
Index: tree-ssa-loop-ivcanon.c
===================================================================
--- tree-ssa-loop-ivcanon.c	(revision 253889)
+++ tree-ssa-loop-ivcanon.c	(working copy)
@@ -530,7 +530,6 @@  remove_exits_and_undefined_stmts (struct
 	  if (!loop_exit_edge_p (loop, exit_edge))
 	    exit_edge = EDGE_SUCC (bb, 1);
 	  exit_edge->probability = profile_probability::always ();
-	  exit_edge->count = exit_edge->src->count;
 	  gcc_checking_assert (loop_exit_edge_p (loop, exit_edge));
 	  gcond *cond_stmt = as_a <gcond *> (elt->stmt);
 	  if (exit_edge->flags & EDGE_TRUE_VALUE)
@@ -643,7 +642,6 @@  unloop_loops (bitmap loop_closed_ssa_inv
       stmt = gimple_build_call (builtin_decl_implicit (BUILT_IN_UNREACHABLE), 0);
       latch_edge = make_edge (latch, create_basic_block (NULL, NULL, latch), flags);
       latch_edge->probability = profile_probability::never ();
-      latch_edge->count = profile_count::zero ();
       latch_edge->flags |= flags;
       latch_edge->goto_locus = locus;
 
Index: tree-ssa-loop-manip.c
===================================================================
--- tree-ssa-loop-manip.c	(revision 253889)
+++ tree-ssa-loop-manip.c	(working copy)
@@ -1294,12 +1294,10 @@  tree_transform_and_unroll_loop (struct l
   /* Set the probability of new exit to the same of the old one.  Fix
      the frequency of the latch block, by scaling it back by
      1 - exit->probability.  */
-  new_exit->count = exit->count;
   new_exit->probability = exit->probability;
   new_nonexit = single_pred_edge (loop->latch);
   new_nonexit->probability = exit->probability.invert ();
   new_nonexit->flags = EDGE_TRUE_VALUE;
-  new_nonexit->count -= exit->count;
   if (new_nonexit->probability.initialized_p ())
     scale_bbs_frequencies (&loop->latch, 1, new_nonexit->probability);
 
@@ -1371,7 +1369,7 @@  tree_transform_and_unroll_loop (struct l
      exit edge.  */
 
   freq_h = loop->header->count;
-  freq_e = (loop_preheader_edge (loop))->count;
+  freq_e = (loop_preheader_edge (loop))->count ();
   /* Use frequency only if counts are zero.  */
   if (!(freq_h > 0) && !(freq_e > 0))
     {
@@ -1390,17 +1388,15 @@  tree_transform_and_unroll_loop (struct l
 
   exit_bb = single_pred (loop->latch);
   new_exit = find_edge (exit_bb, rest);
-  new_exit->count = loop_preheader_edge (loop)->count;
   new_exit->probability = profile_probability::always ()
 				.apply_scale (1, new_est_niter + 1);
 
-  rest->count += new_exit->count;
+  rest->count += new_exit->count ();
   rest->frequency += EDGE_FREQUENCY (new_exit);
 
   new_nonexit = single_pred_edge (loop->latch);
   prob = new_nonexit->probability;
   new_nonexit->probability = new_exit->probability.invert ();
-  new_nonexit->count = exit_bb->count - new_exit->count;
   prob = new_nonexit->probability / prob;
   if (prob.initialized_p ())
     scale_bbs_frequencies (&loop->latch, 1, prob);
Index: tree-ssa-loop-split.c
===================================================================
--- tree-ssa-loop-split.c	(revision 253889)
+++ tree-ssa-loop-split.c	(working copy)
@@ -353,11 +353,8 @@  connect_loops (struct loop *loop1, struc
       new_e->flags |= EDGE_TRUE_VALUE;
     }
 
-  new_e->count = skip_bb->count;
   new_e->probability = profile_probability::likely ();
-  new_e->count = skip_e->count.apply_probability (PROB_LIKELY);
-  skip_e->count -= new_e->count;
-  skip_e->probability = profile_probability::unlikely ();
+  skip_e->probability = new_e->probability.invert ();
 
   return new_e;
 }
@@ -560,7 +557,6 @@  split_loop (struct loop *loop1, struct t
 	initialize_original_copy_tables ();
 	basic_block cond_bb;
 
-	/* FIXME: probabilities seems wrong here.  */
 	struct loop *loop2 = loop_version (loop1, cond, &cond_bb,
 					   profile_probability::always (),
 					   profile_probability::always (),
Index: tree-ssa-loop-unswitch.c
===================================================================
--- tree-ssa-loop-unswitch.c	(revision 253889)
+++ tree-ssa-loop-unswitch.c	(working copy)
@@ -853,16 +853,15 @@  hoist_guard (struct loop *loop, edge gua
      same average number of iterations regardless outcome of guard.  */
   new_edge->probability = guard->probability;
   profile_count skip_count = guard->src->count > 0
-		   ? guard->count.apply_scale (pre_header->count,
+		   ? guard->count ().apply_scale (pre_header->count,
 					       guard->src->count)
-		   : guard->count.apply_probability (new_edge->probability);
+		   : guard->count ().apply_probability (new_edge->probability);
 
-  if (skip_count > e->count)
+  if (skip_count > e->count ())
     {
       fprintf (dump_file, "  Capping count; expect profile inconsistency\n");
-      skip_count = e->count;
+      skip_count = e->count ();
     }
-  new_edge->count = skip_count;
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
       fprintf (dump_file, "  Estimated probability of skipping loop is ");
@@ -874,19 +873,14 @@  hoist_guard (struct loop *loop, edge gua
 
      First decrease count of path from newly hoisted loop guard
      to loop header...  */
-  e->count -= skip_count;
   e->probability = new_edge->probability.invert ();
-  e->dest->count = e->count;
+  e->dest->count = e->count ();
   e->dest->frequency = EDGE_FREQUENCY (e);
 
   /* ... now update profile to represent that original guard will be optimized
      away ...  */
   guard->probability = profile_probability::never ();
-  guard->count = profile_count::zero ();
   not_guard->probability = profile_probability::always ();
-  /* This count is wrong (frequency of not_guard does not change),
-     but will be scaled later.  */
-  not_guard->count = guard->src->count;
 
   /* ... finally scale everything in the loop except for guarded basic blocks
      where profile does not change.  */
Index: tree-ssa-phionlycprop.c
===================================================================
--- tree-ssa-phionlycprop.c	(revision 253889)
+++ tree-ssa-phionlycprop.c	(working copy)
@@ -298,7 +298,6 @@  propagate_rhs_into_lhs (gimple *stmt, tr
 
 			  te->probability += e->probability;
 
-			  te->count += e->count;
 			  remove_edge (e);
 			  cfg_altered = true;
 			}
Index: tree-ssa-phiopt.c
===================================================================
--- tree-ssa-phiopt.c	(revision 253889)
+++ tree-ssa-phiopt.c	(working copy)
@@ -375,7 +375,6 @@  replace_phi_edge_with_variable (basic_bl
       EDGE_SUCC (cond_block, 0)->flags |= EDGE_FALLTHRU;
       EDGE_SUCC (cond_block, 0)->flags &= ~(EDGE_TRUE_VALUE | EDGE_FALSE_VALUE);
       EDGE_SUCC (cond_block, 0)->probability = profile_probability::always ();
-      EDGE_SUCC (cond_block, 0)->count += EDGE_SUCC (cond_block, 1)->count;
 
       block_to_remove = EDGE_SUCC (cond_block, 1)->dest;
     }
@@ -385,7 +384,6 @@  replace_phi_edge_with_variable (basic_bl
       EDGE_SUCC (cond_block, 1)->flags
 	&= ~(EDGE_TRUE_VALUE | EDGE_FALSE_VALUE);
       EDGE_SUCC (cond_block, 1)->probability = profile_probability::always ();
-      EDGE_SUCC (cond_block, 1)->count += EDGE_SUCC (cond_block, 0)->count;
 
       block_to_remove = EDGE_SUCC (cond_block, 0)->dest;
     }
Index: tree-ssa-reassoc.c
===================================================================
--- tree-ssa-reassoc.c	(revision 253889)
+++ tree-ssa-reassoc.c	(working copy)
@@ -6033,12 +6033,10 @@  branch_fixup (void)
 
       edge etrue = make_edge (cond_bb, merge_bb, EDGE_TRUE_VALUE);
       etrue->probability = profile_probability::even ();
-      etrue->count = cond_bb->count.apply_scale (1, 2);
       edge efalse = find_edge (cond_bb, then_bb);
       efalse->flags = EDGE_FALSE_VALUE;
       efalse->probability -= etrue->probability;
-      efalse->count -= etrue->count;
-      then_bb->count -= etrue->count;
+      then_bb->count -= etrue->count ();
 
       tree othervar = NULL_TREE;
       if (gimple_assign_rhs1 (use_stmt) == var)
Index: tree-ssa-tail-merge.c
===================================================================
--- tree-ssa-tail-merge.c	(revision 253889)
+++ tree-ssa-tail-merge.c	(working copy)
@@ -1570,14 +1570,14 @@  replace_block_by (basic_block bb1, basic
      making the bb count inconsistent with the edge weights.  */
   FOR_EACH_EDGE (e1, ei, bb1->succs)
     {
-      if (e1->count.initialized_p ())
-	out_sum += e1->count;
+      if (e1->count ().initialized_p ())
+	out_sum += e1->count ();
       out_freq_sum += EDGE_FREQUENCY (e1);
     }
   FOR_EACH_EDGE (e1, ei, bb2->succs)
     {
-      if (e1->count.initialized_p ())
-	out_sum += e1->count;
+      if (e1->count ().initialized_p ())
+	out_sum += e1->count ();
       out_freq_sum += EDGE_FREQUENCY (e1);
     }
 
@@ -1585,10 +1585,9 @@  replace_block_by (basic_block bb1, basic
     {
       e2 = find_edge (bb2, e1->dest);
       gcc_assert (e2);
-      e2->count += e1->count;
-      if (out_sum > 0 && e2->count.initialized_p ())
+      if (out_sum > 0 && e2->count ().initialized_p ())
 	{
-	  e2->probability = e2->count.probability_in (bb2->count);
+	  e2->probability = e2->count ().probability_in (bb2->count);
 	}
       else if (bb1->frequency && bb2->frequency)
 	e2->probability = e1->probability;
@@ -1599,7 +1598,7 @@  replace_block_by (basic_block bb1, basic
 		(GCOV_COMPUTE_SCALE (EDGE_FREQUENCY (e1)
 				     + EDGE_FREQUENCY (e2),
 				     out_freq_sum));
-      out_sum += e2->count;
+      out_sum += e2->count ();
     }
   bb2->frequency += bb1->frequency;
   if (bb2->frequency > BB_FREQ_MAX)
Index: tree-ssa-threadupdate.c
===================================================================
--- tree-ssa-threadupdate.c	(revision 253889)
+++ tree-ssa-threadupdate.c	(working copy)
@@ -303,7 +303,6 @@  remove_ctrl_stmt_and_useless_edges (basi
       else
 	{
 	  e->probability = profile_probability::always ();
-	  e->count = bb->count;
 	  ei_next (&ei);
 	}
     }
@@ -741,7 +740,7 @@  compute_path_counts (struct redirection_
 	     same last path edge in the case where the last edge has a nocopy
 	     source block.  */
 	  gcc_assert (ein_path->last ()->e == elast);
-	  path_in_count += ein->count;
+	  path_in_count += ein->count ();
 	  path_in_freq += EDGE_FREQUENCY (ein);
 	}
       else if (!ein_path)
@@ -749,7 +748,7 @@  compute_path_counts (struct redirection_
 	  /* Keep track of the incoming edges that are not on any jump-threading
 	     path.  These counts will still flow out of original path after all
 	     jump threading is complete.  */
-	    nonpath_count += ein->count;
+	    nonpath_count += ein->count ();
 	}
     }
 
@@ -789,7 +788,7 @@  compute_path_counts (struct redirection_
   for (unsigned int i = 1; i < path->length (); i++)
     {
       edge epath = (*path)[i]->e;
-      profile_count cur_count = epath->count;
+      profile_count cur_count = epath->count ();
       if ((*path)[i]->type == EDGE_COPY_SRC_JOINER_BLOCK)
 	{
 	  has_joiner = true;
@@ -809,13 +808,13 @@  compute_path_counts (struct redirection_
 		     they are redirected by an invocation of this routine.  */
 		  && !bitmap_bit_p (local_info->duplicate_blocks,
 				    ein->src->index))
-		nonpath_count += ein->count;
+		nonpath_count += ein->count ();
 	    }
 	}
       if (cur_count < path_out_count)
 	path_out_count = cur_count;
-      if (epath->count < min_path_count)
-	min_path_count = epath->count;
+      if (epath->count () < min_path_count)
+	min_path_count = epath->count ();
     }
 
   /* We computed path_out_count above assuming that this path targeted
@@ -830,12 +829,12 @@  compute_path_counts (struct redirection_
      (since any path through the joiner with a different elast will not
      include a copy of this elast in its duplicated path).
      So ensure that this path's path_out_count is at least the
-     difference between elast->count and nonpath_count.  Otherwise the edge
+     difference between elast->count () and nonpath_count.  Otherwise the edge
      counts after threading will not be sane.  */
   if (local_info->need_profile_correction
-      && has_joiner && path_out_count < elast->count - nonpath_count)
+      && has_joiner && path_out_count < elast->count () - nonpath_count)
     {
-      path_out_count = elast->count - nonpath_count;
+      path_out_count = elast->count () - nonpath_count;
       /* But neither can we go above the minimum count along the path
 	 we are duplicating.  This can be an issue due to profile
 	 insanities coming in to this pass.  */
@@ -863,128 +862,69 @@  update_profile (edge epath, edge edup, p
   if (edup)
     {
       basic_block dup_block = edup->src;
+      /* Edup's count is reduced by path_out_count.  We need to redistribute
+         probabilities to the remaining edges.  */
+      if (path_out_count > 0 && dup_block->count.initialized_p ())
+	{
+	  edge esucc;
+	  edge_iterator ei;
+	  profile_probability edup_prob
+	     = path_out_count.probability_in (epath->src->count);
+
+	  /* Either scale up or down the remaining edges.
+	     probabilities are always in range <0,1> and thus we can't do
+	     both by same loop.  */
+	  if (edup->probability > edup_prob)
+	    {
+	       profile_probability rev_scale
+		 = (profile_probability::always () - edup->probability)
+		   / (profile_probability::always () - edup_prob);
+               FOR_EACH_EDGE (esucc, ei, dup_block->succs)
+	         if (esucc != edup)
+	           esucc->probability /= rev_scale;
+	    }
+	  else if (edup->probability < edup_prob)
+	    {
+	       profile_probability scale
+		 = (profile_probability::always () - edup_prob)
+		   / (profile_probability::always () - edup->probability);
+              FOR_EACH_EDGE (esucc, ei, dup_block->succs)
+	        if (esucc != edup)
+	          esucc->probability *= scale;
+	    }
+	  edup->probability = edup_prob;
+	}
       gcc_assert (!dup_block->count.initialized_p ());
       gcc_assert (dup_block->frequency == 0);
       dup_block->count = path_in_count;
       dup_block->frequency = path_in_freq;
     }
 
-  /* Now update the original block's count and frequency in the
-     opposite manner - remove the counts/freq that will flow
-     into the duplicated block.  Handle underflow due to precision/
-     rounding issues.  */
-  epath->src->count -= path_in_count;
-  epath->src->frequency -= path_in_freq;
-  if (epath->src->frequency < 0)
-    epath->src->frequency = 0;
-
   /* Next update this path edge's original and duplicated counts.  We know
      that the duplicated path will have path_out_count flowing
      out of it (in the joiner case this is the count along the duplicated path
      out of the duplicated joiner).  This count can then be removed from the
      original path edge.  */
-  if (edup)
-    edup->count = path_out_count;
-  epath->count -= path_out_count;
-  /* FIXME: can epath->count be legally uninitialized here?  */
-}
-
-
-/* The duplicate and original joiner blocks may end up with different
-   probabilities (different from both the original and from each other).
-   Recompute the probabilities here once we have updated the edge
-   counts and frequencies.  */
-
-static void
-recompute_probabilities (basic_block bb)
-{
-  edge esucc;
-  edge_iterator ei;
-  FOR_EACH_EDGE (esucc, ei, bb->succs)
+  if (path_out_count > 0 && epath->src->count.initialized_p ())
     {
-      if (!(bb->count > 0))
-	continue;
-
-      /* Prevent overflow computation due to insane profiles.  */
-      if (esucc->count < bb->count)
-	esucc->probability = esucc->count.probability_in (bb->count).guessed ();
-      else
-	/* Can happen with missing/guessed probabilities, since we
-	   may determine that more is flowing along duplicated
-	   path than joiner succ probabilities allowed.
-	   Counts and freqs will be insane after jump threading,
-	   at least make sure probability is sane or we will
-	   get a flow verification error.
-	   Not much we can do to make counts/freqs sane without
-	   redoing the profile estimation.  */
-	esucc->probability = profile_probability::guessed_always ();
-    }
-}
-
-
-/* Update the counts of the original and duplicated edges from a joiner
-   that go off path, given that we have already determined that the
-   duplicate joiner DUP_BB has incoming count PATH_IN_COUNT and
-   outgoing count along the path PATH_OUT_COUNT.  The original (on-)path
-   edge from joiner is EPATH.  */
-
-static void
-update_joiner_offpath_counts (edge epath, basic_block dup_bb,
-			      profile_count path_in_count,
-			      profile_count path_out_count)
-{
-  /* Compute the count that currently flows off path from the joiner.
-     In other words, the total count of joiner's out edges other than
-     epath.  Compute this by walking the successors instead of
-     subtracting epath's count from the joiner bb count, since there
-     are sometimes slight insanities where the total out edge count is
-     larger than the bb count (possibly due to rounding/truncation
-     errors).  */
-  profile_count total_orig_off_path_count = profile_count::zero ();
-  edge enonpath;
-  edge_iterator ei;
-  FOR_EACH_EDGE (enonpath, ei, epath->src->succs)
-    {
-      if (enonpath == epath)
-	continue;
-      total_orig_off_path_count += enonpath->count;
+      edge esucc;
+      edge_iterator ei;
+      profile_probability epath_prob
+	 = path_out_count.probability_in (epath->src->count);
+      epath->probability -= epath_prob;
+      FOR_EACH_EDGE (esucc, ei, epath->src->succs)
+	if (esucc != epath)
+	  esucc->probability /= epath_prob;
     }
 
-  /* For the path that we are duplicating, the amount that will flow
-     off path from the duplicated joiner is the delta between the
-     path's cumulative in count and the portion of that count we
-     estimated above as flowing from the joiner along the duplicated
-     path.  */
-  profile_count total_dup_off_path_count = path_in_count - path_out_count;
-
-  /* Now do the actual updates of the off-path edges.  */
-  FOR_EACH_EDGE (enonpath, ei, epath->src->succs)
-    {
-      /* Look for edges going off of the threading path.  */
-      if (enonpath == epath)
-	continue;
-
-      /* Find the corresponding edge out of the duplicated joiner.  */
-      edge enonpathdup = find_edge (dup_bb, enonpath->dest);
-      gcc_assert (enonpathdup);
-
-      /* We can't use the original probability of the joiner's out
-	 edges, since the probabilities of the original branch
-	 and the duplicated branches may vary after all threading is
-	 complete.  But apportion the duplicated joiner's off-path
-	 total edge count computed earlier (total_dup_off_path_count)
-	 among the duplicated off-path edges based on their original
-	 ratio to the full off-path count (total_orig_off_path_count).
-	 */
-      profile_probability scale
-		 = enonpath->count.probability_in (total_orig_off_path_count);
-      /* Give the duplicated offpath edge a portion of the duplicated
-	 total.  */
-      enonpathdup->count = total_dup_off_path_count.apply_probability (scale);
-      /* Now update the original offpath edge count, handling underflow
-	 due to rounding errors.  */
-      enonpath->count -= enonpathdup->count;
-    }
+  /* Now update the original block's count and frequency in the
+     opposite manner - remove the counts/freq that will flow
+     into the duplicated block.  Handle underflow due to precision/
+     rounding issues.  */
+  epath->src->count -= path_in_count;
+  epath->src->frequency -= path_in_freq;
+  if (epath->src->frequency < 0)
+    epath->src->frequency = 0;
 }
 
 
@@ -1002,7 +942,7 @@  estimated_freqs_path (struct redirection
   bool non_zero_freq = false;
   FOR_EACH_EDGE (ein, ei, e->dest->preds)
     {
-      if (ein->count > 0)
+      if (ein->count () > 0)
 	return false;
       non_zero_freq |= ein->src->frequency != 0;
     }
@@ -1016,7 +956,7 @@  estimated_freqs_path (struct redirection
       edge esucc;
       FOR_EACH_EDGE (esucc, ei, epath->src->succs)
 	{
-	  if (esucc->count > 0)
+	  if (esucc->count () > 0)
 	    return false;
 	  non_zero_freq |= esucc->src->frequency != 0;
 	}
@@ -1040,36 +980,16 @@  freqs_to_counts_path (struct redirection
 {
   edge e = rd->incoming_edges->e;
   vec<jump_thread_edge *> *path = THREAD_PATH (e);
-  edge ein;
-  edge_iterator ei;
-  FOR_EACH_EDGE (ein, ei, e->dest->preds)
-    {
-      /* Scale up the frequency by REG_BR_PROB_BASE, to avoid rounding
-	 errors applying the probability when the frequencies are very
-	 small.  */
-      if (ein->probability.initialized_p ())
-        ein->count = profile_count::from_gcov_type
-		  (apply_probability (ein->src->frequency * REG_BR_PROB_BASE,
-				        ein->probability
-					  .to_reg_br_prob_base ())).guessed ();
-      else
-	/* FIXME: this is hack; we should track uninitialized values.  */
-	ein->count = profile_count::zero ();
-    }
 
   for (unsigned int i = 1; i < path->length (); i++)
     {
       edge epath = (*path)[i]->e;
-      edge esucc;
       /* Scale up the frequency by REG_BR_PROB_BASE, to avoid rounding
 	 errors applying the edge probability when the frequencies are very
 	 small.  */
       epath->src->count = 
 	profile_count::from_gcov_type
 	  (epath->src->frequency * REG_BR_PROB_BASE);
-      FOR_EACH_EDGE (esucc, ei, epath->src->succs)
-	esucc->count = 
-	   esucc->src->count.apply_probability (esucc->probability);
     }
 }
 
@@ -1086,21 +1006,14 @@  clear_counts_path (struct redirection_da
 {
   edge e = rd->incoming_edges->e;
   vec<jump_thread_edge *> *path = THREAD_PATH (e);
-  edge ein, esucc;
-  edge_iterator ei;
   profile_count val = profile_count::uninitialized ();
   if (profile_status_for_fn (cfun) == PROFILE_READ)
     val = profile_count::zero ();
 
-  FOR_EACH_EDGE (ein, ei, e->dest->preds)
-    ein->count = val;
-
   /* First clear counts along original path.  */
   for (unsigned int i = 1; i < path->length (); i++)
     {
       edge epath = (*path)[i]->e;
-      FOR_EACH_EDGE (esucc, ei, epath->src->succs)
-	esucc->count = val;
       epath->src->count = val;
     }
   /* Also need to clear the counts along duplicated path.  */
@@ -1109,8 +1022,6 @@  clear_counts_path (struct redirection_da
       basic_block dup = rd->dup_blocks[i];
       if (!dup)
 	continue;
-      FOR_EACH_EDGE (esucc, ei, dup->succs)
-	esucc->count = val;
       dup->count = val;
     }
 }
@@ -1230,17 +1141,6 @@  ssa_fix_duplicate_block_edges (struct re
 	  update_profile (epath, e2, path_in_count, path_out_count,
 			  path_in_freq);
 
-	  /* Next we need to update the counts of the original and duplicated
-	     edges from the joiner that go off path.  */
-	  update_joiner_offpath_counts (epath, e2->src, path_in_count,
-					path_out_count);
-
-	  /* Finally, we need to set the probabilities on the duplicated
-	     edges out of the duplicated joiner (e2->src).  The probabilities
-	     along the original path will all be updated below after we finish
-	     processing the whole path.  */
-	  recompute_probabilities (e2->src);
-
 	  /* Record the frequency flowing to the downstream duplicated
 	     path blocks.  */
 	  cur_path_freq = EDGE_FREQUENCY (e2);
@@ -1263,8 +1163,7 @@  ssa_fix_duplicate_block_edges (struct re
 	     been updated at the end of that handling to the edge frequency
 	     along the duplicated joiner path edge.  */
 	  update_profile (epath, EDGE_SUCC (rd->dup_blocks[count], 0),
-			  path_out_count, path_out_count,
-			  cur_path_freq);
+			  path_out_count, path_out_count, cur_path_freq);
 	}
       else
 	{
@@ -1294,14 +1193,6 @@  ssa_fix_duplicate_block_edges (struct re
 	}
     }
 
-  /* Now walk orig blocks and update their probabilities, since the
-     counts and freqs should be updated properly by above loop.  */
-  for (unsigned int i = 1; i < path->length (); i++)
-    {
-      edge epath = (*path)[i]->e;
-      recompute_probabilities (epath->src);
-    }
-
   /* Done with all profile and frequency updates, clear counts if they
      were copied.  */
   if (do_freqs_to_counts)
@@ -2247,7 +2138,7 @@  duplicate_thread_path (edge entry, edge
      invalidating the property that is propagated by executing all the blocks of
      the jump-thread path in order.  */
 
-  curr_count = entry->count;
+  curr_count = entry->count ();
   curr_freq = EDGE_FREQUENCY (entry);
 
   for (i = 0; i < n_region; i++)
@@ -2300,7 +2191,7 @@  duplicate_thread_path (edge entry, edge
 	  if (i + 1 != n_region)
 	    {
 	      curr_freq = EDGE_FREQUENCY (single_succ_edge (bb));
-	      curr_count = single_succ_edge (bb)->count;
+	      curr_count = single_succ_edge (bb)->count ();
 	    }
 	  continue;
 	}
@@ -2331,7 +2222,7 @@  duplicate_thread_path (edge entry, edge
 	else
 	  {
 	    curr_freq = EDGE_FREQUENCY (e);
-	    curr_count = e->count;
+	    curr_count = e->count ();
 	  }
     }
 
@@ -2353,7 +2244,6 @@  duplicate_thread_path (edge entry, edge
     {
       rescan_loop_exit (e, true, false);
       e->probability = profile_probability::always ();
-      e->count = region_copy[n_region - 1]->count;
     }
 
   /* Redirect the entry and add the phi node arguments.  */
Index: tree-switch-conversion.c
===================================================================
--- tree-switch-conversion.c	(revision 253889)
+++ tree-switch-conversion.c	(working copy)
@@ -107,8 +107,7 @@  hoist_edge_and_branch_if_true (gimple_st
   e_false->flags &= ~EDGE_FALLTHRU;
   e_false->flags |= EDGE_FALSE_VALUE;
   e_false->probability = e_true->probability.invert ();
-  e_false->count = split_bb->count - e_true->count;
-  new_bb->count = e_false->count;
+  new_bb->count = e_false->count ();
 
   if (update_dominators)
     {
@@ -239,9 +238,9 @@  case_bit_test_cmp (const void *p1, const
   const struct case_bit_test *const d1 = (const struct case_bit_test *) p1;
   const struct case_bit_test *const d2 = (const struct case_bit_test *) p2;
 
-  if (d2->target_edge->count < d1->target_edge->count)
+  if (d2->target_edge->count () < d1->target_edge->count ())
     return -1;
-  if (d2->target_edge->count > d1->target_edge->count)
+  if (d2->target_edge->count () > d1->target_edge->count ())
     return 1;
   if (d2->bits != d1->bits)
     return d2->bits - d1->bits;
@@ -635,10 +634,10 @@  collect_switch_conv_info (gswitch *swtch
     = label_to_block (CASE_LABEL (gimple_switch_default_label (swtch)));
   e_default = find_edge (info->switch_bb, info->default_bb);
   info->default_prob = e_default->probability;
-  info->default_count = e_default->count;
+  info->default_count = e_default->count ();
   FOR_EACH_EDGE (e, ei, info->switch_bb->succs)
     if (e != e_default)
-      info->other_count += e->count;
+      info->other_count += e->count ();
 
   /* Get upper and lower bounds of case values, and the covered range.  */
   min_case = gimple_switch_label (swtch, 1);
@@ -1424,19 +1423,16 @@  gen_inbound_check (gswitch *swtch, struc
   if (!info->default_case_nonstandard)
     e01 = make_edge (bb0, bb1, EDGE_TRUE_VALUE);
   e01->probability = info->default_prob.invert ();
-  e01->count = info->other_count;
 
   /* flags and profiles of the edge taking care of out-of-range values */
   e02->flags &= ~EDGE_FALLTHRU;
   e02->flags |= EDGE_FALSE_VALUE;
   e02->probability = info->default_prob;
-  e02->count = info->default_count;
 
   bbf = info->final_bb;
 
   e1f = make_edge (bb1, bbf, EDGE_FALLTHRU);
   e1f->probability = profile_probability::always ();
-  e1f->count = info->other_count;
 
   if (info->default_case_nonstandard)
     e2f = NULL;
@@ -1444,7 +1440,6 @@  gen_inbound_check (gswitch *swtch, struc
     {
       e2f = make_edge (bb2, bbf, EDGE_FALLTHRU);
       e2f->probability = profile_probability::always ();
-      e2f->count = info->default_count;
     }
 
   /* frequencies of the new BBs */
@@ -2248,12 +2243,10 @@  do_jump_if_equal (basic_block bb, tree o
   edge false_edge = split_block (bb, cond);
   false_edge->flags = EDGE_FALSE_VALUE;
   false_edge->probability = prob.invert ();
-  false_edge->count = bb->count.apply_probability (false_edge->probability);
 
   edge true_edge = make_edge (bb, label_bb, EDGE_TRUE_VALUE);
   fix_phi_operands_for_edge (true_edge, phi_mapping);
   true_edge->probability = prob;
-  true_edge->count = bb->count.apply_probability (true_edge->probability);
 
   return false_edge->dest;
 }
@@ -2293,12 +2286,10 @@  emit_cmp_and_jump_insns (basic_block bb,
   edge false_edge = split_block (bb, cond);
   false_edge->flags = EDGE_FALSE_VALUE;
   false_edge->probability = prob.invert ();
-  false_edge->count = bb->count.apply_probability (false_edge->probability);
 
   edge true_edge = make_edge (bb, label_bb, EDGE_TRUE_VALUE);
   fix_phi_operands_for_edge (true_edge, phi_mapping);
   true_edge->probability = prob;
-  true_edge->count = bb->count.apply_probability (true_edge->probability);
 
   return false_edge->dest;
 }
Index: tree-tailcall.c
===================================================================
--- tree-tailcall.c	(revision 253889)
+++ tree-tailcall.c	(working copy)
@@ -807,7 +807,6 @@  adjust_return_value (basic_block bb, tre
 static void
 decrease_profile (basic_block bb, profile_count count, int frequency)
 {
-  edge e;
   bb->count = bb->count - count;
   bb->frequency -= frequency;
   if (bb->frequency < 0)
@@ -817,8 +816,6 @@  decrease_profile (basic_block bb, profil
       gcc_assert (!EDGE_COUNT (bb->succs));
       return;
     }
-  e = single_succ_edge (bb);
-  e->count -= count;
 }
 
 /* Returns true if argument PARAM of the tail recursive call needs to be copied
@@ -895,11 +892,11 @@  eliminate_tail_call (struct tailcall *t)
 
   /* Number of executions of function has reduced by the tailcall.  */
   e = single_succ_edge (gsi_bb (t->call_gsi));
-  decrease_profile (EXIT_BLOCK_PTR_FOR_FN (cfun), e->count, EDGE_FREQUENCY (e));
-  decrease_profile (ENTRY_BLOCK_PTR_FOR_FN (cfun), e->count,
+  decrease_profile (EXIT_BLOCK_PTR_FOR_FN (cfun), e->count (), EDGE_FREQUENCY (e));
+  decrease_profile (ENTRY_BLOCK_PTR_FOR_FN (cfun), e->count (),
 		    EDGE_FREQUENCY (e));
   if (e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun))
-    decrease_profile (e->dest, e->count, EDGE_FREQUENCY (e));
+    decrease_profile (e->dest, e->count (), EDGE_FREQUENCY (e));
 
   /* Replace the call by a jump to the start of function.  */
   e = redirect_edge_and_branch (single_succ_edge (gsi_bb (t->call_gsi)),
Index: tree-vect-loop-manip.c
===================================================================
--- tree-vect-loop-manip.c	(revision 253889)
+++ tree-vect-loop-manip.c	(working copy)
@@ -563,13 +563,10 @@  slpeel_add_loop_guard (basic_block guard
   /* Add new edge to connect guard block to the merge/loop-exit block.  */
   new_e = make_edge (guard_bb, guard_to, EDGE_TRUE_VALUE);
 
-  new_e->count = guard_bb->count;
   new_e->probability = probability;
-  new_e->count = enter_e->count.apply_probability (probability);
   if (irreducible_p)
     new_e->flags |= EDGE_IRREDUCIBLE_LOOP;
 
-  enter_e->count -= new_e->count;
   enter_e->probability = probability.invert ();
   set_immediate_dominator (CDI_DOMINATORS, guard_to, dom_bb);
 
@@ -1848,7 +1845,6 @@  vect_do_peeling (loop_vec_info loop_vinf
 	     a merge point of control flow.  */
 	  guard_to->frequency = guard_bb->frequency;
 	  guard_to->count = guard_bb->count;
-	  single_succ_edge (guard_to)->count = guard_to->count;
 	  /* Scale probability of epilog loop back.
 	     FIXME: We should avoid scaling down and back up.  Profile may
 	     get lost if we scale down to 0.  */
Index: tree-vect-loop.c
===================================================================
--- tree-vect-loop.c	(revision 253889)
+++ tree-vect-loop.c	(working copy)
@@ -7224,7 +7224,7 @@  scale_profile_for_vect_loop (struct loop
   edge preheader = loop_preheader_edge (loop);
   /* Reduce loop iterations by the vectorization factor.  */
   gcov_type new_est_niter = niter_for_unrolled_loop (loop, vf);
-  profile_count freq_h = loop->header->count, freq_e = preheader->count;
+  profile_count freq_h = loop->header->count, freq_e = preheader->count ();
 
   /* Use frequency only if counts are zero.  */
   if (!(freq_h > 0) && !(freq_e > 0))
@@ -7244,16 +7244,13 @@  scale_profile_for_vect_loop (struct loop
       scale_loop_frequencies (loop, p);
     }
 
-  basic_block exit_bb = single_pred (loop->latch);
   edge exit_e = single_exit (loop);
-  exit_e->count = loop_preheader_edge (loop)->count;
   exit_e->probability = profile_probability::always ()
 				 .apply_scale (1, new_est_niter + 1);
 
   edge exit_l = single_pred_edge (loop->latch);
   profile_probability prob = exit_l->probability;
   exit_l->probability = exit_e->probability.invert ();
-  exit_l->count = exit_bb->count - exit_e->count;
   if (prob.initialized_p () && exit_l->probability.initialized_p ())
     scale_bbs_frequencies (&loop->latch, 1, exit_l->probability / prob);
 }
Index: ubsan.c
===================================================================
--- ubsan.c	(revision 253889)
+++ ubsan.c	(working copy)
@@ -813,7 +813,6 @@  ubsan_expand_null_ifn (gimple_stmt_itera
   /* Set up the fallthrough basic block.  */
   e = find_edge (cond_bb, fallthru_bb);
   e->flags = EDGE_FALSE_VALUE;
-  e->count = cond_bb->count;
   e->probability = profile_probability::very_likely ();
 
   /* Update dominance info for the newly created then_bb; note that
@@ -884,7 +883,6 @@  ubsan_expand_null_ifn (gimple_stmt_itera
 	  /* Set up the fallthrough basic block.  */
 	  e = find_edge (cond1_bb, cond2_bb);
 	  e->flags = EDGE_FALSE_VALUE;
-	  e->count = cond1_bb->count;
 	  e->probability = profile_probability::very_likely ();
 
 	  /* Update dominance info.  */
@@ -1075,7 +1073,6 @@  ubsan_expand_ptr_ifn (gimple_stmt_iterat
   e->flags = EDGE_FALSE_VALUE;
   if (pos_neg != 3)
     {
-      e->count = cond_bb->count;
       e->probability = profile_probability::very_likely ();
 
       /* Connect 'then block' with the 'else block'.  This is needed
@@ -1091,14 +1088,11 @@  ubsan_expand_ptr_ifn (gimple_stmt_iterat
     }
   else
     {
-      profile_count count = cond_bb->count.apply_probability (PROB_EVEN);
-      e->count = count;
       e->probability = profile_probability::even ();
 
       e = split_block (fallthru_bb, (gimple *) NULL);
       cond_neg_bb = e->src;
       fallthru_bb = e->dest;
-      e->count = count;
       e->probability = profile_probability::very_likely ();
       e->flags = EDGE_FALSE_VALUE;
 
@@ -1109,14 +1103,12 @@  ubsan_expand_ptr_ifn (gimple_stmt_iterat
       add_bb_to_loop (cond_pos_bb, cond_bb->loop_father);
 
       e = make_edge (cond_bb, cond_pos_bb, EDGE_TRUE_VALUE);
-      e->count = count;
       e->probability = profile_probability::even ();
 
       e = make_edge (cond_pos_bb, then_bb, EDGE_TRUE_VALUE);
       e->probability = profile_probability::very_unlikely ();
 
       e = make_edge (cond_pos_bb, fallthru_bb, EDGE_FALSE_VALUE);
-      e->count = count;
       e->probability = profile_probability::very_likely ();
 
       make_single_succ_edge (then_bb, fallthru_bb, EDGE_FALLTHRU);
Index: value-prof.c
===================================================================
--- value-prof.c	(revision 253889)
+++ value-prof.c	(working copy)
@@ -745,20 +745,16 @@  gimple_divmod_fixed_value (gassign *stmt
   e12->flags &= ~EDGE_FALLTHRU;
   e12->flags |= EDGE_FALSE_VALUE;
   e12->probability = prob;
-  e12->count = profile_count::from_gcov_type (count);
 
   e13 = make_edge (bb, bb3, EDGE_TRUE_VALUE);
   e13->probability = prob.invert ();
-  e13->count = profile_count::from_gcov_type (all - count);
 
   remove_edge (e23);
 
   e24 = make_edge (bb2, bb4, EDGE_FALLTHRU);
   e24->probability = profile_probability::always ();
-  e24->count = profile_count::from_gcov_type (count);
 
   e34->probability = profile_probability::always ();
-  e34->count = profile_count::from_gcov_type (all - count);
 
   return tmp2;
 }
@@ -910,20 +906,16 @@  gimple_mod_pow2 (gassign *stmt, profile_
   e12->flags &= ~EDGE_FALLTHRU;
   e12->flags |= EDGE_FALSE_VALUE;
   e12->probability = prob;
-  e12->count = profile_count::from_gcov_type (count);
 
   e13 = make_edge (bb, bb3, EDGE_TRUE_VALUE);
   e13->probability = prob.invert ();
-  e13->count = profile_count::from_gcov_type (all - count);
 
   remove_edge (e23);
 
   e24 = make_edge (bb2, bb4, EDGE_FALLTHRU);
   e24->probability = profile_probability::always ();
-  e24->count = profile_count::from_gcov_type (count);
 
   e34->probability = profile_probability::always ();
-  e34->count = profile_count::from_gcov_type (all - count);
 
   return result;
 }
@@ -1076,26 +1068,21 @@  gimple_mod_subtract (gassign *stmt, prof
   e12->flags &= ~EDGE_FALLTHRU;
   e12->flags |= EDGE_FALSE_VALUE;
   e12->probability = prob1.invert ();
-  e12->count = profile_count::from_gcov_type (all - count1);
 
   e14 = make_edge (bb, bb4, EDGE_TRUE_VALUE);
   e14->probability = prob1;
-  e14->count = profile_count::from_gcov_type (count1);
 
   if (ncounts)  /* Assumed to be 0 or 1.  */
     {
       e23->flags &= ~EDGE_FALLTHRU;
       e23->flags |= EDGE_FALSE_VALUE;
-      e23->count = profile_count::from_gcov_type (all - count1 - count2);
       e23->probability = prob2.invert ();
 
       e24 = make_edge (bb2, bb4, EDGE_TRUE_VALUE);
       e24->probability = prob2;
-      e24->count = profile_count::from_gcov_type (count2);
     }
 
   e34->probability = profile_probability::always ();
-  e34->count = profile_count::from_gcov_type (all - count1 - count2);
 
   return result;
 }
@@ -1383,7 +1370,6 @@  gimple_ic (gcall *icall_stmt, struct cgr
       if (e_ij != NULL)
 	{
 	  e_ij->probability = profile_probability::always ();
-	  e_ij->count = all - count;
 	  e_ij = single_pred_edge (split_edge (e_ij));
 	}
     }
@@ -1395,25 +1381,18 @@  gimple_ic (gcall *icall_stmt, struct cgr
 
   e_cd->flags = (e_cd->flags & ~EDGE_FALLTHRU) | EDGE_TRUE_VALUE;
   e_cd->probability = prob;
-  e_cd->count = count;
 
   e_ci = make_edge (cond_bb, icall_bb, EDGE_FALSE_VALUE);
   e_ci->probability = prob.invert ();
-  e_ci->count = all - count;
 
   remove_edge (e_di);
 
   if (e_ij != NULL)
     {
-      if ((dflags & ECF_NORETURN) != 0)
-	e_ij->count = all;
-      else
+      if ((dflags & ECF_NORETURN) == 0)
 	{
 	  e_dj = make_edge (dcall_bb, join_bb, EDGE_FALLTHRU);
 	  e_dj->probability = profile_probability::always ();
-	  e_dj->count = count;
-
-	  e_ij->count = all - count;
 	}
       e_ij->probability = profile_probability::always ();
     }
@@ -1494,7 +1473,6 @@  gimple_ic (gcall *icall_stmt, struct cgr
       {
 	e = make_edge (dcall_bb, e_eh->dest, e_eh->flags);
 	e->probability = e_eh->probability;
-	e->count = e_eh->count;
 	for (gphi_iterator psi = gsi_start_phis (e_eh->dest);
 	     !gsi_end_p (psi); gsi_next (&psi))
 	  {
@@ -1704,20 +1682,16 @@  gimple_stringop_fixed_value (gcall *vcal
 
   e_ci->flags = (e_ci->flags & ~EDGE_FALLTHRU) | EDGE_TRUE_VALUE;
   e_ci->probability = prob;
-  e_ci->count = profile_count::from_gcov_type (count);
 
   e_cv = make_edge (cond_bb, vcall_bb, EDGE_FALSE_VALUE);
   e_cv->probability = prob.invert ();
-  e_cv->count = profile_count::from_gcov_type (all - count);
 
   remove_edge (e_iv);
 
   e_ij = make_edge (icall_bb, join_bb, EDGE_FALLTHRU);
   e_ij->probability = profile_probability::always ();
-  e_ij->count = profile_count::from_gcov_type (count);
 
   e_vj->probability = profile_probability::always ();
-  e_vj->count = profile_count::from_gcov_type (all - count);
 
   /* Insert PHI node for the call result if necessary.  */
   if (gimple_call_lhs (vcall_stmt)