1 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 ; Make sure the llvm.access.group meta-data is preserved
4 ; when a memcpy is replaced with a load+store by instcombine
7 ; void test(char* out, long size)
9 ; #pragma clang loop vectorize(assume_safety)
10 ; for (long i = 0; i < size; i+=2) {
11 ; memcpy(&(out[i]), &(out[i+size]), 2);
16 ; CHECK: %{{.*}} = load i16, i16* %{{.*}}, align 1, !llvm.access.group !1
17 ; CHECK: store i16 %{{.*}}, i16* %{{.*}}, align 1, !llvm.access.group !1
20 ; ModuleID = '<stdin>'
21 source_filename = "memcpy.pragma.cpp"
22 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
23 target triple = "x86_64-unknown-linux-gnu"
25 ; Function Attrs: nounwind uwtable
26 define void @_Z4testPcl(i8* %out, i64 %size) #0 {
30 for.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
35 for.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.access.group !4
42 for.inc: ; preds = %for.body
43 %add2 = add nsw i64 %i.0, 2
44 br label %for.cond, !llvm.loop !2
46 for.end: ; preds = %for.cond
50 ; Function Attrs: argmemonly nounwind
51 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i1) #1
53 attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "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" }
54 attributes #1 = { argmemonly nounwind }
58 !0 = !{!"clang version 4.0.0 (cfe/trunk 277751)"}
59 !1 = distinct !{!1, !2, !3, !{!"llvm.loop.parallel_accesses", !4}}
60 !2 = distinct !{!2, !3}
61 !3 = !{!"llvm.loop.vectorize.enable", i1 true}
62 !4 = distinct !{} ; access group