Currently, when tcp_input() receives a packet on a session that matches a TCPCB, it checks (so->so_options & SO_ACCEPTCONN) to determine whether or not the socket is a listening socket. However, this causes the code to access a different cacheline. If we first check if the socket is in the LISTEN state, we can avoid accessing so->so_options for ESTABLISHED packets.
If INVARIANTS is defined, the code still needs to access both to check that so->so_options is consistent with the state. (That's just the penalty you pay for running INVARIANTS.)