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.

llvm-svn: 166877
diff --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
index 495d403..bc8ae66 100644
--- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ b/llvm/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());