1 |
On Friday 16 May 2003 08:52 pm, Anupam Kapoor wrote: |
2 |
> i was under the assumption that most processors already perform branch |
3 |
> prediction. no ? do you think that -fbranch-probabilities provides a |
4 |
> more 'comprehensive' view of the executing program ? |
5 |
|
6 |
Yes, modern processors do perform branch prediction. But you're right, the |
7 |
compiler can do a much more 'comprehensive' job. |
8 |
|
9 |
The reason is that CPU branch prediction algorithms tend to forget any |
10 |
information they learn that occurred farther away in time or space than |
11 |
certain thresholds. The Xeon, I think, retains information only about the |
12 |
last 16 branching instructions and the direction of only the last four |
13 |
branches on each of those instructions. |
14 |
|
15 |
GCC, on the other hand, can retain information about all the branches, and |
16 |
complete directional statistics over the entire run, but it can only make |
17 |
static predictions. (For example, GCC can't take advantage of knowing that |
18 |
the branch will go one way for 200 consecutive times, then the other for |
19 |
300--it has to predict the branch will go the second way all the time and |
20 |
order accordingly.) |
21 |
|
22 |
So you get the best performance when you combine the two approaches. |
23 |
|
24 |
Evan |
25 |
|
26 |
-- |
27 |
gentoo-dev@g.o mailing list |