branch prediction on a function pointer

Yes, reasonably recent processors can do (at least something like) branch prediction for indirect jumps.

From the Pentium (Intel's first to do branch prediction) through the first Pentium IV's, all that was used for indirect branches was the Branch Target Buffer (BTB). This meant that they "predicted" such branches correctly when (and only when) the target was exactly identical to the previous target--which sounds like it's adequate for your case.

Starting with the Pentium M/Prescott (the last Pentium IV) Intel improved branch prediction for indirect jumps to use a two-level adaptive predictor. If I'm understanding your question correctly (i.e., your loop will execute with the same target for many consecutive iterations, and those are what you care about) even just the BTB would be sufficient for your purposes. The two level predictor would become more useful if (for example) you were branching on the least significant bit of consecutive numbers, so you had a predictable pattern of jumping to one target in one iteration, and the other in the next iteration. With a pattern like this, the BTB alone would always predict the branch incorrectly, but the two-level predictor in a current processor would predict correctly (after the first couple of iterations, so the pattern could be detected).


From The microarchitecture of Intel, AMD and VIA CPUs An optimization guide for assembly programmers and compiler makers

http://www.agner.org/optimize/microarchitecture.pdf

section 3.7 (for Sandy Bridge, other processors are in other sections) Pattern recognition for indirect jumps and calls Indirect jumps and indirect calls (but not returns) are predicted using the same two-level predictor as branch instructions.

A pointer to a function is an indirect call.