asan.c (create_cond_insert_point): Do not update edge count.
authorJan Hubicka <hubicka@ucw.cz>
Thu, 19 Oct 2017 20:19:15 +0000 (22:19 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Thu, 19 Oct 2017 20:19:15 +0000 (20:19 +0000)
* 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.

From-SVN: r253910

60 files changed:
gcc/ChangeLog
gcc/asan.c
gcc/auto-profile.c
gcc/basic-block.h
gcc/bb-reorder.c
gcc/cfg.c
gcc/cfganal.c
gcc/cfgbuild.c
gcc/cfgcleanup.c
gcc/cfgexpand.c
gcc/cfghooks.c
gcc/cfgloop.c
gcc/cfgloopanal.c
gcc/cfgloopmanip.c
gcc/cfgrtl.c
gcc/cgraphunit.c
gcc/gimple-pretty-print.c
gcc/gimple-ssa-isolate-paths.c
gcc/haifa-sched.c
gcc/hsa-gen.c
gcc/ifcvt.c
gcc/ipa-inline-transform.c
gcc/ipa-split.c
gcc/ipa-utils.c
gcc/loop-doloop.c
gcc/loop-unroll.c
gcc/lto-streamer-in.c
gcc/lto-streamer-out.c
gcc/modulo-sched.c
gcc/postreload-gcse.c
gcc/predict.c
gcc/profile.c
gcc/reg-stack.c
gcc/shrink-wrap.c
gcc/tracer.c
gcc/trans-mem.c
gcc/tree-call-cdce.c
gcc/tree-cfg.c
gcc/tree-cfgcleanup.c
gcc/tree-complex.c
gcc/tree-eh.c
gcc/tree-inline.c
gcc/tree-ssa-dce.c
gcc/tree-ssa-ifcombine.c
gcc/tree-ssa-loop-im.c
gcc/tree-ssa-loop-ivcanon.c
gcc/tree-ssa-loop-manip.c
gcc/tree-ssa-loop-split.c
gcc/tree-ssa-loop-unswitch.c
gcc/tree-ssa-phionlycprop.c
gcc/tree-ssa-phiopt.c
gcc/tree-ssa-reassoc.c
gcc/tree-ssa-tail-merge.c
gcc/tree-ssa-threadupdate.c
gcc/tree-switch-conversion.c
gcc/tree-tailcall.c
gcc/tree-vect-loop-manip.c
gcc/tree-vect-loop.c
gcc/ubsan.c
gcc/value-prof.c

index 8d628e200def9aa34392baf5861f7b641c4320fe..59bcbb4d5d78dd3996ed9b5ed286c192d03024d7 100644 (file)
@@ -1,3 +1,138 @@
+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.
+
 2017-10-19  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/82618
index be8b79e3554fcd3581b7fcc238aa81693a210d23..302ac4fcdecf20899c561a6124f6158b757c1cc3 100644 (file)
@@ -1807,7 +1807,6 @@ create_cond_insert_point (gimple_stmt_iterator *iter,
   /* 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 9226e202d50374f0af49d6b583ca06cb52367338..378f48037ededcf4bc21e6d3ba2065830e80f861 100644 (file)
@@ -1234,7 +1234,7 @@ afdo_propagate_edge (bool is_succ, bb_set *annotated_bb,
       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_set *annotated_bb,
       }
     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 &annotated_bb, edge_set *annotated_edge)
           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 *annotated_bb, edge_set *annotated_edge)
       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 &promoted_stmts)
        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 c0c47784c02448b177acca538404d0493825b32e..1505cce81bf589483c93495263830080f4590cd7 100644 (file)
@@ -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 (basic_block bb)
   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 4dad298fe596d103f6ad4289bc2426d3b8513a66..dc2025fac9c19be07a9df451d4071e0b144ab1db 100644 (file)
@@ -374,11 +374,11 @@ rotate_loop (edge back_edge, struct trace *trace, int trace_n)
                {
                  /* 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 trace *trace, int trace_n)
                  /* 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 exec_th, gcov_type count_th,
                  || !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 exec_th, gcov_type count_th,
                      || !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 trace *traces)
                                && !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 trace *traces)
                  && 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, unsigned int cold_bb_count,
 
          /* 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, unsigned int cold_bb_count,
           /* 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, unsigned int cold_bb_count,
             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 01e68aeda518994f82ef57c4422e0c94cded68a7..41002ec00910b50787ba5f010ce3dc95797a1a19 100644 (file)
--- a/gcc/cfg.c
+++ b/gcc/cfg.c
@@ -263,7 +263,6 @@ unchecked_make_edge (basic_block src, basic_block dst, int flags)
   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, basic_block dest, int flags)
   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 * file, int indent)
                       ";; %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 * file, int indent)
        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_flags_t flags, int do_succ)
       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_block bb, int edge_frequency,
     }
 
   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 *bbs, int nbbs, int num, int den)
 
   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_block *bbs, int nbbs, gcov_type num,
                                 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_block *bbs, int nbbs, gcov_type num,
   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 (basic_block *bbs, int nbbs,
                                     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, int nbbs,
                       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 394d986c945a3d02ce8a8769859ce2ccba2c8fcb..c506067fdcd1962d8442b51c35aa21650538215f 100644 (file)
@@ -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 62956b2a6a2a0603a50a68db153d3b18592cada8..c6d506ae474261c83974dcd6c05b674b4fe19e60 100644 (file)
@@ -576,10 +576,8 @@ compute_outgoing_frequencies (basic_block b)
          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_block b)
     {
       e = single_succ_edge (b);
       e->probability = profile_probability::always ();
-      e->count = b->count;
       return;
     }
   else
@@ -610,10 +607,6 @@ compute_outgoing_frequencies (basic_block b)
       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 blocks)
            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 365c971effb3da1e05525a85e8b12954531933cc..c2b0434f179bde595dea280f9dece9315caeda86 100644 (file)
@@ -558,7 +558,7 @@ try_forward_edges (int mode, basic_block b)
       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 b)
                  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, edge e2,
            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 df60f80491ca5b66a363b6b568edb2960cc53f33..a255ac3c6f094c3a0a3b5e4e64c02114a70eeb7b 100644 (file)
@@ -2507,7 +2507,7 @@ expand_gimple_cond (basic_block bb, gcond *stmt)
   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);
@@ -3817,7 +3817,6 @@ expand_gimple_tailcall (basic_block bb, gcall *stmt, bool *can_fallthru)
      the exit block.  */
 
   probability = profile_probability::never ();
-  profile_count count = profile_count::zero ();
 
   for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); )
     {
@@ -3825,12 +3824,10 @@ expand_gimple_tailcall (basic_block bb, gcall *stmt, bool *can_fallthru)
        {
          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);
        }
@@ -3860,7 +3857,6 @@ expand_gimple_tailcall (basic_block bb, gcall *stmt, bool *can_fallthru)
   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);
 
@@ -5930,8 +5926,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 258a5eabf8dd08af4d00782efbb1416040a4a047..320036bc7577ce185d147da884eb4141dc688654 100644 (file)
@@ -176,12 +176,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 +447,6 @@ redirect_edge_succ_nodup (edge e, basic_block new_succ)
     {
       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 +625,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 +642,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 +870,6 @@ make_forwarder_block (basic_block bb, bool (*redirect_edge_p) (edge),
   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 +883,7 @@ make_forwarder_block (basic_block bb, bool (*redirect_edge_p) (edge),
          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 +1069,7 @@ duplicate_block (basic_block bb, edge e, basic_block after)
 {
   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 +1093,6 @@ duplicate_block (basic_block bb, edge e, basic_block after)
         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 +1456,7 @@ account_profile_record (struct profile_record *record, int after_pass)
            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 +1472,7 @@ account_profile_record (struct profile_record *record, int after_pass)
            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 c3bd9c05013d81a197bfd659261e872c499c886a..4b0374abefa5a0968026627977eb47e4387afcb9 100644 (file)
@@ -599,12 +599,12 @@ find_subloop_latch_edge_by_profile (vec<edge> latches)
 
   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 73710abac6e2e6637bff0b91286459b30e17a1b1..15b39e335fd04ec67f1143f5a2136aeddf71e736 100644 (file)
@@ -253,9 +253,9 @@ expected_loop_iterations_unbounded (const struct loop *loop,
 
       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 fd335c3fe1dd5e36844bb74bf59322b441ea422c..af65183bfaa4163c8f6708288ed6322b8243a3ae 100644 (file)
@@ -546,16 +546,12 @@ scale_loop_profile (struct loop *loop, profile_probability 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, profile_probability 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_edge,
   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_edge,
     {
       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 first_head, basic_block second_head,
                  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 739d1bb9490cac02b235d244629463ee00aa4ab0..65e25dc1293349f2ecdc3f309635a4d7d9879381 100644 (file)
@@ -1156,7 +1156,6 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout)
     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, basic_block target, rtx jump_label)
          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, basic_block target, rtx jump_label)
   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, basic_block target, rtx jump_label)
       /* 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, basic_block target, rtx jump_label)
       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 9385dc825ab286276a627955d004b7aa462dda12..ea52f43dc6a7d9a6be54635112c8614eec104d8e 100644 (file)
@@ -1608,10 +1608,8 @@ init_lowered_empty_function (tree decl, bool in_ssa, profile_count count)
   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_asm_thunks, bool force_gimple_thunk)
                  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 ed8e51c1c4677735462f88f460db64ee6cb63924..0da90740165b1063f994b63288b709f45426f6ae 100644 (file)
@@ -109,7 +109,7 @@ dump_profile (int frequency, profile_count &count)
    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 probability, profile_count &count)
     }
 
   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 probability, profile_count &count)
 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 807e00324105d7814473cf0e7a74949ac0f90a84..ba5c6a3a715328ae41b148420850d1fe8f8c0a84 100644 (file)
@@ -169,7 +169,6 @@ isolate_path (basic_block bb, basic_block duplicate,
 
       /* 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 d6dab57101b1ccd6d1e170b79dc0da566e5a617d..0c73003ebcaabd30e1f357518e89d9b30d4ceac3 100644 (file)
@@ -8311,11 +8311,9 @@ sched_create_recovery_edges (basic_block first_bb, basic_block rec,
      '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 d89d12084eb269b719fbd8e5c4ad8e3e8ddc7758..a2cb8b24e16f55e827ef6077d4816d3129162f9d 100644 (file)
@@ -6269,7 +6269,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;
 
@@ -6359,7 +6359,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)
@@ -6375,9 +6374,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;
              }
@@ -6386,7 +6382,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 278d5b240f14e875e6f2fa558289b164670e99cb..72bab82491f48ad7f054f0931ac22751d881302c 100644 (file)
@@ -5283,8 +5283,6 @@ dead_or_predicable (basic_block test_bb, basic_block merge_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 dc224f7a39469abdcd6ecb1c1a955552ee07fdba..1e7fafa1bff88f916d135589416433a0339245b1 100644 (file)
@@ -692,14 +692,7 @@ inline_transform (struct cgraph_node *node)
 
          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 e3759d6c50e401f49f315d93af4978417c7dbbd2..f2d1478d5903f066f7e16e0f7eb2b1283a1f9c5d 100644 (file)
@@ -1285,7 +1285,6 @@ split_function (basic_block return_bb, struct split_point *split_point,
          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 708710d61353a3c921dc61a5190c308e4bab1a00..a27e406efec95e974342092f1f6f1913c0ff65e1 100644 (file)
@@ -524,20 +524,28 @@ ipa_merge_profiles (struct cgraph_node *dst,
          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 5769d9deccb364acb99bd9b4e78a68eb1703ab9c..421b35513d2a72f7ec84e0cd4b9aeaed6c4dbff6 100644 (file)
@@ -393,9 +393,7 @@ add_test (rtx cond, edge *e, basic_block dest)
 
   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 322f151ac5dfdc4f0303ee73ad8220fc694f30e8..816302b9e70d85029b43151275b1428fb4ab142b 100644 (file)
@@ -977,7 +977,6 @@ unroll_loop_runtime_iterations (struct loop *loop)
   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 loop *loop)
       /* 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 loop *loop)
       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 loop *loop)
       /* 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 loop *loop)
       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 51d9a7b222b5636e4b3f9a09eaad34f0924b8c0d..ea6f92b174f5d65b1f88d9b5a4cb11661bff0a7f 100644 (file)
@@ -715,8 +715,7 @@ make_new_block (struct function *fn, unsigned int index)
 
 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, struct data_in *data_in,
          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, struct data_in *data_in,
 
          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 data_in *data_in,
   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 944502be3f8aef9408c81cbf7beb48f738c7fa1d..d007c0af5d66a37edc44b46a7ef5f51970a8086a 100644 (file)
@@ -1883,7 +1883,6 @@ output_cfg (struct output_block *ob, struct function *fn)
        {
          streamer_write_uhwi (ob, e->dest->index);
          e->probability.stream_out (ob);
-         e->count.stream_out (ob);
          streamer_write_uhwi (ob, e->flags);
        }
     }
index f85011e90c216875a8fdb27eb3de86547c7157b8..71b2a6160964f163c60e9c707ce996a7ce4dfe43 100644 (file)
@@ -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 a1dcac2600c7a3c86495f65f4d43c1ff51a2fcc6..15fdb7e0cfe7767e559cd9ef6d5f66d3501ffd90 100644 (file)
@@ -1108,14 +1108,14 @@ eliminate_partially_redundant_load (basic_block bb, rtx_insn *insn,
            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 (basic_block bb, rtx_insn *insn,
          /* 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 e534502aaf58df3f1a14c0c7c3f5473b6654e500..0a85d0b00b43dc7850df7329eb124fbb34973d6d 100644 (file)
@@ -203,7 +203,7 @@ maybe_hot_bb_p (struct function *fun, const_basic_block bb)
 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 function *fun, const_basic_block bb)
 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 function *fun, edge e)
 {
   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_predictor predictor, int probability,
       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, profile_count call_count)
   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 6d40241a37bccdad614d9fc9f7b3e8e45d67f0eb..95dd578a4937b0905f97c2ad8762463a2027e947 100644 (file)
@@ -831,12 +831,7 @@ compute_branch_probabilities (unsigned cfg_checksum, unsigned lineno_checksum)
 
   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 86021ab0b90de016ac0f5a312bed129bcf7ff793..62f7d7b965373daafdb90b16a68a092779d23009 100644 (file)
@@ -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 3cad7760f9c4eee1cd369a735294f6b00cdfac5a..1a2802fbcc199ed90e465391d1261fa88beba2ec 100644 (file)
@@ -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 dd071c1650c8d9b7cef5a4d70ff0bf9a9ac57fe6..f3e401b8b123f7245f3dbcf7d90ffcf84e9b579a 100644 (file)
@@ -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 40b5368118664bdaaeb06546c390924feb1763f8..2c701f0a546db9396b6ec998b7cf457a07d52eb9 100644 (file)
@@ -2938,10 +2938,8 @@ expand_transaction (struct tm_region *region, void *data ATTRIBUTE_UNUSED)
       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 *region, void *data ATTRIBUTE_UNUSED)
       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 *region, void *data ATTRIBUTE_UNUSED)
       // 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 *region, void *data ATTRIBUTE_UNUSED)
       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, basic_block dest_bb,
     }
   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 1578350c0c63eb4f09618411f792f27167d54da7..43987721b25eefcfa2419639935caba5a7e80c14 100644 (file)
@@ -913,21 +913,17 @@ shrink_wrap_one_built_in_call_with_conds (gcall *bi_call, vec <gimple *> 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 b5e0460c84a5b345805a2dea932ca06f3dc53b53..a7c7348ed298e0e22b48464c59e81d900f7ee1f3 100644 (file)
@@ -1062,8 +1062,8 @@ gimple_find_sub_bbs (gimple_seq seq, gimple_stmt_iterator *gsi)
       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, gimple_stmt_iterator *gsi)
       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, edge exit,
   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, edge exit,
   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, edge exit,
   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 blocks)
                    }
                  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 *stmt, gimple *cond,
   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 1a71c93aeedc439652ae5d3de83f7507e6163762..9b7f08c586c39d6d37fc15280f395a6e847706e0 100644 (file)
@@ -195,7 +195,6 @@ cleanup_control_expr_graph (basic_block bb, gimple_stmt_iterator gsi,
                }
 
              taken_edge->probability += e->probability;
-             taken_edge->count += e->count;
              remove_edge_and_dominated_blocks (e);
              retval = true;
            }
index d61047bbf5f809f8d4cb4f41df846aa2cf77cc82..e2d93b78eae5e2be7017f072ced3ac1cb5f4b958 100644 (file)
@@ -1192,13 +1192,11 @@ expand_complex_div_wide (gimple_stmt_iterator *gsi, tree inner_type,
 
       /* 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 329fadb230f35cc8a22d625a505c09d36e28d496..e255e086bb54a1cba3db0a01bae8a5427fdcc9cf 100644 (file)
@@ -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, edge e_out,
   /* 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 c764a44db61684195640d076b467dfcebfbbb930..597addbd4bb0bb67ba148742854c37a80d0397d7 100644 (file)
@@ -2215,7 +2215,7 @@ update_ssa_across_abnormal_edges (basic_block bb, basic_block ret_bb,
    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, profile_count num, profile_count den,
   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, profile_count num, profile_count den,
            && 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, profile_count num, profile_count den,
                && (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, profile_count count, int frequency_scale,
 
       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, profile_count count, int frequency_scale,
   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 59dd3f3038a86e573dc3ce9df7394082a11cc03e..a5f0edf7893b10cb198d1af813c6bb559026e609 100644 (file)
@@ -1051,7 +1051,6 @@ remove_dead_stmt (gimple_stmt_iterator *i, basic_block bb)
        }
       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 a211335889b1d4c1fce2fa3c0e37f3f3c30f103d..06d22693a1f1524eb2e8513b647b89316d1a68c8 100644 (file)
@@ -358,10 +358,7 @@ update_profile_after_ifcombine (basic_block inner_cond_bb,
      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 503e662452c1bc5877ce0bb1f0390d574704db1a..a1b8a0097453aefc108c9483856f05209c1fbb7a 100644 (file)
@@ -1815,9 +1815,9 @@ execute_sm_if_changed (edge ex, tree mem, tree tmp_var, tree flag,
 
   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, tree tmp_var, tree flag,
   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 efb199aaaa25d3bd3c44bcf437c9e6e74b4f46ec..743bf1ad9d6d578512dedb4745ebec94535ed261 100644 (file)
@@ -530,7 +530,6 @@ remove_exits_and_undefined_stmts (struct loop *loop, unsigned int npeeled)
          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_invalidated,
       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 b08b8b9b92c9f800b2b3971e0ebcb0697094485a..5794dae75be56e23d22a55eaf03a41f016944ddc 100644 (file)
@@ -1294,12 +1294,10 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
   /* 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 loop *loop, unsigned factor,
      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 loop *loop, unsigned factor,
 
   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 e454cc5dc93817393e7c5bd7f5f70e76286535e5..dcb7c1ee4c81dfaa264b041b87955bc063128c43 100644 (file)
@@ -353,11 +353,8 @@ connect_loops (struct loop *loop1, struct loop *loop2)
       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 tree_niter_desc *niter)
        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 57aba4f1dd019de39cb69785f9115f422f498590..4287c104f24f37fb46e456402227adc1d4b90dfa 100644 (file)
@@ -853,16 +853,15 @@ hoist_guard (struct loop *loop, edge guard)
      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 guard)
 
      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 65af44834df71592d80d546ffa779a245f5765f5..fe39aa71f98b5f846d7826ca0727303a330684ad 100644 (file)
@@ -298,7 +298,6 @@ propagate_rhs_into_lhs (gimple *stmt, tree lhs, tree rhs,
 
                          te->probability += e->probability;
 
-                         te->count += e->count;
                          remove_edge (e);
                          cfg_altered = true;
                        }
index c3bdc9e09a7c571b257975062556494c9832e92d..d0570c3fa9c1981bca00c645935624cfc7df3531 100644 (file)
@@ -375,7 +375,6 @@ replace_phi_edge_with_variable (basic_block cond_block,
       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_block cond_block,
       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 e0e64e16eba8f2c0667ef452a329840294abc3f3..cb438c744b71519bb3bb3b50b98fb221ecd15e1d 100644 (file)
@@ -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 a65ff31d900951c527ccf4f64c0415bb5639b278..c10289af78818c99f14b0e6b7915f573b1f1d170 100644 (file)
@@ -1570,14 +1570,14 @@ replace_block_by (basic_block bb1, basic_block bb2)
      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_block bb2)
     {
       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_block bb2)
                (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 28c81a6ec5706fffbf5d51239a5b230914a260d0..8681707651caf2eb3b0008bab443b23c79b675f2 100644 (file)
@@ -303,7 +303,6 @@ remove_ctrl_stmt_and_useless_edges (basic_block bb, basic_block dest_bb)
       else
        {
          e->probability = profile_probability::always ();
-         e->count = bb->count;
          ei_next (&ei);
        }
     }
@@ -741,7 +740,7 @@ compute_path_counts (struct redirection_data *rd,
             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_data *rd,
          /* 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_data *rd,
   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_data *rd,
                     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_data *rd,
      (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.  */
@@ -858,17 +857,54 @@ static void
 update_profile (edge epath, edge edup, profile_count path_in_count,
                profile_count path_out_count, int path_in_freq)
 {
+  if (!(path_in_count > 0))
+    return;
 
   /* First update the duplicated block's count / frequency.  */
   if (edup)
     {
       basic_block dup_block = edup->src;
-      gcc_assert (!dup_block->count.initialized_p ());
+
+      /* Edup's count is reduced by path_out_count.  We need to redistribute
+         probabilities to the remaining edges.  */
+
+      edge esucc;
+      edge_iterator ei;
+      profile_probability edup_prob
+        = path_out_count.probability_in (path_in_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;
+
+      /* FIXME once freqs_to_counts is dropped re-enable this check.  */
+      gcc_assert (!dup_block->count.initialized_p () || 1);
       gcc_assert (dup_block->frequency == 0);
       dup_block->count = path_in_count;
       dup_block->frequency = path_in_freq;
     }
 
+  profile_count final_count = epath->count () - path_out_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/
@@ -883,107 +919,31 @@ update_profile (edge epath, edge edup, profile_count path_in_count,
      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 (!(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 (epath->src->count > 0)
     {
-      if (enonpath == epath)
-       continue;
-      total_orig_off_path_count += enonpath->count;
-    }
-
-  /* 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;
+      edge esucc;
+      edge_iterator ei;
+      profile_probability epath_prob = final_count.probability_in (epath->src->count);
 
-      /* 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;
+      if (epath->probability > epath_prob)
+       {
+          profile_probability rev_scale
+            = (profile_probability::always () - epath->probability)
+              / (profile_probability::always () - epath_prob);
+          FOR_EACH_EDGE (esucc, ei, epath->src->succs)
+            if (esucc != epath)
+              esucc->probability /= rev_scale;
+       }
+      else if (epath->probability < epath_prob)
+       {
+          profile_probability scale
+            = (profile_probability::always () - epath_prob)
+              / (profile_probability::always () - epath->probability);
+         FOR_EACH_EDGE (esucc, ei, epath->src->succs)
+           if (esucc != epath)
+             esucc->probability *= scale;
+       }
+      epath->probability = epath_prob;
     }
 }
 
@@ -1002,7 +962,7 @@ estimated_freqs_path (struct redirection_data *rd)
   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 +976,7 @@ estimated_freqs_path (struct redirection_data *rd)
       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;
        }
@@ -1042,34 +1002,19 @@ freqs_to_counts_path (struct redirection_data *rd)
   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_EACH_EDGE (ein, ei, e->dest->preds)
+    ein->src->count = profile_count::from_gcov_type
+         (ein->src->frequency * REG_BR_PROB_BASE);
   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 +1031,20 @@ clear_counts_path (struct redirection_data *rd)
 {
   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 ();
 
+  edge ein;
+  edge_iterator ei;
+
   FOR_EACH_EDGE (ein, ei, e->dest->preds)
-    ein->count = val;
+    ein->src->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 +1053,6 @@ clear_counts_path (struct redirection_data *rd)
       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 +1172,6 @@ ssa_fix_duplicate_block_edges (struct redirection_data *rd,
          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 +1194,7 @@ ssa_fix_duplicate_block_edges (struct redirection_data *rd,
             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 +1224,6 @@ ssa_fix_duplicate_block_edges (struct redirection_data *rd,
        }
     }
 
-  /* 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 +2169,7 @@ duplicate_thread_path (edge entry, edge exit, basic_block *region,
      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 +2222,7 @@ duplicate_thread_path (edge entry, edge exit, basic_block *region,
          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 +2253,7 @@ duplicate_thread_path (edge entry, edge exit, basic_block *region,
        else
          {
            curr_freq = EDGE_FREQUENCY (e);
-           curr_count = e->count;
+           curr_count = e->count ();
          }
     }
 
@@ -2353,7 +2275,6 @@ duplicate_thread_path (edge entry, edge exit, basic_block *region,
     {
       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 dc9fc84c6a01bca5a379117aa2e0a4425faf7678..a786377c038a1ef9b5ec0e65b798b50b5c002817 100644 (file)
@@ -107,8 +107,7 @@ hoist_edge_and_branch_if_true (gimple_stmt_iterator *gsip,
   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 void *p2)
   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, struct switch_conv_info *info)
     = 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, struct switch_conv_info *info)
   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, struct switch_conv_info *info)
     {
       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 op0, tree op1, basic_block label_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;
 }
@@ -2293,12 +2286,10 @@ emit_cmp_and_jump_insns (basic_block bb, tree op0, tree op1,
   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 c4b8cee4d27738a663d08a09ad0af28b5218ed45..9bcd1d6890ae68e7d7e572116022dd9606ff732a 100644 (file)
@@ -807,7 +807,6 @@ adjust_return_value (basic_block bb, tree m, tree a)
 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, profile_count count, int frequency)
       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 910334f664e6737a5225de9add3235e382b13e61..d4c233e0b5a1f4494860fbf9e25ea65dbd4bce18 100644 (file)
@@ -563,13 +563,10 @@ slpeel_add_loop_guard (basic_block guard_bb, tree cond,
   /* 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_vinfo, tree niters, tree nitersm1,
             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 bf49e26e2a67ca168cece33f42052789b4705bcc..7a0f9d5ad07a1968ea1a2af0372e59e6b52a4343 100644 (file)
@@ -7224,7 +7224,7 @@ scale_profile_for_vect_loop (struct loop *loop, unsigned vf)
   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 *loop, unsigned vf)
       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 a73061b6ae2c563432ea0617ce980e80dbf8551e..a6d446a69a84671afcf720ce4e5d3b09ee913cc0 100644 (file)
@@ -813,7 +813,6 @@ ubsan_expand_null_ifn (gimple_stmt_iterator *gsip)
   /* 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_iterator *gsip)
          /* 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_iterator *gsip)
   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_iterator *gsip)
     }
   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_iterator *gsip)
       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 23b8dc26471c6c38c270a9d1777b6eea8d6db80e..704900f9e8d4746a9afa26804a5ded0c3e4f26c8 100644 (file)
@@ -745,20 +745,16 @@ gimple_divmod_fixed_value (gassign *stmt, tree value, profile_probability prob,
   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_probability prob, gcov_type count, gcov_
   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, profile_probability prob1,
   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 cgraph_node *direct_call,
       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 cgraph_node *direct_call,
 
   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 cgraph_node *direct_call,
       {
        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 *vcall_stmt, tree icall_size, profile_probabi
 
   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)