The ALU takes two operands and an operation code, and outputs a result plus flags such as carry (CF), zero (ZF), sign (SF) and overflow (OF). A cmp instruction is simply a subtraction whose result is thrown away: only the flags are kept.
Term
ALU (arithmetic logic unit)
The circuit inside the CPU that performs arithmetic and bitwise operations and produces the status flags.