Does any of current C++ compilers ever emit “rep movsb/w/d”?
Does any of current C++ compilers ever emit “rep movsb/w/d”? This question made me wonder, if current modern compilers ever emit REP MOVSB/W/D instruction. REP MOVSB/W/D Based on this discussion, it seems that using REP MOVSB/W/D could be beneficial on current CPUs. REP MOVSB/W/D But no matter how I tried, I cannot made any of the current compilers (GCC 8, Clang 7, MSVC 2017 and ICC 18) to emit this instruction. For this simple code, it could be reasonable to emit REP MOVSB : REP MOVSB void fn(char *dst, const char *src, int l) { for (int i=0; i<l; i++) { dst[i] = src[i]; } } But compilers emit a non-optimized simple byte-copy loop, or a huge unrolled loop (basically an inlined memmove ). Do any of the compilers use this instruction? memmove For that loop (without __restrict ), or ever? gcc has -mmemcpy-strategy=rep_4byte and -minline-all-stringops to override the tuning options. gcc.gnu.org/onlinedocs/gcc/x86-Options.html. ...