• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
2;
3;    void bar();
4;    void foo(int *A, int *B, long int N, long int M) {
5;      for (long int j = 0; j < M; ++j) {
6;        bar();
7;        for (long int i = 0; i < N; ++i)
8;          A[i] += 1;
9;        for (long int i = 0; i < N; ++i)
10;          A[i] += 1;
11;      }
12;    }
13;
14; Test to check that the scop only counts loop depth for loops fully contained
15; in the scop.
16; CHECK: Max Loop Depth: 1
17target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
18
19define void @foo(i32* %A, i32* %B, i64 %N, i64 %M) {
20entry:
21  %cmp1 = icmp slt i64 0, %M
22  br i1 %cmp1, label %for.body1, label %for.end1
23
24  for.body1:                                         ; preds = %entry, %for.inc1
25    %j.0 = phi i64 [ 0, %entry ], [ %j.next, %for.inc1 ]
26    call void (...) @bar() #0
27    %cmp2 = icmp slt i64 0, %N
28    br i1 %cmp2, label %for.body2, label %for.end2
29
30  for.body2:                                        ; preds = %for.body1, %for.inc2
31    %i.1 = phi i64 [ 0, %for.body1 ], [ %i.next.1, %for.inc2 ]
32    %arrayidx = getelementptr inbounds i32, i32* %A, i64 %i.1
33    %tmp = load i32, i32* %arrayidx, align 4
34    %add = add nsw i32 %tmp, 1
35    store i32 %add, i32* %arrayidx, align 4
36    br label %for.inc2
37
38  for.inc2:                                          ; preds = %for.body2
39    %i.next.1 = add nuw nsw i64 %i.1, 1
40    %cmp3 = icmp slt i64 %i.next.1, %N
41    br i1 %cmp3, label %for.body2, label %for.end2
42
43
44  for.end2:                                          ; preds = %for.inc2, %for.body1
45    %cmp4 = icmp slt i64 0, %N
46    br i1 %cmp4, label %for.body3, label %for.end3
47
48  for.body3:					   ; preds = %for.end2
49    %i.2 = phi i64 [ 0, %for.end2 ], [ %i.next.2, %for.inc3 ]
50    %arrayidx1 = getelementptr inbounds i32, i32* %A, i64 %i.2
51    %tmp1 = load i32, i32* %arrayidx1, align 4
52    %add1 = add nsw i32 %tmp1, 1
53    store i32 %add1, i32* %arrayidx1, align 4
54    br label %for.inc3
55
56  for.inc3:					  ; preds = %for.body3
57    %i.next.2 = add nuw nsw i64 %i.2, 1
58    %cmp5 = icmp slt i64 %i.next.2, %N
59    br i1 %cmp5, label %for.body3, label %for.end3
60
61  for.end3:					  ; preds = %for.inc3, %for.end2
62    br label %for.inc1
63
64  for.inc1:					  ; preds = %for.end3
65    %j.next = add nuw nsw i64 %j.0, 1
66    %cmp6 = icmp slt i64 %j.next, %M
67    br i1 %cmp6, label %for.body1, label %for.end1
68
69  for.end1:                                        ; preds = %entry, %for.inc1
70    ret void
71  }
72
73declare void @bar(...) #0
74