Test of 8 subsequent bytes isn't translated into a single compare instruction
问题 Motivated by this question, I compared three different functions for checking if 8 bytes pointed to by the argument are zeros (note that in the original question, characters are compared with '0' , not 0 ): bool f1(const char *ptr) { for (int i = 0; i < 8; i++) if (ptr[i]) return false; return true; } bool f2(const char *ptr) { bool res = true; for (int i = 0; i < 8; i++) res &= (ptr[i] == 0); return res; } bool f3(const char *ptr) { static const char tmp[8]{}; return !std::memcmp(ptr, tmp, 8