1 ; RUN: opt -passes=always-inline,globalopt -S < %s | FileCheck %s
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)
8 ; void caller(long n, double A[static const restrict n]) {
9 ; for (long i = 0; i < n; i += 1)
13 ; Check that the access groups (llvm.access.group) are correctly merged.
15 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
17 define internal void @callee(i64 %n, ptr noalias nonnull %A, i64 %i) #0 {
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
27 %mul = mul nsw i64 %i, %n
28 %add = add nsw i64 %mul, %j.0
29 %arrayidx = getelementptr inbounds double, ptr %A, i64 %add
30 store double 4.200000e+01, ptr %arrayidx, align 8, !llvm.access.group !6
31 %add1 = add nuw nsw i64 %j.0, 1
32 br label %for.cond, !llvm.loop !7
38 attributes #0 = { alwaysinline }
40 !6 = distinct !{} ; access group
41 !7 = distinct !{!7, !9} ; LoopID
42 !9 = !{!"llvm.loop.parallel_accesses", !6}
45 define void @caller(i64 %n, ptr noalias nonnull %A) {
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
55 call void @callee(i64 %n, ptr %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
63 !10 = distinct !{} ; access group
64 !11 = distinct !{!11, !12} ; LoopID
65 !12 = !{!"llvm.loop.parallel_accesses", !10}
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]+]]
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]]}