For static branch prediction one always assume that the branch is not taken, while for dynamic branch prediction if the branch is taken before then it is more likely to be taken again. But I cannot come up with a situation that this is useful? What application will benefit from this? Why not just use static branch prediction?
Answer
boolean b = compute something;
:
for (int j=0; j<1000000; j++)
if (b) one statement;
else another statement;
The if
will cause a conditional branch with the same taken/not taken result each time, but that may vary from one run to the next.
(I know one could write that code a little better with the if
controlling a couple of if-free for-loops, but that's not the point here)
No comments:
Post a Comment