xref: /llvm-project/polly/test/ScopDetect/non-beneficial-loops-small-trip-count.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly -polly-process-unprofitable=false '-passes=print<polly-detect>' -disable-output < %s 2>&1 | FileCheck %s
2;
3; CHECK-NOT: Valid
4;
5; Do not consider this a SCoP as we do not perform any optimizations for
6; loops with a small trip count.
7;
8;    void f(int *A) {
9;      for (int i = 0; i < 4; i++)
10;        for (int j = 0; j < 4; j++)
11;          for (int k = 0; k < 4; k++)
12;            for (int l = 0; l < 4; l++)
13;              A[i] += A[i] * A[i - 1] + A[i + 1];
14;    }
15;
16target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
17
18define void @f(ptr %A) {
19entry:
20  br label %for.cond
21
22for.cond:                                         ; preds = %for.inc.24, %entry
23  %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc.24 ], [ 0, %entry ]
24  %exitcond5 = icmp ne i64 %indvars.iv, 4
25  br i1 %exitcond5, label %for.body, label %for.end.26
26
27for.body:                                         ; preds = %for.cond
28  br label %for.cond.1
29
30for.cond.1:                                       ; preds = %for.inc.21, %for.body
31  %j.0 = phi i32 [ 0, %for.body ], [ %inc22, %for.inc.21 ]
32  %exitcond2 = icmp ne i32 %j.0, 4
33  br i1 %exitcond2, label %for.body.3, label %for.end.23
34
35for.body.3:                                       ; preds = %for.cond.1
36  br label %for.cond.4
37
38for.cond.4:                                       ; preds = %for.inc.18, %for.body.3
39  %k.0 = phi i32 [ 0, %for.body.3 ], [ %inc19, %for.inc.18 ]
40  %exitcond1 = icmp ne i32 %k.0, 4
41  br i1 %exitcond1, label %for.body.6, label %for.end.20
42
43for.body.6:                                       ; preds = %for.cond.4
44  br label %for.cond.7
45
46for.cond.7:                                       ; preds = %for.inc, %for.body.6
47  %l.0 = phi i32 [ 0, %for.body.6 ], [ %inc, %for.inc ]
48  %exitcond = icmp ne i32 %l.0, 4
49  br i1 %exitcond, label %for.body.9, label %for.end
50
51for.body.9:                                       ; preds = %for.cond.7
52  %arrayidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
53  %tmp = load i32, ptr %arrayidx, align 4
54  %tmp6 = add nsw i64 %indvars.iv, -1
55  %arrayidx11 = getelementptr inbounds i32, ptr %A, i64 %tmp6
56  %tmp7 = load i32, ptr %arrayidx11, align 4
57  %mul = mul nsw i32 %tmp, %tmp7
58  %tmp8 = add nuw nsw i64 %indvars.iv, 1
59  %arrayidx13 = getelementptr inbounds i32, ptr %A, i64 %tmp8
60  %tmp9 = load i32, ptr %arrayidx13, align 4
61  %add14 = add nsw i32 %mul, %tmp9
62  %arrayidx16 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
63  %tmp10 = load i32, ptr %arrayidx16, align 4
64  %add17 = add nsw i32 %tmp10, %add14
65  store i32 %add17, ptr %arrayidx16, align 4
66  br label %for.inc
67
68for.inc:                                          ; preds = %for.body.9
69  %inc = add nuw nsw i32 %l.0, 1
70  br label %for.cond.7
71
72for.end:                                          ; preds = %for.cond.7
73  br label %for.inc.18
74
75for.inc.18:                                       ; preds = %for.end
76  %inc19 = add nuw nsw i32 %k.0, 1
77  br label %for.cond.4
78
79for.end.20:                                       ; preds = %for.cond.4
80  br label %for.inc.21
81
82for.inc.21:                                       ; preds = %for.end.20
83  %inc22 = add nuw nsw i32 %j.0, 1
84  br label %for.cond.1
85
86for.end.23:                                       ; preds = %for.cond.1
87  br label %for.inc.24
88
89for.inc.24:                                       ; preds = %for.end.23
90  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
91  br label %for.cond
92
93for.end.26:                                       ; preds = %for.cond
94  ret void
95}
96