Ok for google branch with minor changes below. thanks,
David >> +static bool non_zero_profile_counts ( VEC(edge,gc) *edges) { static bool non_zero_profile_counts(...) Please also provide function documentation. >> + edge e; >> + edge_iterator ei; >> + FOR_EACH_EDGE(e, ei, edges) >> + { >> + if (e->count > 0) >> + return true; >> + } >> + return false; >> +} >> +#define case_probability(x, y) ((y) ? ((x) * REG_BR_PROB_BASE / (y)) : -1) >> + Using upper case for macro? >> + int default_count = 0; int --> gcov_type >> + int count = bb->count; int --> gcov_type >> table_label = gen_label_rtx (); >> if (! try_casesi (index_type, index_expr, minval, range, >> table_label, default_label, fallback_label)) >> { >> bool ok; >> + int default_probability; >> >> + if (has_gaps) >> + { >> + /* There is at least one entry in the jump table that >> jumps >> + to default label. The default label can either be >> reached >> + through the indirect jump or the direct conditional >> jump >> + before that. Split the probability of reaching the >> + default label among these two jumps. */ >> + default_probability = case_probability (default_count/2, >> + bb->count); Some heuristics can probably be developed to make better split of the default probability and value range information can be used. For instance, if the case values are from an enum and the gaps between two enumerators are defined, then the preceding conditional jump should have get 100% of the default probability. This can be enhanced later. >> + count -= default_count; >> + default_count = 0; Why resetting it to 0? >> + >> +static void >> +add_prob_note_to_last_insn(int probability) >> +{ Missing document.