GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "rtl.h"
#include "tree.h"
#include "gimple.h"
#include "cfghooks.h"
#include "tree-pass.h"
#include "ssa.h"
#include "memmodel.h"
#include "emit-rtl.h"
#include "cgraph.h"
#include "coverage.h"
#include "diagnostic-core.h"
#include "gimple-predict.h"
#include "fold-const.h"
#include "calls.h"
#include "cfganal.h"
#include "profile.h"
#include "sreal.h"
#include "cfgloop.h"
#include "gimple-iterator.h"
#include "tree-cfg.h"
#include "tree-ssa-loop-niter.h"
#include "tree-ssa-loop.h"
#include "tree-scalar-evolution.h"
#include "ipa-utils.h"
#include "gimple-pretty-print.h"
#include "selftest.h"
#include "cfgrtl.h"
#include "stringpool.h"
#include "attribs.h"
#include "predict.def"
Data Structures | |
struct | predictor_info |
struct | edge_prediction |
struct | expected_value |
struct | predictor_hash |
struct | predictor_hash_traits |
class | block_info |
class | edge_prob_info |
Macros | |
#define | PRED_FLAG_FIRST_MATCH 1 |
#define | HITRATE(VAL) |
#define | DEF_PREDICTOR(ENUM, NAME, HITRATE, FLAGS) |
#define | BLOCK_INFO(B) |
#define | EDGE_INFO(E) |
Enumerations | |
enum | predictor_reason { REASON_NONE , REASON_IGNORED , REASON_SINGLE_EDGE_DUPLICATE , REASON_EDGE_PAIR_DUPLICATE } |
Variables | |
static const char * | reason_messages [] |
static const struct predictor_info | predictor_info [] |
static gcov_type | min_count = -1 |
static hash_map< const_basic_block, edge_prediction * > * | bb_predictions |
static hash_map< int_hash< unsigned, 0 >, expected_value > * | ssa_expected_value |
#define BLOCK_INFO | ( | B | ) |
Referenced by estimate_bb_frequencies(), and propagate_freq().
#define EDGE_INFO | ( | E | ) |
Referenced by adjust_cfg_counts(), branch_prob(), compute_branch_probabilities(), create_fixup_graph(), estimate_bb_frequencies(), estimate_loops_at_level(), find_spanning_tree(), get_exec_counts(), instrument_edges(), is_edge_inconsistent(), propagate_freq(), read_profile_edge_counts(), and sum_edge_counts().
#define HITRATE | ( | VAL | ) |
Recompute hitrate in percent to our representation.
Referenced by expr_expected_value_1(), predict_loops(), and tree_predict_by_opcode().
#define PRED_FLAG_FIRST_MATCH 1 |
Use given predictor without Dempster-Shaffer theory if it matches using first_match heuristics.
Referenced by combine_predictions_for_bb(), and combine_predictions_for_insn().
enum predictor_reason |
Branch prediction routines for the GNU compiler. Copyright (C) 2000-2024 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>.
References: [1] "Branch Prediction for Free" Ball and Larus; PLDI '93. [2] "Static Branch Frequency and Program Profile Analysis" Wu and Larus; MICRO-27. [3] "Corpus-based Static Branch Prediction" Calder, Grunwald, Lindsay, Martin, Mozer, and Zorn; PLDI '95.
Enum with reasons why a predictor is ignored.
Enumerator | |
---|---|
REASON_NONE | |
REASON_IGNORED | |
REASON_SINGLE_EDGE_DUPLICATE | |
REASON_EDGE_PAIR_DUPLICATE |
void add_reg_br_prob_note | ( | rtx_insn * | jump, |
profile_probability | prob ) |
Add REG_BR_PROB note to JUMP with PROB.
References add_int_reg_note(), find_reg_note(), gcc_checking_assert, JUMP_P, and profile_probability::to_reg_br_prob_note().
Referenced by asan_clear_shadow(), combine_predictions_for_insn(), compare_and_jump_seq(), doloop_modify(), emit_cmp_and_jump_insn_1(), emit_likely_jump_insn(), emit_unlikely_jump_insn(), expand_addsub_overflow(), expand_mul_overflow(), expand_neg_overflow(), and try_split().
|
static |
Find the basic block with return expression and look up for possible return value trying to apply RETURN_PREDICTION heuristics.
References as_a(), cfun, EXIT_BLOCK_PTR_FOR_FN, FOR_EACH_EDGE, gimple_phi_arg_edge(), gimple_phi_num_args(), gimple_return_retval(), gsi_last_bb(), i, INTEGRAL_TYPE_P, last, NULL, PHI_ARG_DEF, predict_paths_leading_to_edge(), r, return_prediction(), safe_dyn_cast(), SSA_NAME_DEF_STMT, TREE_CODE, TREE_TYPE, TYPE_PRECISION, TYPE_UNSIGNED, and zero_one_minusone().
Referenced by tree_bb_level_predictions().
bool assert_is_empty | ( | const_basic_block const & | , |
edge_prediction *const & | value, | ||
void * | ) |
Callback for hash_map::traverse, asserts that the pointer map is empty.
References gcc_assert.
Referenced by tree_estimate_probability(), and tree_guess_outgoing_edge_probabilities().
|
static |
Attempt to predict probabilities of BB outgoing edges using local properties.
References BB_END, can_predict_insn_p(), COMPARISON_P, const0_rtx, const1_rtx, constm1_rtx, FLOAT_MODE_P, GET_CODE, get_condition(), GET_MODE, NOT_TAKEN, NULL, predict_insn_def(), REG_P, REG_POINTER, TAKEN, and XEXP.
Referenced by guess_outgoing_edge_probabilities().
optimization_type bb_optimization_type | ( | const_basic_block | bb | ) |
Return the optimization type that should be used for basic block BB.
References optimize_bb_for_speed_p(), OPTIMIZE_FOR_SIZE, and OPTIMIZE_FOR_SPEED.
Referenced by convert_mult_to_fma(), tree_switch_conversion::switch_conversion::is_exp_index_transform_viable(), reassociate_bb(), and replacement_internal_fn().
Same predicate as edge_probability_reliable_p, working on notes.
References profile_probability::from_reg_br_prob_note(), gcc_assert, profile_probability::probably_reliable_p(), REG_NOTE_KIND, and XINT.
tree build_predict_expr | ( | enum br_predictor | predictor, |
enum prediction | taken ) |
Build PREDICT_EXPR.
References build1(), build_int_cst(), integer_type_node, SET_PREDICT_EXPR_OUTCOME, and void_type_node.
Return true when we can store prediction on insn INSN. At the moment we represent predictions only on conditional jumps, not at computed jump or other complicated cases.
References any_condjump_p(), BLOCK_FOR_INSN(), EDGE_COUNT, and JUMP_P.
Referenced by bb_estimate_probability_locally(), and combine_predictions_for_insn().
|
static |
Clears the list of predictions stored for BB.
References bb_predictions, edge_prediction::ep_next, free(), and NULL.
Referenced by combine_predictions_for_bb().
|
static |
Combine predictions into single probability and store them into CFG. Remove now useless prediction entries. If DRY_RUN is set, only produce dumps and do not modify profile.
References hash_set< KeyId, Lazy, Traits >::add(), profile_probability::always(), bb_predictions, hash_set< KeyId, Lazy, Traits >::begin(), clear_bb_predictions(), hash_set< KeyId, Lazy, Traits >::contains(), dump_file, dump_prediction(), EDGE_COUNT, hash_set< KeyId, Lazy, Traits >::empty(), hash_set< KeyId, Lazy, Traits >::end(), edge_prediction::ep_edge, edge_prediction::ep_next, edge_prediction::ep_predictor, edge_prediction::ep_probability, FOR_EACH_EDGE, profile_probability::from_reg_br_prob_base(), gcc_unreachable, basic_block_def::index, hash_set< KeyId, Lazy, Traits >::is_empty(), profile_probability::never(), NULL, PRED_FLAG_FIRST_MATCH, PROB_EVEN, PROB_VERY_LIKELY, PROB_VERY_UNLIKELY, prune_predictions_for_bb(), REASON_IGNORED, REASON_NONE, REG_BR_PROB_BASE, set_even_probabilities(), basic_block_def::succs, and unlikely_executed_edge_p().
Referenced by tree_estimate_probability(), and tree_guess_outgoing_edge_probabilities().
|
static |
Combine all REG_BR_PRED notes into single probability and attach REG_BR_PROB note if not already present. Remove now useless REG_BR_PRED notes.
References add_reg_br_prob_note(), profile_probability::always(), BRANCH_EDGE, can_predict_insn_p(), dump_file, dump_prediction(), FALLTHRU_EDGE, find_reg_note(), profile_probability::from_reg_br_prob_base(), profile_probability::from_reg_br_prob_note(), basic_block_def::index, INSN_UID(), INTVAL, profile_probability::invert(), PRED_FLAG_FIRST_MATCH, PROB_EVEN, REASON_IGNORED, REASON_NONE, REG_BR_PROB_BASE, REG_NOTE_KIND, REG_NOTES, set_even_probabilities(), single_succ_edge(), single_succ_p(), XEXP, and XINT.
Referenced by guess_outgoing_edge_probabilities().
void compute_function_frequency | ( | void | ) |
Decide whether function is hot, cold or unlikely executed.
References cfun, count, current_function_decl, DECL_ATTRIBUTES, DECL_NAME, DECL_STATIC_CONSTRUCTOR, DECL_STATIC_DESTRUCTOR, ECF_NORETURN, ENTRY_BLOCK_PTR_FOR_FN, flags_from_decl_or_type(), FOR_EACH_BB_FN, cgraph_node::frequency, cgraph_node::get(), lookup_attribute(), MAIN_NAME_P, maybe_hot_bb_p(), NODE_FREQUENCY_EXECUTED_ONCE, NODE_FREQUENCY_HOT, NODE_FREQUENCY_NORMAL, NODE_FREQUENCY_UNLIKELY_EXECUTED, NULL, cgraph_node::only_called_at_exit, cgraph_node::only_called_at_startup, probably_never_executed_bb_p(), warn_function_cold(), and profile_count::zero().
Referenced by autofdo::auto_profile(), branch_prob(), estimate_bb_frequencies(), execute_fixup_cfg(), and ipa_merge_profiles().
void default_rtl_profile | ( | void | ) |
Set RTL expansion to default mode (i.e. when profile info is not known).
References crtl.
Referenced by combine_instructions(), computation_cost(), gimplify_body(), init_expmed(), init_set_costs(), peephole2_optimize(), prepare_function_start(), split_all_insns(), and thread_prologue_and_epilogue_insns().
|
static |
Determine basic blocks/edges that are known to be unlikely executed and set their counters to zero. This is done with first identifying obviously unlikely BBs/edges and then propagating in both directions.
References profile_probability::always(), basic_block_def::aux, cfun, basic_block_def::count, cgraph_node::count, count, current_function_decl, dump_file, dump_flags, ECF_NORETURN, ENTRY_BLOCK_PTR_FOR_FN, EXIT_BLOCK_PTR_FOR_FN, FOR_ALL_BB_FN, FOR_EACH_BB_FN, FOR_EACH_EDGE, gcc_checking_assert, cgraph_node::get(), gimple_call_flags(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), basic_block_def::index, is_gimple_call(), last_basic_block_for_fn, profile_probability::never(), NULL, basic_block_def::preds, propagate_unlikely_bbs_forward(), stmt_can_terminate_bb_p(), basic_block_def::succs, TDF_DETAILS, unlikely_executed_bb_p(), unlikely_executed_edge_p(), worklist, and profile_count::zero().
Referenced by estimate_bb_frequencies(), and tree_estimate_probability().
|
static |
Drop the profile for NODE to guessed, and update its frequency based on whether it is expected to be hot given the CALL_COUNT.
References cgraph_edge::call_stmt, cgraph_node::callees, function::cfg, basic_block_def::count, cgraph_edge::count, cgraph_node::count, control_flow_graph::count_max, symtab_node::decl, DECL_COMDAT, DECL_EXTERNAL, DECL_STRUCT_FUNCTION, dump_file, symtab_node::dump_name(), ENTRY_BLOCK_PTR_FOR_FN, FOR_ALL_BB_FN, cgraph_node::frequency, gimple_bb(), profile_count::guessed_local(), cgraph_node::indirect_calls, maybe_hot_count_p(), cgraph_edge::next_callee, NODE_FREQUENCY_HOT, NODE_FREQUENCY_NORMAL, NULL, opt_for_fn, PROFILE_ABSENT, PROFILE_GUESSED, profile_info, profile_status_for_fn, gcov_summary::runs, profile_count::uninitialized(), warning(), and profile_count::zero().
Referenced by handle_missing_profiles().
|
static |
Dump information about the branch prediction to the output file.
References basic_block_def::count, profile_count::dump(), dump_file, dump_flags, edge_prediction::ep_edge, FOR_EACH_EDGE, profile_count::initialized_p(), NULL, profile_count::precise_p(), PRId64, reason_messages, REASON_NONE, REG_BR_PROB_BASE, basic_block_def::succs, TDF_DETAILS, and profile_count::to_gcov_type().
Referenced by combine_predictions_for_bb(), combine_predictions_for_insn(), and prune_predictions_for_bb().
bool edge_predicted_by_p | ( | edge | e, |
enum br_predictor | predictor, | ||
bool | taken ) |
Return true if the one of outgoing edges is already predicted by PREDICTOR for edge E predicted as TAKEN.
References bb_predictions, edge_prediction::ep_next, i, REG_BR_PROB_BASE, and TAKEN.
Referenced by maybe_predict_edge().
bool edge_probability_reliable_p | ( | const_edge | e | ) |
Same predicate as above, working on edges.
|
static |
Estimate and propagate basic block frequencies using the given branch probabilities.
References alloc_aux_for_blocks(), alloc_aux_for_edges(), profile_probability::always(), BLOCK_INFO, cfun, profile_count::combine_with_ipa_count(), compute_function_frequency(), basic_block_def::count, count, current_function_decl, function::decl, determine_unlikely_bbs(), dump_file, EDGE_INFO, ENTRY_BLOCK_PTR_FOR_FN, estimate_loops(), FOR_BB_BETWEEN, FOR_EACH_BB_FN, FOR_EACH_EDGE, free_aux_for_blocks(), free_aux_for_edges(), frequency, profile_count::from_gcov_type(), gimple_call_fndecl(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), profile_count::guessed_local(), basic_block_def::index, profile_count::ipa(), is_gimple_call(), mark_dfs_back_edges(), profile_count::max(), profile_count::n_bits, NULL, recursive_call_p(), single_succ_edge(), basic_block_def::succs, sreal::to_double(), sreal::to_nearest_int(), profile_count::uninitialized(), and profile_count::zero().
Referenced by rebuild_frequencies(), and tree_estimate_probability().
|
static |
Propagates frequencies through structure of loops.
References bitmap_set_bit, cfun, current_loops, ENTRY_BLOCK_PTR_FOR_FN, estimate_loops_at_level(), FOR_ALL_BB_FN, basic_block_def::index, number_of_loops(), and propagate_freq().
Referenced by estimate_bb_frequencies().
Estimate frequencies in loops at same nest level.
References bitmap_set_bit, EDGE_INFO, estimate_loops_at_level(), free(), get_loop_body(), loop::header, i, loop::inner, loop_latch_edge(), loop::next, loop::num_nodes, and propagate_freq().
Referenced by estimate_loops(), and estimate_loops_at_level().
bool expensive_function_p | ( | int | threshold | ) |
Return true if function is likely to be expensive, so there is no point to optimize performance of prologue, epilogue or do inlining at the expense of code size growth. THRESHOLD is the limit of number of instructions function can execute at average to be still considered not expensive.
References active_insn_p(), cfun, basic_block_def::count, count, dump_file, ENTRY_BLOCK_PTR_FOR_FN, FOR_BB_INSNS, FOR_EACH_BB_FN, basic_block_def::index, profile_count::initialized_p(), and profile_count::zero().
Compare two SSA_NAMEs: returns TRUE if T1 and T2 are value coherent.
References gcc_assert, is_gimple_assign(), NULL, SINGLE_SSA_TREE_OPERAND, SSA_NAME_DEF_STMT, SSA_OP_USE, and TREE_CODE.
Referenced by predict_iv_comparison().
|
static |
Return constant EXPR will likely have at execution time, NULL if unknown. The function is used by builtin_expect branch predictor so the evidence must come from this construct and additional possible constant folding. We may want to implement more involved value guess (such as value range propagation based prediction), but such tricks shall go to new implementation.
References expr, expr_expected_value_1(), extract_ops_from_tree(), TREE_CONSTANT, and TREE_TYPE.
Referenced by expr_expected_value_1(), and tree_predict_by_opcode().
|
static |
Helper function for expr_expected_value.
References boolean_true_node, build_int_cst(), build_one_cst(), build_real_from_int_cst(), BUILT_IN_NORMAL, DECL_BUILT_IN_CLASS, DECL_FUNCTION_CODE(), DECL_IS_MALLOC, DECL_IS_OPERATOR_NEW_P, dyn_cast(), error_at(), expr_expected_value(), expr_expected_value_1(), fold_build1, fold_build2, fold_build2_initializer_loc(), fold_convert, gcc_assert, get_gimple_rhs_class(), get_predictor_value(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), GIMPLE_BINARY_RHS, gimple_call_arg(), gimple_call_fndecl(), gimple_call_internal_fn(), gimple_call_internal_p(), gimple_call_num_args(), gimple_location(), gimple_phi_arg_edge(), gimple_phi_num_args(), GIMPLE_SINGLE_RHS, GIMPLE_UNARY_RHS, HITRATE, i, profile_count::initialized_p(), integer_type_node, is_gimple_assign(), is_gimple_call(), MIN, profile_count::nonzero_p(), NULL, NULL_TREE, operand_equal_p(), PHI_ARG_DEF, PHI_RESULT, expected_value::predictor, PROB_ALWAYS, expected_value::probability, r, RDIV, real_to_integer(), REG_BR_PROB_BASE, ssa_expected_value, SSA_NAME_DEF_STMT, SSA_NAME_VERSION, TREE_CODE, TREE_CONSTANT, tree_fits_uhwi_p(), TREE_OPERAND, TREE_REAL_CST_PTR, tree_to_uhwi(), TREE_TYPE, UNKNOWN_LOCATION, and expected_value::val.
Referenced by expr_expected_value(), expr_expected_value_1(), and tree_predict_by_opcode().
|
static |
Filter edge predictions PREDS by a function FILTER: if FILTER return false the prediction is removed. DATA are passed to the filter function.
References bb_predictions, edge_prediction::ep_next, and free().
Referenced by maybe_predict_edge(), prune_predictions_for_bb(), and remove_predictions_associated_with_edge().
Force edge E to be cold. If IMPOSSIBLE is true, for edge to have count and probability 0 otherwise keep low probability to represent possible error in a guess. This is used i.e. in case we predict loop to likely iterate given number of times but we are not 100% sure. This function locally updates profile without attempt to keep global consistency which cannot be reached in full generality without full profile rebuild from probabilities alone. Doing so is not necessarily a good idea because frequencies and counts may be more realistic then probabilities. In some cases (such as for elimination of early exits during full loop unrolling) the caller can ensure that profile will get consistent afterwards.
References profile_probability::always(), cfun, current_ir_type(), dump_file, dump_flags, ENTRY_BLOCK_PTR_FOR_FN, FOR_EACH_EDGE, force_edge_cold(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), IR_GIMPLE, maybe_hot_bb_p(), MIN, profile_probability::never(), set_edge_probability_and_rescale_others(), single_pred_edge(), single_pred_p(), stmt_can_terminate_bb_p(), TDF_DETAILS, profile_count::to_frequency(), update_br_prob_note(), profile_probability::very_unlikely(), and profile_count::zero().
Referenced by duplicate_loop_body_to_header_edge(), force_edge_cold(), isolate_path(), and try_unroll_loop_completely().
optimization_type function_optimization_type | ( | struct function * | fun | ) |
Return the optimization type that should be used for function FUN.
References OPTIMIZE_FOR_SIZE, OPTIMIZE_FOR_SPEED, and optimize_function_for_speed_p().
Return the SSA_NAME in T or T's operands. Return NULL if SSA_NAME cannot be found.
References BINARY_CLASS_P, NULL, strips_small_constant(), TREE_CODE, TREE_OPERAND, and TREE_OPERAND_LENGTH.
Referenced by is_comparison_with_loop_invariant_p().
gcov_type get_hot_bb_threshold | ( | void | ) |
Determine the threshold for hot BB counts.
References dump_file, profile_count::max_count, min_count, PRId64, profile_info, set_hot_bb_threshold(), and gcov_summary::sum_max.
Referenced by dump_function_to_file(), ipa_propagate_frequency(), maybe_hot_count_p(), and output_profile_summary().
|
static |
Return probability of a PREDICTOR. If the predictor has variable probability return passed PROBABILITY.
References gcc_assert.
Referenced by expr_expected_value_1(), and tree_predict_by_opcode().
void gimple_predict_edge | ( | edge | e, |
enum br_predictor | predictor, | ||
int | probability ) |
Predict edge E with the given PROBABILITY.
References bb_predictions, cfun, EDGE_COUNT, ENTRY_BLOCK_PTR_FOR_FN, edge_prediction::ep_next, edge_prediction::ep_probability, and i.
bool gimple_predicted_by_p | ( | const_basic_block | bb, |
enum br_predictor | predictor ) |
Return true if the one of outgoing edges is already predicted by PREDICTOR.
References bb_predictions, edge_prediction::ep_next, and i.
void guess_outgoing_edge_probabilities | ( | basic_block | bb | ) |
Set edge->probability for each successor edge of BB.
References BB_END, bb_estimate_probability_locally(), and combine_predictions_for_insn().
Referenced by compute_outgoing_frequencies().
void handle_missing_profiles | ( | void | ) |
In the case of COMDAT routines, multiple object files will contain the same function and the linker will select one for the binary. In that case all the other copies from the profile instrument binary will be missing profile counts. Look for cases where this happened, due to non-zero call counts going to 0-count functions, and drop the profile to guessed so that we can use the estimated probabilities and avoid optimizing only for size. The other case where the profile may be missing is when the routine is not going to be emitted to the object file, e.g. for "extern template" class methods. Those will be marked DECL_EXTERNAL. Emit a warning in all other cases of non-zero calls to 0-count functions.
References cgraph_edge::callee, cgraph_node::callees, cgraph_edge::caller, cgraph_node::callers, function::cfg, cgraph_edge::count, cgraph_node::count, symtab_node::decl, DECL_COMDAT, DECL_EXTERNAL, DECL_STRUCT_FUNCTION, drop_profile(), FOR_EACH_DEFINED_FUNCTION, profile_count::initialized_p(), profile_count::ipa(), cgraph_edge::next_caller, profile_count::nonzero_p(), profile_info, PROFILE_READ, profile_status_for_fn, gcov_summary::runs, cgraph_node::tp_first_run, worklist, and profile_count::zero().
Referenced by tree_profiling().
optimization_type insn_optimization_type | ( | ) |
Return the optimization type that should be used for the current instruction.
References OPTIMIZE_FOR_SIZE, OPTIMIZE_FOR_SPEED, and optimize_insn_for_speed_p().
Referenced by expand_sfix_optab().
void invert_br_probabilities | ( | rtx | insn | ) |
Invert all branch predictions or probability notes in the INSN. This needs to be done each time we invert the condition used by the jump.
References profile_probability::from_reg_br_prob_note(), GEN_INT, INTVAL, profile_probability::invert(), REG_BR_PROB_BASE, REG_NOTE_KIND, REG_NOTES, profile_probability::to_reg_br_prob_note(), XEXP, and XINT.
Referenced by redirect_jump_2().
|
static |
Check the compare STMT in LOOP. If it compares an induction variable to a loop invariant, return true, and save LOOP_INVARIANT, COMPARE_CODE and LOOP_STEP. Otherwise return false and set LOOP_INVAIANT to NULL.
References affine_iv::base, get_base_value(), gimple_cond_code(), gimple_cond_lhs(), gimple_cond_rhs(), integer_zerop(), invert_tree_comparison(), loop_containing_stmt(), NULL, simple_iv(), affine_iv::step, TREE_CODE, and tree_fits_shwi_p().
Referenced by predict_iv_comparison(), and predict_loops().
Returns TRUE if the STMT is exit(0) like statement.
References gimple_call_arg(), gimple_call_builtin_p(), integer_zerop(), and nb_iter_bound::stmt.
Referenced by tree_bb_level_predictions().
gimple_opt_pass * make_pass_profile | ( | gcc::context * | ctxt | ) |
gimple_opt_pass * make_pass_rebuild_frequencies | ( | gcc::context * | ctxt | ) |
gimple_opt_pass * make_pass_strip_predict_hints | ( | gcc::context * | ctxt | ) |
bool maybe_hot_bb_p | ( | struct function * | fun, |
const_basic_block | bb ) |
Return true if basic block BB of function FUN can be CPU intensive and should thus be optimized for maximum performance.
References basic_block_def::count, gcc_checking_assert, and maybe_hot_count_p().
Referenced by compute_function_frequency(), dump_bb_info(), force_edge_cold(), optimize_bb_for_size_p(), and rtl_profile_for_bb().
bool maybe_hot_count_p | ( | struct function * | fun, |
profile_count | count ) |
Return TRUE if COUNT is considered to be hot in function FUN.
References count, function::decl, ENTRY_BLOCK_PTR_FOR_FN, cgraph_node::frequency, cgraph_node::get(), get_hot_bb_threshold(), MAX, NODE_FREQUENCY_EXECUTED_ONCE, NODE_FREQUENCY_HOT, NODE_FREQUENCY_UNLIKELY_EXECUTED, PROFILE_ABSENT, profile_info, PROFILE_READ, profile_status_for_fn, gcov_summary::runs, and profile_count::zero().
Referenced by afdo_callsite_hot_enough_for_early_inline(), drop_profile(), maybe_hot_bb_p(), maybe_hot_edge_p(), and cgraph_edge::maybe_hot_p().
Return true if edge E can be CPU intensive and should thus be optimized for maximum performance.
References cfun, and maybe_hot_count_p().
Referenced by optimize_edge_for_size_p(), and rtl_profile_for_edge().
|
static |
Predict edge E with PRED unless it is already predicted by some predictor considered equivalent.
References bb_predictions, edge_predicted_by_p(), filter_predictions(), not_loop_guard_equal_edge_p(), and predict_edge_def().
Referenced by predict_paths_for_bb(), and predict_paths_leading_to_edge().
|
static |
Filter function predicate that returns true for a edge predicate P if its edge is equal to DATA.
References edge_prediction::ep_edge.
Referenced by remove_predictions_associated_with_edge().
|
static |
Filter function predicate that returns true for a edge predicate P if its edge is equal to DATA.
References edge_prediction::ep_edge, and edge_prediction::ep_predictor.
Referenced by maybe_predict_edge().
|
static |
Return true if edge prediction P is not in DATA hash set.
References hash_set< KeyId, Lazy, Traits >::contains().
Referenced by prune_predictions_for_bb().
optimize_size_level optimize_bb_for_size_p | ( | const_basic_block | bb | ) |
Return TRUE if basic block BB should be optimized for size.
References cfun, count, maybe_hot_bb_p(), optimize_function_for_size_p(), OPTIMIZE_SIZE_BALANCED, OPTIMIZE_SIZE_MAX, and profile_count::zero().
Referenced by tree_switch_conversion::switch_conversion::array_value_type(), coalesce_cost_bb(), compute_alignments(), create_coalesce_list_for_region(), eliminate_partially_redundant_load(), eliminate_partially_redundant_loads(), expand_complex_multiplication(), gimple_divmod_fixed_value_transform(), gimple_mod_pow2_value_transform(), gimple_mod_subtract_transform(), gimple_stringops_transform(), ignore_bb_p(), optimize_bb_for_speed_p(), optimize_loop_for_size_p(), try_crossjump_bb(), try_head_merge_bb(), and vect_recog_divmod_pattern().
bool optimize_bb_for_speed_p | ( | const_basic_block | bb | ) |
Return TRUE if basic block BB should be optimized for speed.
References optimize_bb_for_size_p().
Referenced by attempt_change(), bb_ok_for_noce_convert_multiple_sets(), bb_optimization_type(), bb_valid_for_noce_process_p(), find_candidates_dom_walker::before_dom_children(), vect_optimize_slp_pass::build_vertices(), calculate_elim_costs_all_insns(), cheap_bb_rtx_cost_p(), combine_instructions(), compute_alignments(), copy_bb_p(), create_new_invariant(), cse_extended_basic_block(), find_if_case_1(), find_if_case_2(), get_computation_cost(), get_preferred_alternatives(), get_preferred_alternatives(), get_stored_val(), gimple_expand_builtin_cabs(), gimple_expand_builtin_pow(), gimple_fold_builtin_strcat(), move2add_use_add2_insn(), move2add_use_add3_insn(), noce_find_if_block(), noce_process_if_block(), note_reg_elim_costly(), optimize_cands_for_speed_p(), optimize_loop_for_speed_p(), optimize_range_tests_to_bit_test(), outgoing_edges_match(), back_threader_profitability::possibly_profitable_path_p(), reload_cse_move2add(), reload_cse_simplify_operands(), reload_cse_simplify_set(), replace_reciprocal(), replace_reciprocal_squares(), replace_uncond_cands_and_profitable_phis(), should_replace_address(), simplify_builtin_call(), try_replace_in_use(), try_replace_reg(), and value_replacement().
optimize_size_level optimize_edge_for_size_p | ( | edge | e | ) |
Return TRUE if edge E should be optimized for size.
References cfun, maybe_hot_edge_p(), optimize_function_for_size_p(), OPTIMIZE_SIZE_BALANCED, OPTIMIZE_SIZE_MAX, and unlikely_executed_edge_p().
Referenced by coalesce_cost_edge(), and optimize_edge_for_speed_p().
Return TRUE if edge E should be optimized for speed.
References optimize_edge_for_size_p().
Referenced by connect_traces(), do_pre_partial_partial_insertion(), do_pre_regular_insertion(), find_traces_1_round(), and back_threader_profitability::profitable_path_p().
optimize_size_level optimize_function_for_size_p | ( | struct function * | fun | ) |
Return true if function FUN should always be optimized for size.
References function::decl, cgraph_node::get(), cgraph_node::optimize_for_size_p(), OPTIMIZE_SIZE_MAX, and OPTIMIZE_SIZE_NO.
Referenced by bb_to_key(), better_edge_p(), compute_alignments(), connect_better_edge_p(), connect_traces(), decide_copy_try_finally(), find_traces_1_round(), gimple_fold_builtin_fputs(), gimple_fold_builtin_stpcpy(), gimple_fold_builtin_strchr(), gimple_fold_builtin_strcpy(), inherit_reload_reg(), fwd_jt_path_registry::mark_threaded_blocks(), optimize_bb_for_size_p(), optimize_edge_for_size_p(), optimize_function_for_speed_p(), optimize_insn_for_size_p(), relax_delay_slots(), sra_get_max_scalarization_size(), and want_to_gcse_p().
Return true if function FUN should always be optimized for speed.
References optimize_function_for_size_p().
Referenced by assemble_start_function(), cheap_bb_rtx_cost_p(), decompose_multiword_subregs(), fold_truth_andor_1(), function_optimization_type(), gimple_expand_builtin_pow(), gimple_expand_builtin_powi(), gimplify_init_constructor(), optimize_range_tests(), reorder_basic_blocks_simple(), simplify_context::simplify_binary_operation_1(), use_shrink_wrapping_separate(), and want_to_gcse_p().
optimize_size_level optimize_insn_for_size_p | ( | void | ) |
Return TRUE if the current function is optimized for size.
References cfun, optimize_function_for_size_p(), and OPTIMIZE_SIZE_BALANCED.
Referenced by expand_clrsb_using_clz(), tree_switch_conversion::jump_table_cluster::find_jump_tables(), inline_expand_builtin_bytecmp(), and optimize_insn_for_speed_p().
bool optimize_insn_for_speed_p | ( | void | ) |
Return TRUE if the current function is optimized for speed.
References optimize_insn_for_size_p().
Referenced by avoid_expensive_constant(), can_do_by_pieces(), can_store_by_pieces(), choose_mult_variant(), clear_storage_hints(), compress_float_constant(), convert_mode_scalar(), do_jump(), tree_switch_conversion::bit_test_cluster::emit(), emit_case_dispatch_table(), emit_conditional_move(), emit_move_complex(), emit_store_flag(), emit_store_flag_int(), expand_abs_nojump(), expand_binop(), expand_ccmp_expr_1(), expand_DIVMOD(), expand_divmod(), expand_expr_divmod(), expand_expr_real_2(), expand_gimple_cond(), expand_mul_overflow(), expand_mult(), expand_one_cmpl_abs_nojump(), expand_POPCOUNT(), expand_sdiv_pow2(), expand_shift_1(), expand_smod_pow2(), expand_unop(), expand_widening_mult(), expmed_mult_highpart(), expmed_mult_highpart_optab(), insn_optimization_type(), maybe_optimize_mod_cmp(), maybe_optimize_pow2p_mod_cmp(), output_asm_name(), precompute_register_parameters(), prefer_and_bit_test(), prepare_cmp_insn(), store_by_pieces(), and synth_mult().
optimize_size_level optimize_loop_for_size_p | ( | class loop * | loop | ) |
Return TRUE if LOOP should be optimized for size.
References loop::header, and optimize_bb_for_size_p().
Referenced by decide_unrolling(), optimize_loop_nest_for_size_p(), tree_ssa_split_loops(), and tree_ssa_unswitch_loops().
Return TRUE if LOOP should be optimized for speed.
References loop::header, and optimize_bb_for_speed_p().
Referenced by add_iv_candidate_for_use(), adjust_setup_cost(), doloop_optimize(), loop_distribution::execute(), move_single_loop_invariants(), optimize_loop_nest_for_speed_p(), split_paths(), tree_predictive_commoning(), tree_ssa_iv_optimize_loop(), and try_peel_loop().
optimize_size_level optimize_loop_nest_for_size_p | ( | class loop * | loop | ) |
Return TRUE if nest rooted at LOOP should be optimized for size.
References loop::inner, loop_outer(), MIN, loop::next, optimize_loop_for_size_p(), and OPTIMIZE_SIZE_NO.
Referenced by loop_prefetch_arrays(), parallelize_loops(), and tree_loop_unroll_and_jam().
Return TRUE if nest rooted at LOOP should be optimized for speed.
References loop::inner, loop_outer(), loop::next, and optimize_loop_for_speed_p().
Referenced by tree_unroll_loops_completely_1(), try_vectorize_loop(), vect_enhance_data_refs_alignment(), and vect_mark_for_runtime_alias_test().
void predict_edge_def | ( | edge | e, |
enum br_predictor | predictor, | ||
enum prediction | taken ) |
Predict edge E by given predictor if possible.
References predict_edge(), REG_BR_PROB_BASE, and TAKEN.
Referenced by maybe_predict_edge(), predict_iv_comparison(), tree_estimate_probability_bb(), and tree_predict_by_opcode().
Predict for extra loop exits that will lead to EXIT_EDGE. The extra loop exits are resulted from short-circuit conditions that will generate an if_tmp. E.g.: if (foo() || global > 10) break; This will be translated into: BB3: loop header... BB4: if foo() goto BB6 else goto BB5 BB5: if global > 10 goto BB6 else goto BB7 BB6: goto BB7 BB7: iftmp = (PHI 0(BB5), 1(BB6)) if iftmp == 1 goto BB8 else goto BB3 BB8: outside of the loop... The edge BB7->BB8 is loop exit because BB8 is outside of the loop. From the dataflow, we can infer that BB4->BB6 and BB5->BB6 are also loop exits. This function takes BB7->BB8 as input, and finds out the extra loop exits to predict them using PRED_LOOP_EXTRA_EXIT.
References dyn_cast(), EDGE_COUNT, FOR_EACH_EDGE, gimple_cond_code(), gimple_cond_lhs(), gimple_cond_rhs(), gimple_phi_arg_def(), gimple_phi_arg_edge(), gimple_phi_num_args(), gsi_last_bb(), i, integer_onep(), integer_zerop(), NOT_TAKEN, predict_paths_leading_to_edge(), safe_dyn_cast(), SSA_NAME_DEF_STMT, TREE_CODE, and TREE_CONSTANT.
Referenced by predict_loops().
|
static |
References add_reg_note(), any_condjump_p(), gcc_assert, and GEN_INT.
Referenced by predict_insn_def(), and rtl_predict_edge().
void predict_insn_def | ( | rtx_insn * | insn, |
enum br_predictor | predictor, | ||
enum prediction | taken ) |
Predict insn by given predictor.
References gcc_assert, predict_insn(), PROB_UNINITIALIZED, REG_BR_PROB_BASE, and TAKEN.
Referenced by bb_estimate_probability_locally(), prepare_call_address(), and stack_protect_epilogue().
|
static |
Predict branch probability of BB when BB contains a branch that compares an induction variable in LOOP with LOOP_IV_BASE_VAR to LOOP_BOUND_VAR. The loop exit is compared using LOOP_BOUND_CODE, with step of LOOP_BOUND_STEP. E.g. for (int i = 0; i < bound; i++) { if (i < bound - 2) computation_1(); else computation_2(); } In this loop, we will predict the branch inside the loop to be taken.
References wi::cmps(), wi::div_trunc(), expr_coherent_p(), FOR_EACH_EDGE, gcc_assert, gsi_last_bb(), is_comparison_with_loop_invariant_p(), wi::neg_p(), NOT_TAKEN, predict_edge(), predict_edge_def(), predicted_by_loop_heuristics_p(), REG_BR_PROB_BASE, safe_dyn_cast(), SIGNED, wi::sub(), basic_block_def::succs, TAKEN, generic_wide_int< storage >::to_uhwi(), wi::to_widest(), tree_fits_shwi_p(), and wi::udiv_trunc().
Referenced by predict_loops().
|
static |
Predict edge probabilities by exploiting loop structure.
References hash_set< KeyId, Lazy, Traits >::add(), as_a(), loop::bounds, CDI_DOMINATORS, cfun, compare_tree_int(), hash_set< KeyId, Lazy, Traits >::contains(), CONVERT_EXPR_CODE_P, current_function_decl, dominated_by_p(), dump_file, dump_flags, estimated_stmt_executions(), flow_bb_inside_loop_p(), FOR_EACH_BB_FN, FOR_EACH_EDGE, FOR_EACH_VEC_ELT, free(), get_loop_body(), get_loop_exit_edges(), gimple_assign_rhs1(), gimple_assign_rhs_code(), gimple_call_arg(), gimple_call_fndecl(), gimple_call_internal_p(), gimple_cond_code(), gimple_cond_lhs(), gimple_cond_rhs(), gsi_end_p(), gsi_last_bb(), gsi_next(), gsi_start_bb(), gsi_stmt(), wi::gtu_p(), loop::header, HITRATE, predictor_info::hitrate, basic_block_def::index, integer_zerop(), is_comparison_with_loop_invariant_p(), is_gimple_call(), LI_FROM_INNERMOST, likely_max_loop_iterations_int(), likely_max_stmt_executions(), basic_block_def::loop_father, loop_niter_by_eval(), loop_outer(), loop_preheader_edge(), wi::ltu_p(), max_loop_iterations_int(), nb_iter_bound::next, niter_desc::niter, NOT_TAKEN, NULL, loop::num, NUM_FIXED_BLOCKS, loop::num_nodes, number_of_iterations_exit(), predict_edge(), predict_extra_loop_exits(), predict_iv_comparison(), predict_paths_leading_to(), predict_paths_leading_to_edge(), predicted_by_loop_heuristics_p(), predicted_by_p(), print_generic_expr(), RDIV, recursive_call_p(), REG_BR_PROB_BASE, safe_dyn_cast(), single_pred_edge(), single_pred_p(), single_succ_p(), SSA_NAME_DEF_STMT, nb_iter_bound::stmt, basic_block_def::succs, TDF_DETAILS, TDF_SLIM, generic_wide_int< storage >::to_shwi(), TREE_CODE, tree_fits_uhwi_p(), tree_to_shwi(), tree_to_uhwi(), and unlikely_executed_edge_p().
Referenced by tree_estimate_probability().
|
static |
Predict edges to successors of CUR whose sources are not postdominated by BB by PRED and recurse to all postdominators.
References bitmap_set_bit, CDI_DOMINATORS, CDI_POST_DOMINATORS, dominated_by_p(), first_dom_son(), flow_bb_inside_loop_p(), FOR_EACH_EDGE, gcc_assert, loop_exit_edge_p(), maybe_predict_edge(), next_dom_son(), NUM_FIXED_BLOCKS, predict_paths_for_bb(), basic_block_def::preds, unlikely_executed_edge_p(), and visited.
Referenced by predict_paths_for_bb(), predict_paths_leading_to(), and predict_paths_leading_to_edge().
|
static |
Sets branch probabilities according to PREDiction and FLAGS.
References predict_paths_for_bb().
Referenced by predict_loops(), and tree_bb_level_predictions().
|
static |
Like predict_paths_leading_to but take edge instead of basic block.
References CDI_POST_DOMINATORS, dominated_by_p(), FOR_EACH_EDGE, maybe_predict_edge(), predict_paths_for_bb(), basic_block_def::succs, and unlikely_executed_edge_p().
Referenced by apply_return_prediction(), predict_extra_loop_exits(), and predict_loops().
Return true if edge E is likely to be well predictable by branch predictor.
References REG_BR_PROB_BASE.
Referenced by default_max_noce_ifcvt_seq_cost(), find_if_case_1(), and find_if_case_2().
|
static |
Return true if E is predicted by one of loop heuristics.
References bb_predictions, edge_prediction::ep_next, and i.
Referenced by predict_iv_comparison(), and predict_loops().
const char * predictor_name | ( | enum br_predictor | predictor | ) |
References predictor_info::name.
Referenced by dump_generic_node(), and pp_gimple_stmt_1().
|
static |
Return true if COUNT is considered to be never executed in function FUN or if function FUN is considered so in the static profile.
References count, function::decl, cgraph_node::frequency, gcc_checking_assert, cgraph_node::get(), NODE_FREQUENCY_UNLIKELY_EXECUTED, profile_info, PROFILE_READ, profile_status_for_fn, gcov_summary::runs, and profile_count::zero().
Referenced by probably_never_executed_bb_p(), and probably_never_executed_edge_p().
bool probably_never_executed_bb_p | ( | struct function * | fun, |
const_basic_block | bb ) |
Return true if basic block BB of function FUN is probably never executed.
References basic_block_def::count, and probably_never_executed().
Referenced by bb_to_key(), check_bb_profile(), compute_function_frequency(), dump_bb_info(), find_rarely_executed_basic_blocks_and_crossing_edges(), and push_to_next_round_p().
Return true if edge E of function FUN is probably never executed.
References probably_never_executed(), and unlikely_executed_edge_p().
Referenced by check_bb_profile(), find_rarely_executed_basic_blocks_and_crossing_edges(), back_threader_profitability::possibly_profitable_path_p(), back_threader_profitability::profitable_path_p(), and single_likely_exit().
|
static |
Helper function for estimate_bb_frequencies. Propagate the frequencies in blocks marked in TOVISIT, starting in HEAD.
References BASIC_BLOCK_FOR_FN, bitmap_bit_p, bitmap_clear_bit(), BLOCK_INFO, cfun, basic_block_def::count, count, dump_file, EDGE_INFO, EXECUTE_IF_SET_IN_BITMAP, EXIT_BLOCK_PTR_FOR_FN, find_edge(), FOR_EACH_EDGE, frequency, gcc_assert, i, basic_block_def::index, last, NULL, basic_block_def::preds, basic_block_def::succs, sreal::to_double(), visit, and profile_count::zero().
Referenced by estimate_loops(), and estimate_loops_at_level().
void propagate_unlikely_bbs_forward | ( | void | ) |
All basic blocks that are reachable only from unlikely basic blocks are unlikely.
References basic_block_def::aux, cfun, basic_block_def::count, count, dump_file, dump_flags, ENTRY_BLOCK_PTR_FOR_FN, FOR_ALL_BB_FN, FOR_EACH_EDGE, basic_block_def::index, NULL, basic_block_def::succs, TDF_DETAILS, worklist, and profile_count::zero().
Referenced by determine_unlikely_bbs(), and find_rarely_executed_basic_blocks_and_crossing_edges().
|
static |
Prune predictions for a basic block BB. Currently we do following clean-up steps: 1) remove duplicate prediction that is guessed with the same probability (different than 1/2) to both edge 2) remove duplicates for a prediction that belongs with the same probability to a single edge
References hash_set< KeyId, Lazy, Traits >::add(), bb_predictions, dump_file, dump_prediction(), edge_prediction::ep_edge, edge_prediction::ep_next, edge_prediction::ep_predictor, edge_prediction::ep_probability, filter_predictions(), hash_table< Descriptor, Lazy, Allocator >::find(), hash_table< Descriptor, Lazy, Allocator >::find_slot(), not_removed_prediction_p(), REASON_EDGE_PAIR_DUPLICATE, REASON_SINGLE_EDGE_DUPLICATE, and REG_BR_PROB_BASE.
Referenced by combine_predictions_for_bb().
void rebuild_frequencies | ( | void | ) |
Rebuild function frequencies. Passes are in general expected to maintain profile by hand, however in some cases this is not possible: for example when inlining several functions with loops freuqencies might run out of scale and thus needs to be recomputed.
References cfun, connect_infinite_loops_to_exit(), basic_block_def::count, count, profile_count::differs_from_p(), dump_file, ENTRY_BLOCK_PTR_FOR_FN, estimate_bb_frequencies(), FOR_BB_BETWEEN, FOR_EACH_EDGE, basic_block_def::index, profile_count::initialized_p(), loop_optimizer_finalize(), loop_optimizer_init(), LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS, NULL, basic_block_def::preds, PROFILE_ABSENT, profile_status_for_fn, remove_fake_exit_edges(), profile_count::uninitialized(), and profile_count::zero().
Referenced by tree_function_versioning().
void remove_predictions_associated_with_edge | ( | edge | e | ) |
Remove all predictions on given basic block that are attached to edge E.
References bb_predictions, filter_predictions(), and not_equal_edge_p().
Referenced by remove_edge_raw().
void report_predictor_hitrates | ( | void | ) |
Perform a dry run of the branch prediction pass and report comparsion of the predicted and real profile into the dump file.
References cfun, dump_file, dump_flags, flow_loops_dump(), loop_optimizer_finalize(), loop_optimizer_init(), LOOPS_NORMAL, NULL, number_of_loops(), scev_finalize(), scev_initialize(), TDF_DETAILS, and tree_estimate_probability().
Referenced by branch_prob().
|
static |
Try to guess whether the value of return means error code.
References integer_onep(), integer_zerop(), INTEGRAL_TYPE_P, NOT_TAKEN, POINTER_TYPE_P, TREE_CODE, TREE_CONSTANT, tree_int_cst_sgn(), and TREE_TYPE.
Referenced by apply_return_prediction().
void rtl_predict_edge | ( | edge | e, |
enum br_predictor | predictor, | ||
int | probability ) |
Predict edge E with given probability if possible.
References any_condjump_p(), BB_END, predict_insn(), and REG_BR_PROB_BASE.
bool rtl_predicted_by_p | ( | const_basic_block | bb, |
enum br_predictor | predictor ) |
void rtl_profile_for_bb | ( | basic_block | bb | ) |
Set RTL expansion for BB profile.
References cfun, crtl, and maybe_hot_bb_p().
Referenced by combine_instructions(), construct_exit_block(), expand_gimple_basic_block(), peephole2_optimize(), simplify_builtin_call(), split_all_insns(), and thread_prologue_and_epilogue_insns().
void rtl_profile_for_edge | ( | edge | e | ) |
Set RTL expansion for edge profile.
References crtl, and maybe_hot_edge_p().
|
static |
We cannot predict the probabilities of outgoing edges of bb. Set them evenly and hope for the best. If UNLIKELY_EDGES is not null, distribute even probability for all edges not mentioned in the set. These edges are given PROB_VERY_UNLIKELY probability. Similarly for LIKELY_EDGES, if we have exactly one likely edge, make the other edges predicted as not probable.
References profile_probability::always(), count, edge_prediction::ep_probability, FOR_EACH_EDGE, profile_probability::from_reg_br_prob_base(), gcc_assert, profile_probability::invert(), profile_probability::never(), NULL, basic_block_def::succs, unlikely_executed_edge_p(), and profile_probability::very_unlikely().
Referenced by combine_predictions_for_bb(), and combine_predictions_for_insn().
void set_hot_bb_threshold | ( | gcov_type | min | ) |
Set the threshold for hot BB counts.
References min_count.
Referenced by get_hot_bb_threshold(), input_profile_summary(), and ipa_profile().
Get rid of all builtin_expect calls and GIMPLE_PREDICT statements we no longer need. EARLY is set to true when called from early optimizations.
References changed, fndecl_built_in_p(), FOR_EACH_BB_FN, gimple_build_assign(), gimple_call_arg(), gimple_call_fndecl(), gimple_call_internal_fn(), gimple_call_internal_p(), gimple_call_lhs(), gimple_call_num_args(), gimple_predict_predictor(), gsi_end_p(), gsi_next(), gsi_remove(), gsi_replace(), gsi_start_bb(), gsi_stmt(), is_gimple_call(), NULL_TREE, strip_predictor_early(), and TODO_cleanup_cfg.
|
static |
Return true when PRED predictor should be removed after early tree passes. Most of the predictors are beneficial to survive as early inlining can also distribute then into caller's bodies.
Referenced by strip_predict_hints().
Check if T1 and T2 satisfy the IV_COMPARE condition. Return the SSA_NAME if the condition satisfies, NULL otherwise. T1 and T2 should be one of the following cases: 1. T1 is SSA_NAME, T2 is NULL 2. T1 is SSA_NAME, T2 is INTEGER_CST between [-4, 4] 3. T2 is SSA_NAME, T1 is INTEGER_CST between [-4, 4]
References NULL, TREE_CODE, tree_fits_shwi_p(), and tree_to_shwi().
Referenced by get_base_value().
|
static |
Look for basic block that contains unlikely to happen events (such as noreturn calls) and mark all paths leading to execution of this basic blocks as unlikely.
References apply_return_prediction(), cfun, current_function_decl, DECL_ATTRIBUTES, EXIT_BLOCK_PTR_FOR_FN, FOR_EACH_BB_FN, FOR_EACH_EDGE, gimple_call_fndecl(), gimple_call_noreturn_p(), gimple_predict_outcome(), gimple_predict_predictor(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), is_exit_with_zero_arg(), is_gimple_call(), lookup_attribute(), NOT_TAKEN, predict_paths_leading_to(), recursive_call_p(), nb_iter_bound::stmt, and unlikely_executed_edge_p().
Referenced by tree_estimate_probability().
void tree_estimate_probability | ( | bool | dry_run | ) |
Predict branch probabilities and estimate profile of the tree CFG. This function can be called from the loop optimizers to recompute the profile information. If DRY_RUN is set, do not modify CFG and only produce dump files.
References assert_is_empty(), bb_predictions, calculate_dominance_info(), CDI_POST_DOMINATORS, cfun, combine_predictions_for_bb(), connect_infinite_loops_to_exit(), CP_SIMPLE_PREHEADERS, create_preheaders(), determine_unlikely_bbs(), estimate_bb_frequencies(), FOR_EACH_BB_FN, free_dominance_info(), NULL, number_of_loops(), predict_loops(), PROFILE_READ, profile_status_for_fn, record_loop_exits(), remove_fake_exit_edges(), ssa_expected_value, tree_bb_level_predictions(), and tree_estimate_probability_bb().
Referenced by report_predictor_hitrates().
|
static |
Predict branch probabilities and estimate profile for basic block BB. When LOCAL_ONLY is set do not use any global properties of CFG.
References as_a(), CDI_DOMINATORS, CDI_POST_DOMINATORS, cfun, dominated_by_p(), EXIT_BLOCK_PTR_FOR_FN, FOR_EACH_EDGE, gimple_call_fn(), gimple_call_fndecl(), gimple_has_side_effects(), gimple_inexpensive_call_p(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), is_gimple_call(), NOT_TAKEN, predict_edge_def(), nb_iter_bound::stmt, basic_block_def::succs, TAKEN, tree_predict_by_opcode(), and virtual_method_call_p().
Referenced by tree_estimate_probability(), and tree_guess_outgoing_edge_probabilities().
void tree_guess_outgoing_edge_probabilities | ( | basic_block | bb | ) |
Set edge->probability for each successor edge of BB.
References assert_is_empty(), bb_predictions, combine_predictions_for_bb(), NULL, ssa_expected_value, and tree_estimate_probability_bb().
Referenced by gimple_find_sub_bbs().
|
static |
Predict using opcode of the last statement in basic block.
References boolean_type_node, dyn_cast(), expr_expected_value(), expr_expected_value_1(), find_taken_edge_switch_expr(), FLOAT_TYPE_P, FOR_EACH_EDGE, gcc_assert, get_predictor_value(), gimple_cond_code(), gimple_cond_lhs(), gimple_cond_rhs(), gimple_switch_index(), gsi_last_bb(), HITRATE, integer_all_onesp(), integer_onep(), integer_zerop(), NOT_TAKEN, POINTER_TYPE_P, predict_edge(), predict_edge_def(), real_minus_onep(), real_onep(), real_zerop(), REG_BR_PROB_BASE, nb_iter_bound::stmt, basic_block_def::succs, TAKEN, TREE_CODE, TREE_TYPE, and type().
Referenced by tree_estimate_probability_bb().
|
static |
Return true if BB is unlikely executed.
References cfun, basic_block_def::count, ENTRY_BLOCK_PTR_FOR_FN, EXIT_BLOCK_PTR_FOR_FN, gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), stmt_can_terminate_bb_p(), unlikely_executed_stmt_p(), and profile_count::zero().
Referenced by determine_unlikely_bbs().
Return true if edge E is unlikely executed for obvious reasons.
References profile_probability::never(), and profile_count::zero().
Referenced by combine_predictions_for_bb(), determine_unlikely_bbs(), optimize_edge_for_size_p(), predict_loops(), predict_paths_for_bb(), predict_paths_leading_to_edge(), probably_never_executed_edge_p(), set_even_probabilities(), and tree_bb_level_predictions().
Return true if STMT is known to be unlikely executed.
References symtab_node::analyzed, AVAIL_AVAILABLE, current_function_decl, symtab_node::decl, DECL_ATTRIBUTES, cgraph_node::frequency, cgraph_node::get(), gimple_call_fndecl(), gimple_call_fntype(), is_gimple_call(), lookup_attribute(), NODE_FREQUENCY_UNLIKELY_EXECUTED, TYPE_ATTRIBUTES, and cgraph_node::ultimate_alias_target().
Referenced by unlikely_executed_bb_p().
bool update_max_bb_count | ( | void | ) |
Convert counts measured by profile driven feedback to frequencies. Return nonzero iff there was any nonzero execution count.
References cfun, basic_block_def::count, ENTRY_BLOCK_PTR_FOR_FN, FOR_BB_BETWEEN, profile_count::ipa(), profile_count::max(), profile_count::nonzero_p(), NULL, and profile_count::uninitialized().
Referenced by autofdo::afdo_annotate_cfg(), compute_branch_probabilities(), execute_fixup_cfg(), expand_omp_taskreg(), expand_thunk(), input_function(), ipa_merge_profiles(), optimize_inline_calls(), and tree_function_versioning().
|
static |
Return zero if phi result could have values other than -1, 0 or 1, otherwise return a bitmask, with bits 0, 1 and 2 set if -1, 0 and 1 values are used or likely.
References as_a(), g, gimple_assign_cast_p(), gimple_assign_rhs1(), gimple_assign_rhs_code(), gimple_phi_num_args(), i, INTEGRAL_TYPE_P, is_gimple_assign(), PHI_ARG_DEF, r, SSA_NAME_DEF_STMT, tcc_comparison, wi::to_wide(), TREE_CODE, TREE_CODE_CLASS, TREE_TYPE, TYPE_PRECISION, TYPE_UNSIGNED, and zero_one_minusone().
Referenced by apply_return_prediction(), and zero_one_minusone().
|
static |
This map contains for a basic block the list of predictions for the outgoing edges.
Referenced by clear_bb_predictions(), combine_predictions_for_bb(), edge_predicted_by_p(), filter_predictions(), gimple_predict_edge(), gimple_predicted_by_p(), maybe_predict_edge(), predicted_by_loop_heuristics_p(), prune_predictions_for_bb(), remove_predictions_associated_with_edge(), tree_estimate_probability(), and tree_guess_outgoing_edge_probabilities().
|
static |
Referenced by get_hot_bb_threshold(), and set_hot_bb_threshold().
|
static |
|
static |
String messages for the aforementioned enum.
Referenced by dump_prediction().
|
static |
Referenced by expr_expected_value_1(), tree_estimate_probability(), and tree_guess_outgoing_edge_probabilities().