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