This patch adds support for memmove formation to LoopIdiomRecognize.cpp, which fixes llvm.org/PR25165.
The following loops now optimize to a memmove.
void copy(int *begin, int *end, int *out) {
for (; begin != end; ++begin, ++out)
*out = *begin;
}
void copy2(int *dest, int *source, int size) {
for (int i=0; i < size; ++i)
dest[i] = source[i];
}
void copy3(int *arr) {
for (int i=0; i < 1023; ++i)
arr[i] = arr[i+1];
}
Why the check for HasMemcpy here? Seems a bit odd to check it here rather than later....