LoopIdiom: Add checks to avoid turning memmove into an infinite loop.

I don't think this is possible with the current implementation but that may change eventually.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166877 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
index 495d403..bc8ae66 100644
--- a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
@@ -178,7 +178,7 @@
 
   // Disable loop idiom recognition if the function's name is a common idiom.
   StringRef Name = L->getHeader()->getParent()->getName();
-  if (Name == "memset" || Name == "memcpy")
+  if (Name == "memset" || Name == "memcpy" || Name == "memmove")
     return false;
 
   // The trip count of the loop must be analyzable.
@@ -524,7 +524,7 @@
                            const SCEVAddRecExpr *LoadEv,
                            const SCEV *BECount) {
   // If we're not allowed to form memcpy, we fail.
-  if (!TLI->has(LibFunc::memcpy))
+  if (!TLI->has(LibFunc::memcpy) || !TLI->has(LibFunc::memmove))
     return false;
 
   LoadInst *LI = cast<LoadInst>(SI->getValueOperand());