GCC Middle and Back End API Reference
predict.h File Reference
#include "predict.def"
Include dependency graph for predict.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DEF_PREDICTOR(ENUM, NAME, HITRATE, FLAGS)   ENUM,

Enumerations

enum  br_predictor { DEF_PREDICTOR }
enum  prediction { NOT_TAKEN, TAKEN }

Functions

void predict_insn_def (rtx, enum br_predictor, enum prediction)
int counts_to_freqs (void)
void estimate_bb_frequencies (bool)
const char * predictor_name (enum br_predictor)
tree build_predict_expr (enum br_predictor, enum prediction)
void tree_estimate_probability (void)
void compute_function_frequency (void)
void rebuild_frequencies (void)

Macro Definition Documentation

#define DEF_PREDICTOR (   ENUM,
  NAME,
  HITRATE,
  FLAGS 
)    ENUM,

Definitions for branch prediction routines in the GNU compiler. Copyright (C) 2001-2013 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/.


Enumeration Type Documentation

Enumerator:
DEF_PREDICTOR 

Definitions for the branch prediction routines in the GNU compiler. Copyright (C) 2001-2013 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/. Before including this file, you should define a macro:

DEF_PREDICTOR (ENUM, NAME, HITRATE)

This macro will be called once for each predictor. The ENUM will be of type `enum predictor', and will enumerate all supported predictors. The order of DEF_PREDICTOR calls is important, as in the first match combining heuristics, the predictor appearing first in this file will win.

NAME is used in the debugging output to determine predictor type.

HITRATE is the probability that edge predicted by predictor as taken will be really taken (so it should be always above REG_BR_PROB_BASE / 2). A value used as final outcome of all heuristics.

enum prediction
Enumerator:
NOT_TAKEN 
TAKEN 

Function Documentation

tree build_predict_expr ( enum  br_predictor,
enum  prediction 
)
void compute_function_frequency ( void  )

Decide whether function is hot, cold or unlikely executed.

Only first time try to drop function into unlikely executed. After inlining the roundoff errors may confuse us. Ipa-profile pass will drop functions only called from unlikely functions to unlikely and that is most of what we care about.

int counts_to_freqs ( void  )

Convert counts measured by profile driven feedback to frequencies. Return nonzero iff there was any nonzero execution count.

void estimate_bb_frequencies ( bool  )
void predict_insn_def ( rtx  insn,
enum br_predictor  predictor,
enum prediction  taken 
)

Predict insn by given predictor.

const char* predictor_name ( enum  br_predictor)
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.

When the max bb count in the function is small, there is a higher chance that there were truncation errors in the integer scaling of counts by inlining and other optimizations. This could lead to incorrect classification of code as being cold when it isn't. In that case, force the estimation of bb counts/frequencies from the branch probabilities, rather than computing frequencies from counts, which may also lead to frequencies incorrectly reduced to 0. There is less precision in the probabilities, so we only do this for small max counts.

Referenced by copy_static_chain().

void tree_estimate_probability ( void  )

Predict branch probabilities and estimate profile of the tree CFG. This function can be called from the loop optimizers to recompute the profile information.

We use loop_niter_by_eval, which requires that the loops have preheaders.