When generating code for a for-loop preamble after an if-statement, the generated code sometimes avoids oututting a CMP instruction and just outputs a conditional jump instruction reusing the previous values of the flags register.
It does this in /O2 and /O1 when the if-statement and the for-loop end up comparing the same pairs of registers.
However sometimes it gets the condition code wrong. In the attached example, a JGE instruction is selected instead of a JL.
Compiling with /Od produces the expected result. Incorrect behavior is observed in generating x86 and x64 code. Incorrect behavior also present in Visual Studio 2008 SP1.