1; RUN: opt -S -inline < %s | FileCheck %s
2;
3; Check that the !llvm.access.group is still present after inlining.
4;
5target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6
7define void @Body(i32* nocapture %res, i32* nocapture readnone %c, i32* nocapture readonly %d, i32* nocapture readonly %p, i32 %i) {
8entry:
9  %idxprom = sext i32 %i to i64
10  %arrayidx = getelementptr inbounds i32, i32* %p, i64 %idxprom
11  %0 = load i32, i32* %arrayidx, align 4, !llvm.access.group !0
12  %cmp = icmp eq i32 %0, 0
13  %arrayidx2 = getelementptr inbounds i32, i32* %res, i64 %idxprom
14  %1 = load i32, i32* %arrayidx2, align 4, !llvm.access.group !0
15  br i1 %cmp, label %cond.end, label %cond.false
16
17cond.false:
18  %arrayidx6 = getelementptr inbounds i32, i32* %d, i64 %idxprom
19  %2 = load i32, i32* %arrayidx6, align 4, !llvm.access.group !0
20  %add = add nsw i32 %2, %1
21  br label %cond.end
22
23cond.end:
24  %cond = phi i32 [ %add, %cond.false ], [ %1, %entry ]
25  store i32 %cond, i32* %arrayidx2, align 4
26  ret void
27}
28
29define void @Test(i32* %res, i32* %c, i32* %d, i32* %p, i32 %n) {
30entry:
31  br label %for.cond
32
33for.cond:
34  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
35  %cmp = icmp slt i32 %i.0, 1600
36  br i1 %cmp, label %for.body, label %for.end
37
38for.body:
39  call void @Body(i32* %res, i32* undef, i32* %d, i32* %p, i32 %i.0), !llvm.access.group !0
40  %inc = add nsw i32 %i.0, 1
41  br label %for.cond, !llvm.loop !1
42
43for.end:
44  ret void
45}
46
47!0 = distinct !{}                                          ; access group
48!1 = distinct !{!1, !{!"llvm.loop.parallel_accesses", !0}} ; LoopID
49
50
51; CHECK-LABEL: @Test
52; CHECK: load i32,{{.*}}, !llvm.access.group !0
53; CHECK: load i32,{{.*}}, !llvm.access.group !0
54; CHECK: load i32,{{.*}}, !llvm.access.group !0
55; CHECK: store i32 {{.*}}, !llvm.access.group !0
56; CHECK: br label %for.cond, !llvm.loop !1
57