blob: ad13e3e166a3d6c998eb39f6b970404f6a19c60d [file] [log] [blame]
Johannes Doerfertf8206cf2015-04-12 22:58:40 +00001; RUN: opt %loadPolly -polly-detect -polly-allow-nonaffine-branches -polly-allow-nonaffine-loops=false -analyze < %s | FileCheck %s --check-prefix=REJECTNONAFFINELOOPS
2; RUN: opt %loadPolly -polly-detect -polly-allow-nonaffine-branches -polly-allow-nonaffine-loops=true -analyze < %s | FileCheck %s --check-prefix=ALLOWNONAFFINELOOPS
3; RUN: opt %loadPolly -polly-detect -polly-allow-nonaffine-branches -polly-allow-nonaffine-loops=true -polly-allow-nonaffine -analyze < %s | FileCheck %s --check-prefix=ALLOWNONAFFINELOOPSANDACCESSES
4; RUN: opt %loadPolly -polly-detect -polly-allow-nonaffine-branches -polly-allow-nonaffine-loops=true -polly-allow-nonaffine -polly-detect-scops-in-regions-without-loops -analyze < %s | FileCheck %s --check-prefix=ALLOWNONAFFINELOOPSANDACCESSESANDNOLOOPS
5;
6; This function/region does contain a loop, however it is non-affine, hence the access
7; A[i] is also. Furthermore, it is the only loop, thus when we over approximate
8; non-affine loops __and__ accesses __and__ allow regins without a (affine) loop we will
9; detect it, otherwise we won't.
10;
11; void f(int *A) {
12; for (int i = 0; i < A[i]; i++)
13; A[-1]++;
14; }
15;
16; REJECTNONAFFINELOOPS-NOT: Valid
17; ALLOWNONAFFINELOOPS-NOT: Valid
18; ALLOWNONAFFINELOOPSANDACCESSES-NOT: Valid
19; ALLOWNONAFFINELOOPSANDACCESSESANDNOLOOPS: Valid Region for Scop: bb1 => bb10
20;
21target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
22
23define void @f(i32* %A) {
24bb:
25 br label %bb1
26
27bb1: ; preds = %bb9, %bb
28 %indvars.iv = phi i64 [ %indvars.iv.next, %bb9 ], [ 0, %bb ]
29 %tmp = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
30 %tmp2 = load i32, i32* %tmp, align 4
31 %tmp3 = sext i32 %tmp2 to i64
32 %tmp4 = icmp slt i64 %indvars.iv, %tmp3
33 br i1 %tmp4, label %bb5, label %bb10
34
35bb5: ; preds = %bb1
36 %tmp6 = getelementptr inbounds i32, i32* %A, i64 -1
37 %tmp7 = load i32, i32* %tmp6, align 4
38 %tmp8 = add nsw i32 %tmp7, 1
39 store i32 %tmp8, i32* %tmp6, align 4
40 br label %bb9
41
42bb9: ; preds = %bb5
43 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
44 br label %bb1
45
46bb10: ; preds = %bb1
47 ret void
48}