You see this because of an attempt to debug release builds
Try debugging the "debug" assembly. You should see the behavior you expect. When debugging an optimized assembly, the lines are not necessarily βalignedβ with the source code. As far as you know, the optimizer decided that it is best to run both of them and throw it away if it is not needed.
Note. I do not suggest that the optimizer do this, I just say that it is possible, and that you can really see which line is executed next. The optimizer is free to reorder code, unroll loops, maintain constants, delete variables, add temporary ones, etc. Etc. Etc.
Change - Extra Thoughts
When you go to the hardware level, things can become really reordered. The hardware can choose to run both sides of the branch before it finds out which one should be taken so that the answer is ready as soon as necessary. He will do this, even if it means discarding another job, as this may lead to faster execution.
pstrjds
source share