Did you mean to ask "how does the cpu decide whether an operand is signed"? Because that's what your question looks like. The answer would be: it doesn't. Values are neither signed nor really unsigned, they're just "a bunch of bits". Instructions can have signed or unsigned variants, such as branches (but not comparisons), division, right shift, and long-multiplication. Addition, subtraction (and comparison, which is subtraction that only affects the flags) and short-multiplication (where you don't get that extra upper-half) do not have both signed and unsigned versions, but one version that's correct for both. The result is not affected by signedness.
For those instructions where the result is not affected by signedness, the flags sometimes are. ZF and SF are obviously the same either way, but signedness clearly matters for when there is overflow. But since OF and CF are separate flags, they can be set the different values.
For example, mov eax, -2 \ add eax, eax sets CF because there's unsigned overflow, but it doesn't set OF because there's no signed overflow. You can interpret it as a signed addition that didn't overflow or as an unsigned addition that did overflow (or even as both, but that's almost never useful), but the only difference is in which flags you care about.
The compiler obviously knows what's supposed to be signed and what is supposed to be unsigned, and can therefore choose between sar and shr (for right shift) and between idiv and div (for division) and it chooses the CC for cmovcc and jcc.