Hi Martin,
On Fri, Jul 22, 2016 at 10:17:51AM +0200, Martin Liška wrote:
> /* We can not predict the probabilities of outgoing edges of bb. Set them
> - evenly and hope for the best. */
> + evenly and hope for the best. If UNLIKELY_EDGES is not null, distribute
> + evel probability for all edges not mentioned in the set. These edges
> + are given PROB_VERY_UNLIKELY probability. */
Typo ("evel");
> + unsigned unlikely_count = unlikely_edges ? unlikely_edges->elements () : 0;
> +
> FOR_EACH_EDGE (e, ei, bb->succs)
> if (!(e->flags & (EDGE_EH | EDGE_FAKE)))
> nedges ++;
> +
> + unsigned c = nedges - unlikely_count;
What prevents c from becoming 0? The sum of outgoing edge probabilities
will be very small then (unless there are very many such noreturn edges,
then the sum is too big, instead).
> FOR_EACH_EDGE (e, ei, bb->succs)
> if (!(e->flags & (EDGE_EH | EDGE_FAKE)))
> - e->probability = (REG_BR_PROB_BASE + nedges / 2) / nedges;
> + {
> + if (unlikely_edges != NULL && unlikely_edges->contains (e))
> + e->probability = PROB_VERY_UNLIKELY;
> + else
> + e->probability = (REG_BR_PROB_BASE + c / 2) / c;
> + }
> else
> e->probability = 0;
> }
Even in the normal case, the sum of probabilities will not be almost 1
this way (almost REG_BR_PROB_BASE), but somewhat bigger.
Segher