Add missing header
Change same_mem to use XORs instead of equality operators.

Potentially less prone to optimizer trickery wrt early exits,
especially as it encourages a SIMD approach which modern compilers
tend to prefer if they think they can get away with it.