• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %loadPolly -polly-detect -polly-allow-nonaffine-branches \
2; RUN:     -polly-allow-nonaffine-loops=false \
3; RUN:     -analyze < %s | FileCheck %s --check-prefix=REJECTNONAFFINELOOPS
4; RUN: opt %loadPolly -polly-detect -polly-allow-nonaffine-branches \
5; RUN:     -polly-allow-nonaffine-loops=true \
6; RUN:     -analyze < %s | FileCheck %s --check-prefix=ALLOWNONAFFINELOOPS
7; RUN: opt %loadPolly -polly-detect -polly-allow-nonaffine \
8; RUN:     -polly-allow-nonaffine-branches -polly-allow-nonaffine-loops=true \
9; RUN:     -analyze < %s \
10; RUN:     | FileCheck %s --check-prefix=ALLOWNONAFFINELOOPSANDACCESSES
11;
12; Here we have a non-affine loop (in the context of the loop nest)
13; and also a non-affine access (A[k]). While we can always detect the
14; innermost loop as a SCoP of depth 1, we have to reject the loop nest if not
15; both, non-affine loops as well as non-affine accesses are allowed.
16;
17; REJECTNONAFFINELOOPS:           Valid Region for Scop: bb15 => bb13
18; REJECTNONAFFINELOOPS-NOT:       Valid
19; ALLOWNONAFFINELOOPS:            Valid Region for Scop: bb15 => bb13
20; ALLOWNONAFFINELOOPS-NOT:        Valid
21; ALLOWNONAFFINELOOPSANDACCESSES: Valid Region for Scop: bb11 => bb29
22;
23;    void f(int *A) {
24;      for (int i = 0; i < 1024; i++)
25;        for (int j = 0; j < 1024; j++)
26;          for (int k = i *j;  k < 1024; k++)
27;            A[k] += A[i] + A[j];
28;    }
29;
30target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
31
32define void @f(i32* %A) {
33bb:
34  br label %bb11
35
36bb11:                                             ; preds = %bb28, %bb
37  %indvars.iv8 = phi i64 [ %indvars.iv.next9, %bb28 ], [ 0, %bb ]
38  %indvars.iv1 = phi i64 [ %indvars.iv.next2, %bb28 ], [ 0, %bb ]
39  %exitcond10 = icmp ne i64 %indvars.iv8, 1024
40  br i1 %exitcond10, label %bb12, label %bb29
41
42bb12:                                             ; preds = %bb11
43  br label %bb13
44
45bb13:                                             ; preds = %bb26, %bb12
46  %indvars.iv5 = phi i64 [ %indvars.iv.next6, %bb26 ], [ 0, %bb12 ]
47  %indvars.iv3 = phi i64 [ %indvars.iv.next4, %bb26 ], [ 0, %bb12 ]
48  %exitcond7 = icmp ne i64 %indvars.iv5, 1024
49  br i1 %exitcond7, label %bb14, label %bb27
50
51bb14:                                             ; preds = %bb13
52  br label %bb15
53
54bb15:                                             ; preds = %bb24, %bb14
55  %indvars.iv = phi i64 [ %indvars.iv.next, %bb24 ], [ %indvars.iv3, %bb14 ]
56  %exitcond = icmp ne i64 %indvars.iv, 1024
57  br i1 %exitcond, label %bb16, label %bb25
58
59bb16:                                             ; preds = %bb15
60  %tmp = getelementptr inbounds i32, i32* %A, i64 %indvars.iv8
61  %tmp17 = load i32, i32* %tmp, align 4
62  %tmp18 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv5
63  %tmp19 = load i32, i32* %tmp18, align 4
64  %tmp20 = add nsw i32 %tmp17, %tmp19
65  %tmp21 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
66  %tmp22 = load i32, i32* %tmp21, align 4
67  %tmp23 = add nsw i32 %tmp22, %tmp20
68  store i32 %tmp23, i32* %tmp21, align 4
69  br label %bb24
70
71bb24:                                             ; preds = %bb16
72  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
73  br label %bb15
74
75bb25:                                             ; preds = %bb15
76  br label %bb26
77
78bb26:                                             ; preds = %bb25
79  %indvars.iv.next6 = add nuw nsw i64 %indvars.iv5, 1
80  %indvars.iv.next4 = add nuw nsw i64 %indvars.iv3, %indvars.iv1
81  br label %bb13
82
83bb27:                                             ; preds = %bb13
84  br label %bb28
85
86bb28:                                             ; preds = %bb27
87  %indvars.iv.next9 = add nuw nsw i64 %indvars.iv8, 1
88  %indvars.iv.next2 = add nuw nsw i64 %indvars.iv1, 1
89  br label %bb11
90
91bb29:                                             ; preds = %bb11
92  ret void
93}
94