aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp4
-rw-r--r--test/Transforms/InstCombine/memmove.ll6
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 20204154d0..8c2dc3e92f 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -9131,6 +9131,10 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
CI.setOperand(0, Intrinsic::getDeclaration(M, MemCpyID));
Changed = true;
}
+
+ // memmove(x,x,size) -> noop.
+ if (MMI->getSource() == MMI->getDest())
+ return EraseInstFromFunction(CI);
}
// If we can determine a pointer alignment that is bigger than currently
diff --git a/test/Transforms/InstCombine/memmove.ll b/test/Transforms/InstCombine/memmove.ll
index 2cb346f112..09ec67d265 100644
--- a/test/Transforms/InstCombine/memmove.ll
+++ b/test/Transforms/InstCombine/memmove.ll
@@ -34,3 +34,9 @@ define i32 @test3() {
ret i32 0
}
+; PR2370
+define void @test4(i8* %a) {
+ tail call void @llvm.memmove.i32( i8* %a, i8* %a, i32 100, i32 1 )
+ ret void
+}
+