blob: a53efb75302092453a7c46e134a3708d8db52276 [file] [log] [blame]
Eric Christophercee313d2019-04-17 04:52:47 +00001; RUN: opt -always-inline -globalopt -S < %s | FileCheck %s
2;
3; static void __attribute__((always_inline)) callee(long n, double A[static const restrict n], long i) {
4; for (long j = 0; j < n; j += 1)
5; A[i * n + j] = 42;
6; }
7;
8; void caller(long n, double A[static const restrict n]) {
9; for (long i = 0; i < n; i += 1)
10; callee(n, A, i);
11; }
12;
13; Check that the access groups (llvm.access.group) are correctly merged.
14;
15target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
16
17define internal void @callee(i64 %n, double* noalias nonnull %A, i64 %i) #0 {
18entry:
19 br label %for.cond
20
21for.cond:
22 %j.0 = phi i64 [ 0, %entry ], [ %add1, %for.body ]
23 %cmp = icmp slt i64 %j.0, %n
24 br i1 %cmp, label %for.body, label %for.end
25
26for.body:
27 %mul = mul nsw i64 %i, %n
28 %add = add nsw i64 %mul, %j.0
29 %arrayidx = getelementptr inbounds double, double* %A, i64 %add
30 store double 4.200000e+01, double* %arrayidx, align 8, !llvm.access.group !6
31 %add1 = add nuw nsw i64 %j.0, 1
32 br label %for.cond, !llvm.loop !7
33
34for.end:
35 ret void
36}
37
38attributes #0 = { alwaysinline }
39
40!6 = distinct !{} ; access group
41!7 = distinct !{!7, !9} ; LoopID
42!9 = !{!"llvm.loop.parallel_accesses", !6}
43
44
45define void @caller(i64 %n, double* noalias nonnull %A) {
46entry:
47 br label %for.cond
48
49for.cond:
50 %i.0 = phi i64 [ 0, %entry ], [ %add, %for.body ]
51 %cmp = icmp slt i64 %i.0, %n
52 br i1 %cmp, label %for.body, label %for.end
53
54for.body:
55 call void @callee(i64 %n, double* %A, i64 %i.0), !llvm.access.group !10
56 %add = add nuw nsw i64 %i.0, 1
57 br label %for.cond, !llvm.loop !11
58
59for.end:
60 ret void
61}
62
63!10 = distinct !{} ; access group
64!11 = distinct !{!11, !12} ; LoopID
65!12 = !{!"llvm.loop.parallel_accesses", !10}
66
67
68; CHECK: store double 4.200000e+01, {{.*}} !llvm.access.group ![[ACCESS_GROUP_LIST_3:[0-9]+]]
69; CHECK: br label %for.cond.i, !llvm.loop ![[LOOP_INNER:[0-9]+]]
70; CHECK: br label %for.cond, !llvm.loop ![[LOOP_OUTER:[0-9]+]]
71
72; CHECK: ![[ACCESS_GROUP_LIST_3]] = !{![[ACCESS_GROUP_INNER:[0-9]+]], ![[ACCESS_GROUP_OUTER:[0-9]+]]}
73; CHECK: ![[ACCESS_GROUP_INNER]] = distinct !{}
74; CHECK: ![[ACCESS_GROUP_OUTER]] = distinct !{}
75; CHECK: ![[LOOP_INNER]] = distinct !{![[LOOP_INNER]], ![[ACCESSES_INNER:[0-9]+]]}
76; CHECK: ![[ACCESSES_INNER]] = !{!"llvm.loop.parallel_accesses", ![[ACCESS_GROUP_INNER]]}
77; CHECK: ![[LOOP_OUTER]] = distinct !{![[LOOP_OUTER]], ![[ACCESSES_OUTER:[0-9]+]]}
78; CHECK: ![[ACCESSES_OUTER]] = !{!"llvm.loop.parallel_accesses", ![[ACCESS_GROUP_OUTER]]}