3

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?

0

1 Answer 1

3
    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)

Not the answer you're looking for? Browse other questions tagged or ask your own question.