
MSVC 4.2 re-arranges inline asm
With global optimization enabled, Microsoft Visual C++ 4.2 may change
the following inline asm sequence:
cmp DL,0
jne rarely_taken
continue:
nop
jmp [pointer]
rarely_taken:
nop
jmp continue
to:
cmp DL,0
jne rarely_taken
jmp continue
// some other stuff
continue:
nop
jmp [pointer]
rarely_taken:
nop
jmp continue
On the Pentium, this will cost 1 cycle. There may be an additional
performance loss because the unconditional jump needs an entry in the
Branch Target Buffer.
To prevent the re-arrangement of inline asm, insert:
#pragma optimize("g", off)
before the function which contains inline assembler.