1; RUN: opt < %s -instcombine -S | FileCheck %s
2;
3; Make sure the llvm.mem.parallel_loop_access meta-data is preserved
4; when a memcpy is replaced with a load+store by instcombine
5;
6; #include <string.h>
7; void test(char* out, long size)
8; {
9;     #pragma clang loop vectorize(assume_safety)
10;     for (long i = 0; i < size; i+=2) {
11;         memcpy(&(out[i]), &(out[i+size]), 2);
12;     }
13; }
14
15; CHECK: for.body:
16; CHECK:  %{{.*}} = load i16, i16* %{{.*}}, align 1, !llvm.mem.parallel_loop_access !1
17; CHECK:  store i16 %{{.*}}, i16* %{{.*}}, align 1, !llvm.mem.parallel_loop_access !1
18
19
20; ModuleID = '<stdin>'
21source_filename = "memcpy.pragma.cpp"
22target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
23target triple = "x86_64-unknown-linux-gnu"
24
25; Function Attrs: nounwind uwtable
26define void @_Z4testPcl(i8* %out, i64 %size) #0 {
27entry:
28  br label %for.cond
29
30for.cond:                                         ; preds = %for.inc, %entry
31  %i.0 = phi i64 [ 0, %entry ], [ %add2, %for.inc ]
32  %cmp = icmp slt i64 %i.0, %size
33  br i1 %cmp, label %for.body, label %for.end
34
35for.body:                                         ; preds = %for.cond
36  %arrayidx = getelementptr inbounds i8, i8* %out, i64 %i.0
37  %add = add nsw i64 %i.0, %size
38  %arrayidx1 = getelementptr inbounds i8, i8* %out, i64 %add
39  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %arrayidx, i8* %arrayidx1, i64 2, i1 false), !llvm.mem.parallel_loop_access !1
40  br label %for.inc
41
42for.inc:                                          ; preds = %for.body
43  %add2 = add nsw i64 %i.0, 2
44  br label %for.cond, !llvm.loop !2
45
46for.end:                                          ; preds = %for.cond
47  ret void
48}
49
50; Function Attrs: argmemonly nounwind
51declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i1) #1
52
53attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
54attributes #1 = { argmemonly nounwind }
55
56!llvm.ident = !{!0}
57
58!0 = !{!"clang version 4.0.0 (cfe/trunk 277751)"}
59!1 = distinct !{!1, !2, !3}
60!2 = distinct !{!2, !3}
61!3 = !{!"llvm.loop.vectorize.enable", i1 true}
62