I've got a crash under GCC 4.9/x86_64 when using -O3. (The crash is related to an array that's 64-bit aligned, but GCC selects the vmovdqa instruction, which has 128-bit alignment requirements.) It was easy enough to back-off optimizations: #pragma GCC optimize push #pragma GCC optimize ("-O2") void xorbuf(byte *buf, const byte *mask, size_t count) { ... } #pragma GCC optimize pop However, I need to guard it for non-GCC compilers and down-level version of GCC, like 4.2.1 (still used on OpenBSD). Compiling with -Wall is a mess, otherwise. The man page on pragma optimize does not offer a "first available in ...". Cf., https://gcc.gnu.org/onlinedocs/gcc/Function-Specific-Option-Pragmas.html. When did 'pragma optimize' become available?