call void @llvm.memcpy.p0i8.p0i8.i32(i8* %agg.result2, i8* %x.01, i32 32, i32 16, i1 false)
ret void
; CHECK: @test3
-; CHECK-NEXT: %agg.result2 = bitcast
+; CHECK-NEXT: %agg.result1 = bitcast
; CHECK-NEXT: call void @llvm.memcpy
; CHECK-NEXT: ret void
}
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
+; PR11142 - When looking for a memcpy-memcpy dependency, don't get stuck on
+; instructions between the memcpy's that only affect the destination pointer.
+@test8.str = internal constant [7 x i8] c"ABCDEF\00"
+
+define void @test8() {
+; CHECK: test8
+; CHECK-NOT: memcpy
+ %A = tail call i8* @malloc(i32 10)
+ %B = getelementptr inbounds i8* %A, i64 2
+ tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %B, i8* getelementptr inbounds ([7 x i8]* @test8.str, i64 0, i64 0), i32 7, i32 1, i1 false)
+ %C = tail call i8* @malloc(i32 10)
+ %D = getelementptr inbounds i8* %C, i64 2
+ tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %D, i8* %B, i32 7, i32 1, i1 false)
+ ret void
+; CHECK: ret void
+}
+
+declare noalias i8* @malloc(i32)