Most of the x86 instructions will automatically alter the flags depending on the result. Sometimes this is rather frustrating because you actually what to preserve the flags as long as possible, and sometimes you miss a “mov eax, ecx” which alters the flags. But at least it’s guaranteed that an instruction either sets the flags or it doesn’t touch them, independent of the actual operation… Or is it?
There is the familiy of shift instructions. A “shl eax, cl” will *only* set the sign/zero flags according to the result if cl != 0 (mod 32). Why would anyone want that? Can someone think of a not so artificial situation, where this is useful? And I’m quite sure it is harder to design a processor which handles this special case correctly (let alone pipeline considerations).
Because of this odd behavior, a compiler has to translate
if (a >> b) this(); else that();
to something like
shr eax, cl
test eax, eax
And BTW, the rotate instructions never alter the SF/ZF flags.