https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78809
--- Comment #12 from Richard Earnshaw <rearnsha at gcc dot gnu.org> --- (In reply to Qing Zhao from comment #7) > on the other hand, memcmp will NOT early stop, it will compare exactly N > bytes of both buffers. As a result, the compiler can compare multiple bytes > at one time. > That's not entirely correct. Notionally memcmp needs to return a value representing the relative difference of the first different byte in the compared areas of memory; any later bytes are irrelevant. Yes the compiler can compare multiple bytes at the same time and it does not have to worry about page faulting, but it does have to keep track of where the first difference occurs. Of course, the compiler can see how the result is used to optimize things further; a simple equality test will allow the compiler to generate a simpler sequence that could access all bytes and accumulate the overall result.