diff options
author | Jan Hubicka <hubicka@ucw.cz> | 2017-06-29 18:40:53 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2017-06-29 16:40:53 +0000 |
commit | 357067f243611b9e29367b61a50efe2e78f693c9 (patch) | |
tree | 45e6fed3d816c143ade1663a45c34681cee487a0 /gcc/stmt.c | |
parent | fac877a14ab52fcf94b260112cd133aa80b349b2 (diff) | |
download | gcc-357067f243611b9e29367b61a50efe2e78f693c9.zip gcc-357067f243611b9e29367b61a50efe2e78f693c9.tar.gz gcc-357067f243611b9e29367b61a50efe2e78f693c9.tar.bz2 |
asan.c (asan_emit_stack_protection): Update.
* asan.c (asan_emit_stack_protection): Update.
(create_cond_insert_point): Update.
* auto-profile.c (afdo_propagate_circuit): Update.
* basic-block.h (struct edge_def): Turn probability to
profile_probability.
(EDGE_FREQUENCY): Update.
* bb-reorder.c (find_traces_1_round): Update.
(better_edge_p): Update.
(sanitize_hot_paths): Update.
* cfg.c (unchecked_make_edge): Initialize probability to uninitialized.
(make_single_succ_edge): Update.
(check_bb_profile): Update.
(dump_edge_info): Update.
(update_bb_profile_for_threading): Update.
* cfganal.c (connect_infinite_loops_to_exit): Initialize new edge
probabilitycount to 0.
* cfgbuild.c (compute_outgoing_frequencies): Update.
* cfgcleanup.c (try_forward_edges): Update.
(outgoing_edges_match): Update.
(try_crossjump_to_edge): Update.
* cfgexpand.c (expand_gimple_cond): Update make_single_succ_edge.
(expand_gimple_tailcall): Update.
(construct_init_block): Use make_single_succ_edge.
(construct_exit_block): Use make_single_succ_edge.
* cfghooks.c (verify_flow_info): Update.
(redirect_edge_succ_nodup): Update.
(split_edge): Update.
(account_profile_record): Update.
* cfgloopanal.c (single_likely_exit): Update.
* cfgloopmanip.c (scale_loop_profile): Update.
(set_zero_probability): Remove.
(duplicate_loop_to_header_edge): Update.
* cfgloopmanip.h (loop_version): Update prototype.
* cfgrtl.c (try_redirect_by_replacing_jump): Update.
(force_nonfallthru_and_redirect): Update.
(update_br_prob_note): Update.
(rtl_verify_edges): Update.
(purge_dead_edges): Update.
(rtl_lv_add_condition_to_bb): Update.
* cgraph.c: (cgraph_edge::redirect_call_stmt_to_calle): Update.
* cgraphunit.c (init_lowered_empty_function): Update.
(cgraph_node::expand_thunk): Update.
* cilk-common.c: Include profile-count.h
* dojump.c (inv): Remove.
(jumpifnot): Update.
(jumpifnot_1): Update.
(do_jump_1): Update.
(do_jump): Update.
(do_jump_by_parts_greater_rtx): Update.
(do_compare_rtx_and_jump): Update.
* dojump.h (jumpifnot, jumpifnot_1, jumpif_1, jumpif, do_jump,
do_jump_1. do_compare_rtx_and_jump): Update prototype.
* dwarf2cfi.c: Include profile-count.h
* except.c (dw2_build_landing_pads): Use make_single_succ_edge.
(sjlj_emit_dispatch_table): Likewise.
* explow.c: Include profile-count.h
* expmed.c (emit_store_flag_force): Update.
(do_cmp_and_jump): Update.
* expr.c (compare_by_pieces_d::generate): Update.
(compare_by_pieces_d::finish_mode): Update.
(emit_block_move_via_loop): Update.
(store_expr_with_bounds): Update.
(store_constructor): Update.
(expand_expr_real_2): Update.
(expand_expr_real_1): Update.
* expr.h (try_casesi, try_tablejump): Update prototypes.
* gimple-pretty-print.c (dump_probability): Update.
(dump_profile): New.
(dump_gimple_label): Update.
(dump_gimple_bb_header): Update.
* graph.c (draw_cfg_node_succ_edges): Update.
* hsa-gen.c (convert_switch_statements): Update.
* ifcvt.c (cheap_bb_rtx_cost_p): Update.
(find_if_case_1): Update.
(find_if_case_2): Update.
* internal-fn.c (expand_arith_overflow_result_store): Update.
(expand_addsub_overflow): Update.
(expand_neg_overflow): Update.
(expand_mul_overflow): Update.
(expand_vector_ubsan_overflow): Update.
* ipa-cp.c (good_cloning_opportunity_p): Update.
* ipa-split.c (split_function): Use make_single_succ_edge.
* ipa-utils.c (ipa_merge_profiles): Update.
* loop-doloop.c (add_test): Update.
(doloop_modify): Update.
* loop-unroll.c (compare_and_jump_seq): Update.
(unroll_loop_runtime_iterations): Update.
* lra-constraints.c (lra_inheritance): Update.
* lto-streamer-in.c (input_cfg): Update.
* lto-streamer-out.c (output_cfg): Update.
* mcf.c (adjust_cfg_counts): Update.
* modulo-sched.c (sms_schedule): Update.
* omp-expand.c (expand_omp_for_init_counts): Update.
(extract_omp_for_update_vars): Update.
(expand_omp_ordered_sink): Update.
(expand_omp_for_ordered_loops): Update.
(expand_omp_for_generic): Update.
(expand_omp_for_static_nochunk): Update.
(expand_omp_for_static_chunk): Update.
(expand_cilk_for): Update.
(expand_omp_simd): Update.
(expand_omp_taskloop_for_outer): Update.
(expand_omp_taskloop_for_inner): Update.
* omp-simd-clone.c (simd_clone_adjust): Update.
* optabs.c (expand_doubleword_shift): Update.
(expand_abs): Update.
(emit_cmp_and_jump_insn_1): Update.
(expand_compare_and_swap_loop): Update.
* optabs.h (emit_cmp_and_jump_insns): Update prototype.
* predict.c (predictable_edge_p): Update.
(edge_probability_reliable_p): Update.
(set_even_probabilities): Update.
(combine_predictions_for_insn): Update.
(combine_predictions_for_bb): Update.
(propagate_freq): Update.
(estimate_bb_frequencies): Update.
(force_edge_cold): Update.
* profile-count.c (profile_count::dump): Add missing space into dump.
(profile_count::debug): Add newline.
(profile_count::differs_from_p): Explicitly convert to unsigned.
(profile_count::stream_in): Update.
(profile_probability::dump): New member function.
(profile_probability::debug): New member function.
(profile_probability::differs_from_p): New member function.
(profile_probability::differs_lot_from_p): New member function.
(profile_probability::stream_in): New member function.
(profile_probability::stream_out): New member function.
* profile-count.h (profile_count_quality): Rename to ...
(profile_quality): ... this one.
(profile_probability): New.
(profile_count): Update.
* profile.c (compute_branch_probabilities): Update.
* recog.c (peep2_attempt): Update.
* sched-ebb.c (schedule_ebbs): Update.
* sched-rgn.c (find_single_block_region): Update.
(compute_dom_prob_ps): Update.
(schedule_region): Update.
* sel-sched-ir.c (compute_succs_info): Update.
* stmt.c (struct case_node): Update.
(do_jump_if_equal): Update.
(get_outgoing_edge_probs): Update.
(conditional_probability): Update.
(emit_case_dispatch_table): Update.
(expand_case): Update.
(expand_sjlj_dispatch_table): Update.
(emit_case_nodes): Update.
* targhooks.c: Update.
* tracer.c (better_p): Update.
(find_best_successor): Update.
* trans-mem.c (expand_transaction): Update.
* tree-call-cdce.c: Update.
* tree-cfg.c (gimple_split_edge): Upate.
(move_sese_region_to_fn): Upate.
* tree-cfgcleanup.c (cleanup_control_expr_graph): Upate.
* tree-eh.c (lower_resx): Upate.
(cleanup_empty_eh_move_lp): Upate.
* tree-if-conv.c (version_loop_for_if_conversion): Update.
* tree-inline.c (copy_edges_for_bb): Update.
(copy_cfg_body): Update.
* tree-parloops.c (gen_parallel_loop): Update.
* tree-profile.c (gimple_gen_ic_func_profiler): Update.
(gimple_gen_time_profiler): 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.
(try_peel_loop): 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 (tree_unswitch_loop): Update.
(hoist_guard): Update.
* tree-ssa-phionlycprop.c (propagate_rhs_into_lhs): Update.
* tree-ssa-phiopt.c (replace_phi_edge_with_variable): Update.
(value_replacement): 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.
(create_edge_and_update_destination_phis): Update.
(compute_path_counts): Update.
(recompute_probabilities): Update.
(update_joiner_offpath_counts): Update.
(freqs_to_counts_path): Update.
(duplicate_thread_path): Update.
* tree-switch-conversion.c (hoist_edge_and_branch_if_true): Update.
(struct switch_conv_info): Update.
(gen_inbound_check): Update.
* tree-vect-loop-manip.c (slpeel_add_loop_guard): Update.
(vect_do_peeling): Update.
(vect_loop_versioning): Update.
* tree-vect-loop.c (scale_profile_for_vect_loop): Update.
(optimize_mask_stores): Update.
* ubsan.c (ubsan_expand_null_ifn): Update.
* value-prof.c (gimple_divmod_fixed_value): Update.
(gimple_divmod_fixed_value_transform): Update.
(gimple_mod_pow2): Update.
(gimple_mod_pow2_value_transform): Update.
(gimple_mod_subtract): Update.
(gimple_mod_subtract_transform): Update.
(gimple_ic): Update.
(gimple_stringop_fixed_value): Update.
(gimple_stringops_transform): Update.
* value-prof.h: Update.
From-SVN: r249800
Diffstat (limited to 'gcc/stmt.c')
-rw-r--r-- | gcc/stmt.c | 95 |
1 files changed, 48 insertions, 47 deletions
@@ -93,9 +93,9 @@ struct case_node tree low; /* Lowest index value for this label */ tree high; /* Highest index value for this label */ tree code_label; /* Label to jump to when node matches */ - int prob; /* Probability of taking this case. */ + profile_probability prob; /* Probability of taking this case. */ /* Probability of reaching subtree rooted at this node */ - int subtree_prob; + profile_probability subtree_prob; }; typedef struct case_node *case_node_ptr; @@ -108,7 +108,8 @@ static void balance_case_nodes (case_node_ptr *, case_node_ptr); static int node_has_low_bound (case_node_ptr, tree); static int node_has_high_bound (case_node_ptr, tree); static int node_is_bounded (case_node_ptr, tree); -static void emit_case_nodes (rtx, case_node_ptr, rtx_code_label *, int, tree); +static void emit_case_nodes (rtx, case_node_ptr, rtx_code_label *, + profile_probability, tree); /* Return the rtx-label that corresponds to a LABEL_DECL, creating it if necessary. */ @@ -704,9 +705,8 @@ expand_naked_return (void) is the probability of jumping to LABEL. */ static void do_jump_if_equal (machine_mode mode, rtx op0, rtx op1, rtx_code_label *label, - int unsignedp, int prob) + int unsignedp, profile_probability prob) { - gcc_assert (prob <= REG_BR_PROB_BASE); do_compare_rtx_and_jump (op0, op1, EQ, unsignedp, mode, NULL_RTX, NULL, label, prob); } @@ -722,7 +722,7 @@ do_jump_if_equal (machine_mode mode, rtx op0, rtx op1, rtx_code_label *label, static struct case_node * add_case_node (struct case_node *head, tree low, tree high, - tree label, int prob, + tree label, profile_probability prob, object_allocator<case_node> &case_node_pool) { struct case_node *r; @@ -859,7 +859,7 @@ expand_switch_as_decision_tree_p (tree range, static void emit_case_decision_tree (tree index_expr, tree index_type, case_node_ptr case_list, rtx_code_label *default_label, - int default_prob) + profile_probability default_prob) { rtx index = expand_normal (index_expr); @@ -902,14 +902,14 @@ emit_case_decision_tree (tree index_expr, tree index_type, /* Return the sum of probabilities of outgoing edges of basic block BB. */ -static int +static profile_probability get_outgoing_edge_probs (basic_block bb) { edge e; edge_iterator ei; - int prob_sum = 0; + profile_probability prob_sum = profile_probability::never (); if (!bb) - return 0; + return profile_probability::never (); FOR_EACH_EDGE (e, ei, bb->succs) prob_sum += e->probability; return prob_sum; @@ -922,16 +922,11 @@ get_outgoing_edge_probs (basic_block bb) BASE_PROB is the probability of reaching the branch instruction relative to the same basic block BB. */ -static inline int -conditional_probability (int target_prob, int base_prob) +static inline profile_probability +conditional_probability (profile_probability target_prob, + profile_probability base_prob) { - if (base_prob > 0) - { - gcc_assert (target_prob >= 0); - gcc_assert (target_prob <= base_prob); - return GCOV_COMPUTE_SCALE (target_prob, base_prob); - } - return -1; + return target_prob / base_prob; } /* Generate a dispatch tabler, switching on INDEX_EXPR and jumping to @@ -960,12 +955,13 @@ emit_case_dispatch_table (tree index_expr, tree index_type, rtx_code_label *table_label = gen_label_rtx (); bool has_gaps = false; edge default_edge = stmt_bb ? EDGE_SUCC (stmt_bb, 0) : NULL; - int default_prob = default_edge ? default_edge->probability : 0; - int base = get_outgoing_edge_probs (stmt_bb); + profile_probability default_prob = default_edge ? default_edge->probability + : profile_probability::never (); + profile_probability base = get_outgoing_edge_probs (stmt_bb); bool try_with_tablejump = false; - int new_default_prob = conditional_probability (default_prob, - base); + profile_probability new_default_prob = conditional_probability (default_prob, + base); if (! try_casesi (index_type, index_expr, minval, range, table_label, default_label, fallback_label, @@ -1030,15 +1026,16 @@ emit_case_dispatch_table (tree index_expr, tree index_type, through the indirect jump or the direct conditional jump before that. Split the probability of reaching the default label among these two jumps. */ - new_default_prob = conditional_probability (default_prob/2, + new_default_prob = conditional_probability (default_prob.apply_scale + (1, 2), base); - default_prob /= 2; + default_prob = default_prob.apply_scale (1, 2); base -= default_prob; } else { base -= default_prob; - default_prob = 0; + default_prob = profile_probability::never (); } if (default_edge) @@ -1047,12 +1044,12 @@ emit_case_dispatch_table (tree index_expr, tree index_type, /* We have altered the probability of the default edge. So the probabilities of all other edges need to be adjusted so that it sums up to REG_BR_PROB_BASE. */ - if (base) + if (base > profile_probability::never ()) { edge e; edge_iterator ei; FOR_EACH_EDGE (e, ei, stmt_bb->succs) - e->probability = GCOV_COMPUTE_SCALE (e->probability, base); + e->probability /= base; } if (try_with_tablejump) @@ -1153,7 +1150,7 @@ expand_case (gswitch *stmt) default_label = jump_target_rtx (CASE_LABEL (gimple_switch_default_label (stmt))); edge default_edge = EDGE_SUCC (bb, 0); - int default_prob = default_edge->probability; + profile_probability default_prob = default_edge->probability; /* Get upper and lower bounds of case values. */ elt = gimple_switch_label (stmt, 1); @@ -1216,7 +1213,7 @@ expand_case (gswitch *stmt) edge case_edge = find_edge (bb, case_bb); case_list = add_case_node ( case_list, low, high, lab, - case_edge->probability / (intptr_t)(case_edge->aux), + case_edge->probability.apply_scale (1, (intptr_t)(case_edge->aux)), case_node_pool); } reset_out_edges_aux (bb); @@ -1313,7 +1310,8 @@ expand_sjlj_dispatch_table (rtx dispatch_index, { tree elt = dispatch_table[i]; rtx_code_label *lab = jump_target_rtx (CASE_LABEL (elt)); - do_jump_if_equal (index_mode, index, zero, lab, 0, -1); + do_jump_if_equal (index_mode, index, zero, lab, 0, + profile_probability::uninitialized ()); force_expand_binop (index_mode, sub_optab, index, CONST1_RTX (index_mode), index, 0, OPTAB_DIRECT); @@ -1335,7 +1333,10 @@ expand_sjlj_dispatch_table (rtx dispatch_index, tree elt = dispatch_table[i]; tree low = CASE_LOW (elt); tree lab = CASE_LABEL (elt); - case_list = add_case_node (case_list, low, low, lab, 0, case_node_pool); + case_list = add_case_node (case_list, low, low, lab, + profile_probability::guessed_always () + .apply_scale (1, ncases), + case_node_pool); } emit_case_dispatch_table (index_expr, index_type, @@ -1579,12 +1580,12 @@ node_is_bounded (case_node_ptr node, tree index_type) static void emit_case_nodes (rtx index, case_node_ptr node, rtx_code_label *default_label, - int default_prob, tree index_type) + profile_probability default_prob, tree index_type) { /* If INDEX has an unsigned type, we must make unsigned branches. */ int unsignedp = TYPE_UNSIGNED (index_type); - int probability; - int prob = node->prob, subtree_prob = node->subtree_prob; + profile_probability probability; + profile_probability prob = node->prob, subtree_prob = node->subtree_prob; machine_mode mode = GET_MODE (index); machine_mode imode = TYPE_MODE (index_type); @@ -1704,7 +1705,7 @@ emit_case_nodes (rtx index, case_node_ptr node, rtx_code_label *default_label, subtree or the left subtree. Divide the probability equally. */ probability = conditional_probability ( - node->right->subtree_prob + default_prob/2, + node->right->subtree_prob + default_prob.apply_scale (1, 2), subtree_prob + default_prob); /* See if the value is on the right. */ emit_cmp_and_jump_insns (index, @@ -1715,7 +1716,7 @@ emit_case_nodes (rtx index, case_node_ptr node, rtx_code_label *default_label, GT, NULL_RTX, mode, unsignedp, label_rtx (test_label), probability); - default_prob /= 2; + default_prob = default_prob.apply_scale (1, 2); /* Value must be on the left. Handle the left-hand subtree. */ @@ -1746,7 +1747,7 @@ emit_case_nodes (rtx index, case_node_ptr node, rtx_code_label *default_label, if (!node_has_low_bound (node, index_type)) { probability = conditional_probability ( - default_prob/2, + default_prob.apply_scale (1, 2), subtree_prob + default_prob); emit_cmp_and_jump_insns (index, convert_modes @@ -1756,7 +1757,7 @@ emit_case_nodes (rtx index, case_node_ptr node, rtx_code_label *default_label, LT, NULL_RTX, mode, unsignedp, default_label, probability); - default_prob /= 2; + default_prob = default_prob.apply_scale (1, 2); } emit_case_nodes (index, node->right, default_label, default_prob, index_type); @@ -1788,7 +1789,7 @@ emit_case_nodes (rtx index, case_node_ptr node, rtx_code_label *default_label, if (!node_has_high_bound (node, index_type)) { probability = conditional_probability ( - default_prob/2, + default_prob.apply_scale (1, 2), subtree_prob + default_prob); emit_cmp_and_jump_insns (index, convert_modes @@ -1798,7 +1799,7 @@ emit_case_nodes (rtx index, case_node_ptr node, rtx_code_label *default_label, GT, NULL_RTX, mode, unsignedp, default_label, probability); - default_prob /= 2; + default_prob = default_prob.apply_scale (1, 2); } emit_case_nodes (index, node->left, default_label, @@ -1861,7 +1862,7 @@ emit_case_nodes (rtx index, case_node_ptr node, rtx_code_label *default_label, test_label = build_decl (curr_insn_location (), LABEL_DECL, NULL_TREE, void_type_node); probability = conditional_probability ( - node->right->subtree_prob + default_prob/2, + node->right->subtree_prob + default_prob.apply_scale (1, 2), subtree_prob + default_prob); emit_cmp_and_jump_insns (index, convert_modes @@ -1871,7 +1872,7 @@ emit_case_nodes (rtx index, case_node_ptr node, rtx_code_label *default_label, GT, NULL_RTX, mode, unsignedp, label_rtx (test_label), probability); - default_prob /= 2; + default_prob = default_prob.apply_scale (1, 2); } /* Value belongs to this node or to the left-hand subtree. */ @@ -1912,7 +1913,7 @@ emit_case_nodes (rtx index, case_node_ptr node, rtx_code_label *default_label, if (!node_has_low_bound (node, index_type)) { probability = conditional_probability ( - default_prob/2, + default_prob.apply_scale (1, 2), subtree_prob + default_prob); emit_cmp_and_jump_insns (index, convert_modes @@ -1922,7 +1923,7 @@ emit_case_nodes (rtx index, case_node_ptr node, rtx_code_label *default_label, LT, NULL_RTX, mode, unsignedp, default_label, probability); - default_prob /= 2; + default_prob = default_prob.apply_scale (1, 2); } /* Value belongs to this node or to the right-hand subtree. */ @@ -1949,7 +1950,7 @@ emit_case_nodes (rtx index, case_node_ptr node, rtx_code_label *default_label, if (!node_has_high_bound (node, index_type)) { probability = conditional_probability ( - default_prob/2, + default_prob.apply_scale (1, 2), subtree_prob + default_prob); emit_cmp_and_jump_insns (index, convert_modes @@ -1959,7 +1960,7 @@ emit_case_nodes (rtx index, case_node_ptr node, rtx_code_label *default_label, GT, NULL_RTX, mode, unsignedp, default_label, probability); - default_prob /= 2; + default_prob = default_prob.apply_scale (1, 2); } /* Value belongs to this node or to the left-hand subtree. */ |