brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · d34a99a Raw
79 lines · plain
1; RUN: opt  -passes=always-inline,globalopt -S < %s | FileCheck %s2;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, ptr noalias nonnull %A, i64 %i) #0 {18entry:19  br label %for.cond20 21for.cond:22  %j.0 = phi i64 [ 0, %entry ], [ %add1, %for.body ]23  %cmp = icmp slt i64 %j.0, %n24  br i1 %cmp, label %for.body, label %for.end25 26for.body:27  %mul = mul nsw i64 %i, %n28  %add = add nsw i64 %mul, %j.029  %arrayidx = getelementptr inbounds double, ptr %A, i64 %add30  store double 4.200000e+01, ptr %arrayidx, align 8, !llvm.access.group !631  %add1 = add nuw nsw i64 %j.0, 132  br label %for.cond, !llvm.loop !733 34for.end:35  ret void36}37 38attributes #0 = { alwaysinline }39 40!6 = distinct !{}       ; access group41!7 = distinct !{!7, !9} ; LoopID42!9 = !{!"llvm.loop.parallel_accesses", !6}43 44 45define void @caller(i64 %n, ptr noalias nonnull %A) {46entry:47  br label %for.cond48 49for.cond:50  %i.0 = phi i64 [ 0, %entry ], [ %add, %for.body ]51  %cmp = icmp slt i64 %i.0, %n52  br i1 %cmp, label %for.body, label %for.end53 54for.body:55  call void @callee(i64 %n, ptr %A, i64 %i.0), !llvm.access.group !1056  %add = add nuw nsw i64 %i.0, 157  br label %for.cond, !llvm.loop !1158 59for.end:60  ret void61}62 63!10 = distinct !{}         ; access group64!11 = distinct !{!11, !12} ; LoopID65!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]]}79