I'd like to know how to write efficient jump tables for x64 processors, either in C, C++ or assembly. The input is known in advance, but impossible to predict algorithmically. Assuming I can look as far ahead as I want in the input stream, is there any way I can dynamically tell the CPU which address the next branch is going to go?
Essentially, I'd like to programmatically update the Branch Target Buffer. But I'd settle for anything that allows me to avoid flushing the pipeline in cases where I the programmer know in advance where the next branch is going by looking at the data but the processor cannot determine this from past patterns.
Realizing this is a very specific question and that I'm likely to have failed to convey it properly, here are a few alternate phrasings:
Is there an x64 equivalent to hbr
Hint for Branch on the Cell processor?
Does it ever help to move an assembly cmp
earlier than its conditional branch as it did with Itanium?
Is the predicted target of an indirect jump ever based on a register value instead of the last address used?
Thanks!