https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70308
Bug ID: 70308 Summary: memset generates rep stosl instead of rep stosq Product: gcc Version: 5.2.1 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: socketpair at gmail dot com Target Milestone: --- Consider this program: ============================= #include <string.h> #include <stdio.h> #include <unistd.h> int main() { char buf[128]; if (scanf("%s", buf) != 1) return 42; memset(buf,0, 128); asm volatile("": : :"memory"); return 0; } ============================== compile with -O3 and you will see, that memset is translated to "rep stosl". good. Next, comment line with scanf() and compile again and you will see, that memset is translated to "rep stosq", which is much faster. So, I consider that gcc should emit "rep stosq" in both cases.