1 ; RUN: opt %loadNPMPolly -aa-pipeline=basic-aa -polly-allow-nonaffine-branches -polly-allow-nonaffine-loops=false '-passes=print<polly-detect>' -disable-output < %s 2>&1 | FileCheck %s --check-prefix=REJECTNONAFFINELOOPS
2 ; RUN: opt %loadNPMPolly -aa-pipeline=basic-aa -polly-allow-nonaffine-branches -polly-allow-nonaffine-loops=true '-passes=print<polly-detect>' -disable-output < %s 2>&1 | FileCheck %s --check-prefix=ALLOWNONAFFINELOOPS
3 ; RUN: opt %loadNPMPolly -aa-pipeline=basic-aa -polly-allow-nonaffine-branches -polly-allow-nonaffine-loops=true -polly-allow-nonaffine '-passes=print<polly-detect>' -disable-output < %s 2>&1 | FileCheck %s --check-prefix=ALLOWNONAFFINELOOPSANDACCESSES
5 ; Here we have a non-affine loop (in the context of the loop nest)
6 ; and also a non-affine access (A[k]). While we can always detect the
7 ; innermost loop as a SCoP of depth 1, we have to reject the loop nest if not
8 ; both, non-affine loops as well as non-affine accesses are allowed.
10 ; REJECTNONAFFINELOOPS: Valid Region for Scop: bb15 => bb13
11 ; REJECTNONAFFINELOOPS-NOT: Valid
12 ; ALLOWNONAFFINELOOPS: Valid Region for Scop: bb15 => bb13
13 ; ALLOWNONAFFINELOOPS-NOT: Valid
14 ; ALLOWNONAFFINELOOPSANDACCESSES: Valid Region for Scop: bb11 => bb29
17 ; for (int i = 0; i < 1024; i++)
18 ; for (int j = 0; j < 1024; j++)
19 ; for (int k = i *j; k < 1024; k++)
20 ; A[k] += A[i] + A[j];
23 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
25 define void @f(ptr %A) {
29 bb11: ; preds = %bb28, %bb
30 %indvars.iv8 = phi i64 [ %indvars.iv.next9, %bb28 ], [ 0, %bb ]
31 %indvars.iv1 = phi i64 [ %indvars.iv.next2, %bb28 ], [ 0, %bb ]
32 %exitcond10 = icmp ne i64 %indvars.iv8, 1024
33 br i1 %exitcond10, label %bb12, label %bb29
38 bb13: ; preds = %bb26, %bb12
39 %indvars.iv5 = phi i64 [ %indvars.iv.next6, %bb26 ], [ 0, %bb12 ]
40 %indvars.iv3 = phi i64 [ %indvars.iv.next4, %bb26 ], [ 0, %bb12 ]
41 %exitcond7 = icmp ne i64 %indvars.iv5, 1024
42 br i1 %exitcond7, label %bb14, label %bb27
47 bb15: ; preds = %bb24, %bb14
48 %indvars.iv = phi i64 [ %indvars.iv.next, %bb24 ], [ %indvars.iv3, %bb14 ]
49 %exitcond = icmp ne i64 %indvars.iv, 1024
50 br i1 %exitcond, label %bb16, label %bb25
53 %tmp = getelementptr inbounds i32, ptr %A, i64 %indvars.iv8
54 %tmp17 = load i32, ptr %tmp, align 4
55 %tmp18 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv5
56 %tmp19 = load i32, ptr %tmp18, align 4
57 %tmp20 = add nsw i32 %tmp17, %tmp19
58 %tmp21 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
59 %tmp22 = load i32, ptr %tmp21, align 4
60 %tmp23 = add nsw i32 %tmp22, %tmp20
61 store i32 %tmp23, ptr %tmp21, align 4
65 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
72 %indvars.iv.next6 = add nuw nsw i64 %indvars.iv5, 1
73 %indvars.iv.next4 = add nuw nsw i64 %indvars.iv3, %indvars.iv1
80 %indvars.iv.next9 = add nuw nsw i64 %indvars.iv8, 1
81 %indvars.iv.next2 = add nuw nsw i64 %indvars.iv1, 1