Implements type checking for cmp instruction.