• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -loops -analyze -enable-new-pm=0 < %s | FileCheck %s
2; RUN: opt -passes='print<loops>' -disable-output %s 2>&1 | FileCheck %s
3;
4; void func(long n, double A[static const restrict 4*n], double B[static const restrict 4*n]) {
5;   for (long i = 0; i < n; i += 1)
6;     for (long j = 0; j < n; j += 1)
7;       for (long k = 0; k < n; k += 1)
8;         for (long l = 0; l < n; l += 1) {
9;           A[i + j + k + l] = 21;
10;           B[i + j + k + l] = 42;
11;         }
12; }
13;
14; Check that isAnnotatedParallel is working as expected.
15;
16target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
17
18define void @func(i64 %n, double* noalias nonnull %A, double* noalias nonnull %B) {
19entry:
20  br label %for.cond
21
22for.cond:
23  %i.0 = phi i64 [ 0, %entry ], [ %add28, %for.inc27 ]
24  %cmp = icmp slt i64 %i.0, %n
25  br i1 %cmp, label %for.cond2, label %for.end29
26
27for.cond2:
28  %j.0 = phi i64 [ %add25, %for.inc24 ], [ 0, %for.cond ]
29  %cmp3 = icmp slt i64 %j.0, %n
30  br i1 %cmp3, label %for.cond6, label %for.inc27
31
32for.cond6:
33  %k.0 = phi i64 [ %add22, %for.inc21 ], [ 0, %for.cond2 ]
34  %cmp7 = icmp slt i64 %k.0, %n
35  br i1 %cmp7, label %for.cond10, label %for.inc24
36
37for.cond10:
38  %l.0 = phi i64 [ %add20, %for.body13 ], [ 0, %for.cond6 ]
39  %cmp11 = icmp slt i64 %l.0, %n
40  br i1 %cmp11, label %for.body13, label %for.inc21
41
42for.body13:
43  %add = add nuw nsw i64 %i.0, %j.0
44  %add14 = add nuw nsw i64 %add, %k.0
45  %add15 = add nuw nsw i64 %add14, %l.0
46  %arrayidx = getelementptr inbounds double, double* %A, i64 %add15
47  store double 2.100000e+01, double* %arrayidx, align 8, !llvm.access.group !5
48  %add16 = add nuw nsw i64 %i.0, %j.0
49  %add17 = add nuw nsw i64 %add16, %k.0
50  %add18 = add nuw nsw i64 %add17, %l.0
51  %arrayidx19 = getelementptr inbounds double, double* %B, i64 %add18
52  store double 4.200000e+01, double* %arrayidx19, align 8, !llvm.access.group !6
53  %add20 = add nuw nsw i64 %l.0, 1
54  br label %for.cond10, !llvm.loop !11
55
56for.inc21:
57  %add22 = add nuw nsw i64 %k.0, 1
58  br label %for.cond6, !llvm.loop !14
59
60for.inc24:
61  %add25 = add nuw nsw i64 %j.0, 1
62  br label %for.cond2, !llvm.loop !16
63
64for.inc27:
65  %add28 = add nuw nsw i64 %i.0, 1
66  br label %for.cond, !llvm.loop !18
67
68for.end29:
69  ret void
70}
71
72; access groups
73!7 = distinct !{}
74!8 = distinct !{}
75!10 = distinct !{}
76
77; access group lists
78!5 = !{!7, !10}
79!6 = !{!7, !8, !10}
80
81; LoopIDs
82!11 = distinct !{!11, !{!"llvm.loop.parallel_accesses", !10}}
83!14 = distinct !{!14, !{!"llvm.loop.parallel_accesses", !8, !10}}
84!16 = distinct !{!16, !{!"llvm.loop.parallel_accesses", !8}}
85!18 = distinct !{!18, !{!"llvm.loop.parallel_accesses", !7}}
86
87
88; CHECK: Parallel Loop at depth 1
89; CHECK-NOT: Parallel
90; CHECK:     Loop at depth 2
91; CHECK:         Parallel Loop
92; CHECK:             Parallel Loop
93