GCC Middle and Back End API Reference
|
#include <profile-count.h>
Static Public Member Functions | |
static profile_probability | never () |
static profile_probability | guessed_never () |
static profile_probability | very_unlikely () |
static profile_probability | unlikely () |
static profile_probability | even () |
static profile_probability | very_likely () |
static profile_probability | likely () |
static profile_probability | guessed_always () |
static profile_probability | always () |
static profile_probability | uninitialized () |
static profile_probability | from_reg_br_prob_base (int v) |
static profile_probability | from_reg_br_prob_note (int v) |
static profile_probability | probability_in_gcov_type (gcov_type val1, gcov_type val2) |
static profile_probability | stream_in (class lto_input_block *) |
Private Attributes | |
uint32_t | m_val: 29 |
enum profile_quality | m_quality: 3 |
Static Private Attributes | |
static const int | n_bits = 29 |
static const uint32_t | max_probability = (uint32_t) 1 << (n_bits - 2) |
static const uint32_t | uninitialized_probability = ((uint32_t) 1 << (n_bits - 1)) - 1 |
Friends | |
struct | profile_count |
Data type to hold probabilities. It implements fixed point arithmetics with capping so probability is always in range [0,1] and scaling requiring values greater than 1 needs to be represented otherwise. In addition to actual value the quality of profile is tracked and propagated through all operations. Special value UNINITIALIZED_PROFILE is used for probabilities that has not been determined yet (for example because of -fno-guess-branch-probability) Typically probabilities are derived from profile feedback (via probability_in_gcov_type), autoFDO or guessed statically and then propagated thorough the compilation. Named probabilities are available: - never (0 probability) - guessed_never - very_unlikely (1/2000 probability) - unlikely (1/5 probability) - even (1/2 probability) - likely (4/5 probability) - very_likely (1999/2000 probability) - guessed_always - always Named probabilities except for never/always are assumed to be statically guessed and thus not necessarily accurate. The difference between never and guessed_never is that the first one should be used only in case that well behaving program will very likely not execute the "never" path. For example if the path is going to abort () call or it exception handling. Always and guessed_always probabilities are symmetric. For legacy code we support conversion to/from REG_BR_PROB_BASE based fixpoint integer arithmetics. Once the code is converted to branch probabilities, these conversions will probably go away because they are lossy.
|
inline |
|
inline |
|
inline |
References ADJUSTED, initialized_p(), and m_quality.
Referenced by ipa_profile().
|
inline |
|
inlinestatic |
References m_quality, m_val, max_probability, and PRECISE.
Referenced by profile_count::apply_probability(), rt_bb_visited::check(), check_bb_profile(), cleanup_empty_eh_move_lp(), combine_predictions_for_bb(), combine_predictions_for_insn(), compute_outgoing_frequencies(), copy_cfg_body(), determine_unlikely_bbs(), do_split_loop_on_cond(), duplicate_loop_body_to_header_edge(), back_jt_path_registry::duplicate_thread_path(), tree_switch_conversion::bit_test_cluster::emit(), tree_switch_conversion::jump_table_cluster::emit(), estimate_bb_frequencies(), execute_sm_if_changed(), expand_omp_taskloop_for_inner(), expand_omp_taskloop_for_outer(), expand_thunk(), expand_transaction(), fold_loop_internal_call(), force_edge_cold(), force_nonfallthru_and_redirect(), tree_switch_conversion::switch_conversion::gen_inbound_check(), get_cond_branch_to_split_loop(), gimple_divmod_fixed_value(), gimple_ic(), gimple_mod_pow2(), gimple_mod_subtract(), gimple_stringop_fixed_value(), hoist_guard(), init_lowered_empty_function(), insert_check_and_trap(), rt_bb_visited::insert_exit_check_on_edge(), invert(), likely(), lower_resx(), make_single_succ_edge(), pow(), profile_count::probability_in(), purge_dead_edges(), remove_ctrl_stmt_and_useless_edges(), remove_dead_stmt(), remove_exits_and_undefined_stmts(), replace_phi_edge_with_variable(), scale_loop_profile(), scale_profile_for_vect_loop(), select_best_block(), set_edge_probability_and_rescale_others(), set_even_probabilities(), shrink_wrap_one_built_in_call_with_conds(), split(), split_edge(), split_loop(), sqrt(), tree_transform_and_unroll_loop(), try_redirect_by_replacing_jump(), try_unroll_loop_completely(), unroll_loop_runtime_iterations(), update_profile(), update_profile_after_ch(), update_profile_after_ifcombine(), vect_do_peeling(), vect_loop_versioning(), version_loop_for_if_conversion(), and very_likely().
References m_val, max_probability, RDIV, and uninitialized().
|
inline |
References ADJUSTED, initialized_p(), m_quality, m_val, max_probability, MIN, never(), safe_scale_64bit(), and uninitialized().
Referenced by do_compare_rtx_and_jump(), duplicate_loop_body_to_header_edge(), tree_switch_conversion::jump_table_cluster::emit(), execute_sm_if_changed(), expand_omp_for_generic(), expand_omp_for_static_nochunk(), expand_omp_simd(), extract_omp_for_update_vars(), operator*(), operator*=(), operator/(), operator/=(), set_edge_probability_and_rescale_others(), tree_transform_and_unroll_loop(), update_bb_profile_for_threading(), vect_do_peeling(), and version_loop_by_alias_check().
|
inline |
References ADJUSTED, gcc_checking_assert, initialized_p(), m_quality, m_val, max_probability, MIN, never(), safe_scale_64bit(), and uninitialized().
profile_probability profile_probability::combine_with_count | ( | profile_count | count1, |
profile_probability | other, | ||
profile_count | count2 ) const |
COUNT1 times event happens with *THIS probability, COUNT2 times OTHER happens with COUNT2 probability. Return probability that either *THIS or OTHER happens.
References even(), profile_count::nonzero_p(), profile_count::probability_in(), and profile_count::zero().
void profile_probability::debug | ( | ) | const |
Dump THIS to stderr.
References dump().
bool profile_probability::differs_from_p | ( | profile_probability | other | ) | const |
Return true if THIS differs from OTHER; tolerate small differences.
References initialized_p(), m_val, and max_probability.
Referenced by check_bb_profile().
bool profile_probability::differs_lot_from_p | ( | profile_probability | other | ) | const |
Return true if THIS differs significantly from OTHER.
References initialized_p(), m_val, and max_probability.
void profile_probability::dump | ( | char * | buffer | ) | const |
Output THIS to BUFFER.
References ADJUSTED, AFDO, GUESSED, initialized_p(), m_quality, m_val, and max_probability.
void profile_probability::dump | ( | FILE * | f | ) | const |
Dump THIS to F.
References dump().
Referenced by check_bb_profile(), debug(), dump(), tree_switch_conversion::switch_decision_tree::dump_case_nodes(), outgoing_edges_match(), scale_loop_profile(), and update_bb_profile_for_threading().
|
inlinestatic |
References guessed_always().
Referenced by branch_fixup(), combine_with_count(), create_empty_loop_on_edge(), do_compare_rtx_and_jump(), do_jump_1(), tree_switch_conversion::switch_conversion::exp_index_transform(), expand_addsub_overflow(), expand_complex_div_wide(), expand_mul_overflow(), expand_oacc_for(), expand_transaction(), fixup_reorder_chain(), gimple_lower_bitint(), gimple_mod_subtract_transform(), cgraph_edge::redirect_call_stmt_to_callee(), try_store_by_multiple_pieces(), ubsan_expand_ptr_ifn(), update_profile_after_ifcombine(), and value_replacement().
|
inlinestatic |
References gcc_checking_assert, GUESSED, m_quality, m_val, max_probability, RDIV, and REG_BR_PROB_BASE.
Referenced by combine_predictions_for_bb(), combine_predictions_for_insn(), ipa_profile(), and set_even_probabilities().
|
inlinestatic |
References m_quality, and m_val.
Referenced by br_prob_note_reliable_p(), combine_predictions_for_insn(), compute_outgoing_frequencies(), cond_exec_process_if_block(), dead_or_predicable(), fixup_reorder_chain(), force_nonfallthru_and_redirect(), invert_br_probabilities(), mostly_true_jump(), purge_dead_edges(), to_reg_br_prob_note(), and try_split().
|
inline |
References GUESSED, and m_quality.
Referenced by expand_oacc_for(), expand_omp_for_init_counts(), expand_omp_for_init_vars(), set_edge_probability_and_rescale_others(), simd_clone_adjust(), and update_bb_profile_for_threading().
|
inlinestatic |
References GUESSED, m_quality, m_val, and max_probability.
Referenced by asan_clear_shadow(), compute_branch_probabilities(), do_compare_rtx_and_jump(), emit_block_cmp_via_loop(), emit_block_move_via_loop(), emit_block_move_via_oriented_loop(), even(), execute_sm_if_changed(), expand_omp_atomic_pipeline(), expand_omp_for_generic(), expand_omp_for_ordered_loops(), expand_omp_for_static_nochunk(), expand_omp_ordered_sink(), expand_omp_simd(), expand_thunk(), extract_omp_for_update_vars(), tree_transform_and_unroll_loop(), unlikely(), vect_do_peeling(), version_loop_by_alias_check(), and very_unlikely().
|
inlinestatic |
References GUESSED, m_quality, and m_val.
Referenced by add_test(), better_edge_p(), create_parallel_loop(), expand_compare_and_swap_loop(), expand_omp_atomic_pipeline(), gimple_flow_call_edges_add(), oacc_entry_exit_single_gang(), rtl_flow_call_edges_add(), simd_clone_adjust(), and split_bb_make_tm_edge().
|
inline |
References m_val, and uninitialized_probability.
Referenced by adjusted(), profile_count::apply_probability(), apply_scale(), apply_scale(), tree_switch_conversion::switch_decision_tree::balance_case_nodes(), better_edge_p(), cheap_bb_rtx_cost_p(), compare_and_jump_seq(), cond_exec_process_insns(), differs_from_p(), differs_lot_from_p(), do_jump_1(), dump(), dump_probability(), tree_switch_conversion::bit_test_cluster::emit(), emit_cmp_and_jump_insn_1(), execute_sm_if_changed(), find_traces_1_round(), nonzero_p(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), operator<(), operator<=(), operator>(), operator>=(), pow(), probably_reliable_p(), cgraph_edge::redirect_call_stmt_to_callee(), sanitize_hot_paths(), split_loop(), sqrt(), profile_count::to_frequency(), to_reg_br_prob_base(), to_reg_br_prob_note(), to_sreal(), try_split(), update_profile(), and vect_do_peeling().
|
inline |
References always().
Referenced by add_test(), combine_predictions_for_insn(), cond_exec_process_if_block(), create_cond_insert_point(), dead_or_predicable(), do_compare_rtx_and_jump(), do_jump(), do_jump_1(), do_jump_by_parts_greater_rtx(), tree_switch_conversion::switch_decision_tree::do_jump_if_equal(), tree_switch_conversion::bit_test_cluster::emit(), tree_switch_conversion::jump_table_cluster::emit(), tree_switch_conversion::switch_decision_tree::emit_cmp_and_jump_insns(), execute_sm_if_changed(), expand_omp_for_generic(), expand_omp_for_init_counts(), expand_omp_for_init_vars(), expand_omp_ordered_sink(), expand_omp_simd(), find_if_case_1(), find_if_case_2(), tree_switch_conversion::switch_conversion::gen_inbound_check(), gimple_divmod_fixed_value(), gimple_ic(), gimple_mod_pow2(), gimple_mod_subtract(), gimple_stringop_fixed_value(), invert_br_probabilities(), jumpifnot(), jumpifnot_1(), outgoing_edges_match(), set_edge_probability_and_rescale_others(), set_even_probabilities(), slpeel_add_loop_guard(), split(), split_loop(), tree_transform_and_unroll_loop(), tree_unswitch_loop(), unroll_loop_runtime_iterations(), update_bb_profile_for_threading(), vect_do_peeling(), vect_loop_versioning(), and version_loop_by_alias_check().
|
inlinestatic |
References always(), and unlikely().
Referenced by tree_switch_conversion::jump_table_cluster::emit(), expand_oacc_for(), expand_omp_for_init_counts(), expand_omp_for_init_vars(), expand_transaction(), gen_parallel_loop(), optimize_mask_stores(), simd_clone_adjust(), try_store_by_multiple_pieces(), vect_loop_versioning(), worker_single_copy(), and worker_single_simple().
|
inlinestatic |
References m_quality, m_val, and PRECISE.
Referenced by profile_count::apply_probability(), apply_scale(), apply_scale(), tree_switch_conversion::switch_decision_tree::balance_case_nodes(), rt_bb_visited::check(), check_bb_profile(), combine_predictions_for_bb(), compute_branch_probabilities(), connect_infinite_loops_to_exit(), copy_edges_for_bb(), determine_unlikely_bbs(), tree_switch_conversion::bit_test_cluster::emit(), tree_switch_conversion::jump_table_cluster::emit(), emit_case_dispatch_table(), tree_switch_conversion::switch_decision_tree::emit_case_nodes(), expand_gimple_tailcall(), fold_loop_internal_call(), force_edge_cold(), get_outgoing_edge_probs(), gimple_divmod_fixed_value_transform(), gimple_mod_pow2_value_transform(), gimple_mod_subtract_transform(), gimple_stringops_transform(), tree_switch_conversion::group_cluster::group_cluster(), gsi_insert_finally_seq_after_call(), hoist_guard(), insert_check_and_trap(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), profile_count::probability_in(), sanitize_hot_paths(), set_edge_probability_and_rescale_others(), set_even_probabilities(), sqrt(), tree_transform_and_unroll_loop(), unlikely_executed_edge_p(), unloop_loops(), update_profile_after_ch(), and update_profile_after_ifcombine().
|
inline |
References initialized_p(), and m_val.
Referenced by pow().
|
inline |
References ADJUSTED, initialized_p(), m_quality, m_val, max_probability, MIN, never(), RDIV, and uninitialized().
|
inline |
References apply_scale().
|
inline |
References ADJUSTED, initialized_p(), m_quality, m_val, max_probability, MIN, never(), RDIV, and uninitialized().
|
inline |
References apply_scale().
|
inline |
References initialized_p(), m_quality, m_val, max_probability, MIN, never(), and uninitialized().
|
inline |
References initialized_p(), m_quality, m_val, max_probability, MIN, never(), and uninitialized().
|
inline |
References initialized_p(), m_quality, m_val, MIN, never(), and uninitialized().
|
inline |
References initialized_p(), m_quality, m_val, MIN, never(), and uninitialized().
|
inline |
References ADJUSTED, gcc_checking_assert, GUESSED, initialized_p(), m_quality, m_val, max_probability, MIN, never(), RDIV, and uninitialized().
|
inline |
References apply_scale().
|
inline |
References ADJUSTED, gcc_checking_assert, GUESSED, initialized_p(), m_quality, m_val, max_probability, MIN, never(), RDIV, and uninitialized().
|
inline |
References apply_scale().
|
inline |
References initialized_p(), and m_val.
|
inline |
References initialized_p(), and m_val.
|
inline |
|
inline |
References initialized_p(), and m_val.
|
inline |
References initialized_p(), and m_val.
profile_probability profile_probability::pow | ( | int | n | ) | const |
Compute n-th power of THIS.
References always(), initialized_p(), and nonzero_p().
|
inlinestatic |
References gcc_checking_assert, m_quality, m_val, max_probability, PRECISE, and safe_scale_64bit().
Referenced by adjust_cfg_counts(), compute_branch_probabilities(), gimple_divmod_fixed_value_transform(), gimple_mod_pow2_value_transform(), gimple_mod_subtract_transform(), and gimple_stringops_transform().
|
inline |
References ADJUSTED, initialized_p(), m_quality, m_val, and max_probability.
Referenced by br_prob_note_reliable_p().
|
inline |
References m_quality.
|
inline |
References ADJUSTED, and m_quality.
Referenced by get_cond_branch_to_split_loop().
|
inline |
References always(), and invert().
Referenced by do_compare_rtx_and_jump(), and do_jump_1().
profile_probability profile_probability::sqrt | ( | ) | const |
Compute square root.
References ADJUSTED, always(), initialized_p(), m_quality, m_val, max_probability, MIN, never(), and RDIV.
Referenced by vect_loop_versioning().
|
static |
Stream THIS from IB.
References m_quality, m_val, and streamer_read_uhwi().
Referenced by input_cfg().
void profile_probability::stream_out | ( | struct lto_output_stream * | ob | ) |
Stream THIS to OB.
References m_quality, m_val, and streamer_write_uhwi_stream().
void profile_probability::stream_out | ( | struct output_block * | ob | ) |
Stream THIS to OB.
References m_quality, m_val, and streamer_write_uhwi().
|
inline |
References gcc_checking_assert, initialized_p(), m_val, max_probability, RDIV, and REG_BR_PROB_BASE.
Referenced by cheap_bb_rtx_cost_p(), check_bb_profile(), dump_probability(), find_traces_1_round(), mostly_true_jump(), and profile_count::to_frequency().
|
inline |
References from_reg_br_prob_note(), gcc_checking_assert, initialized_p(), m_quality, and m_val.
Referenced by add_reg_br_prob_note(), cond_exec_process_insns(), and invert_br_probabilities().
sreal profile_probability::to_sreal | ( | ) | const |
Return probability as sreal in range [0, 1].
References gcc_checking_assert, initialized_p(), m_val, and n_bits.
Referenced by good_cloning_opportunity_p(), and split_loop().
|
inlinestatic |
References GUESSED, m_quality, m_val, and uninitialized_probability.
Referenced by apply(), apply_scale(), apply_scale(), compare_and_jump_seq(), cond_exec_process_if_block(), dead_or_predicable(), do_cmp_and_jump(), do_jump(), do_jump_1(), emit_store_flag_force(), execute_sm_if_changed(), expand_abs(), expand_doubleword_shift(), expand_expr_real_1(), expand_expr_real_2(), expand_sjlj_dispatch_table(), find_traces_1_round(), compare_by_pieces_d::finish_mode(), compare_by_pieces_d::generate(), init_emit_regs(), if_chain::is_beneficial(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), profile_count::probability_in(), rtl_lv_add_condition_to_bb(), sanitize_hot_paths(), store_constructor(), store_expr(), try_split(), and unchecked_make_edge().
|
inlinestatic |
References guessed_always(), m_val, and r.
Referenced by expand_mul_overflow(), expand_oacc_for(), expand_omp_for_init_counts(), expand_omp_for_init_vars(), expand_transaction(), gen_parallel_loop(), gimple_gen_ic_func_profiler(), gimple_gen_time_profiler(), likely(), simd_clone_adjust(), sjlj_emit_function_enter(), and worker_single_copy().
|
inline |
References m_val.
|
inline |
References gcc_checking_assert, GUESSED, m_quality, m_val, max_probability, uninitialized_probability, and UNINITIALIZED_PROFILE.
|
inlinestatic |
References always(), and very_unlikely().
Referenced by asan_emit_stack_protection(), connect_loops(), create_cond_insert_point(), emit_likely_jump_insn(), expand_addsub_overflow(), expand_arith_overflow_result_store(), expand_builtin_strub_leave(), expand_builtin_strub_update(), expand_mul_overflow(), expand_neg_overflow(), expand_omp_for_init_vars(), expand_omp_for_static_chunk(), expand_omp_for_static_nochunk(), expand_transaction(), expand_vector_ubsan_overflow(), gimple_gen_ic_func_profiler(), split_loop(), ubsan_expand_null_ifn(), and ubsan_expand_ptr_ifn().
|
inlinestatic |
References guessed_always(), m_val, and r.
Referenced by asan_emit_stack_protection(), create_cond_insert_point(), emit_unlikely_jump_insn(), expand_addsub_overflow(), expand_complex_multiplication(), expand_mul_overflow(), expand_neg_overflow(), expand_omp_for_init_counts(), expand_omp_for_init_vars(), expand_omp_for_static_chunk(), expand_omp_for_static_nochunk(), expand_ubsan_result_store(), force_edge_cold(), set_even_probabilities(), shrink_wrap_one_built_in_call_with_conds(), single_likely_exit(), ubsan_expand_null_ifn(), ubsan_expand_ptr_ifn(), and very_likely().
|
friend |
|
private |
Referenced by adjusted(), afdo(), always(), profile_count::apply_probability(), apply_scale(), apply_scale(), dump(), from_reg_br_prob_base(), from_reg_br_prob_note(), guessed(), guessed_always(), guessed_never(), never(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), operator==(), profile_count::probability_in(), probability_in_gcov_type(), probably_reliable_p(), quality(), reliable_p(), sqrt(), stream_in(), stream_out(), stream_out(), to_reg_br_prob_note(), uninitialized(), and verify().
|
private |
Referenced by always(), apply(), profile_count::apply_probability(), apply_scale(), apply_scale(), differs_from_p(), differs_lot_from_p(), dump(), from_reg_br_prob_base(), from_reg_br_prob_note(), guessed_always(), guessed_never(), initialized_p(), never(), nonzero_p(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), profile_count::probability_in(), probability_in_gcov_type(), probably_reliable_p(), sqrt(), stream_in(), stream_out(), stream_out(), to_reg_br_prob_base(), to_reg_br_prob_note(), to_sreal(), uninitialized(), unlikely(), value(), verify(), and very_unlikely().
|
staticprivate |
Referenced by always(), apply(), profile_count::apply_probability(), apply_scale(), apply_scale(), differs_from_p(), differs_lot_from_p(), dump(), from_reg_br_prob_base(), guessed_always(), operator*(), operator*=(), operator+(), operator+=(), operator/(), operator/=(), profile_count::probability_in(), probability_in_gcov_type(), probably_reliable_p(), sqrt(), to_reg_br_prob_base(), and verify().
|
staticprivate |
Referenced by to_sreal().
|
staticprivate |
Referenced by initialized_p(), uninitialized(), and verify().