Question: This is more for the sake of curiosity than anything else. If I have a Java operator if/elseand I know that one of the branches of the if / else statement will be taken much more often than the other, can I order two branches giving a JIT hint, which leads to better performance?
Background:
converted, inter alia, conditional branch instruction, followed by instructions that should be executed if the jump did not execute computer architecture operator "if / else" In my simplified representation. Somewhere else in memory will be the code that the transition was aiming for. As I understand it, the CPU loads the instructions sequentially to the extent possible (I’m sure that I don’t see the industry predictor here), and a path without a jump has a higher probability of loading the instruction cache and the CPU instruction pipeline.
Question Revised: Can well-reasoned orderings of operator branches if/elseincrease the likelihood that often executable code immediately follows a conditional branch instruction that will make the code more cache and pipe friendly?
Reality: I would not be surprised to hear that the JIT compiler is a complex program that, after all the reordering of commands, allocation of registers and other accounting documentation, such guarantees.
Most of my if if else statements will fail, so I won’t do it everywhere. In addition, many times I am mistaken as to which branch will be executed more often and ultimately actually worsens performance.
I would like to think that such a simple thing as intentional with branch ordering would not be considered a premature optimization, but if it is, I will only mess with ordering if the profiler shows me that the code is slow.
Thank!