http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54132
Bug #: 54132 Summary: Incorrect loop transformation with -ftree-loop-distribute-patterns Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: m...@mansr.com The following function is incorrectly optimised when -ftree-loop-distribute-patterns is used (enabled by -O3): void foo(char *p, int n) { int i; for (i = 0; i < n; i++) p[i] = p[i - 1]; } The loop is replaced by a call to memmove(), whereas the correct operation is equivalent to memset(p, p[-1], n).