All CPUs have ALUs. I won't post Wikipedia links as you are good enough to find by yourself ;) but I can teach you a bit about CPU's internal.
What you basically need to know is that all CPUs have comparison instructions, ie BEQ "Branch-on-Equal" which is used to implement "if" instructions and jumps if A == B (there is another instruction for A < B, etc). When CPU reads this instruction and the operands, it loads them in the two ALU input buses and sets a proper ALU code that represents the comparison operation. The ALU is built to compare the numbers via hardware and output a proper result on its output side, or setting a status bit on the CPU.
Hardware comparison of numbers is easy, and almost all academic student have once designed a comparison (from 4 to 8 bits, but same logic applies to 32 and 64), you can find schematics anywhere