1 ; RUN: opt %loadPolly -basic-aa -polly-print-ast -polly-ast-detect-parallel -disable-output < %s | FileCheck %s
3 ; Verify that we actually detect this loop as the innermost loop even though
4 ; there is a conditional inside.
7 ; CHECK: for (int c0 = 0; c0 <= 1023; c0 += 1) {
8 ; CHECK: if (c0 >= m + 1025) {
9 ; CHECK: Stmt_if_else(c0);
11 ; CHECK: Stmt_if_then(c0);
12 ; CHECK: Stmt_if_end(c0);
15 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
17 @A = common global [1024 x i32] zeroinitializer, align 16
18 @B = common global [1024 x i32] zeroinitializer, align 16
20 define void @loop_with_condition(i32 %m) nounwind {
24 %tmp1 = zext i32 %tmp to i64
27 for.cond: ; preds = %for.inc, %entry
28 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
29 %arrayidx = getelementptr [1024 x i32], ptr @A, i64 0, i64 %indvar
30 %arrayidx10 = getelementptr [1024 x i32], ptr @B, i64 0, i64 %indvar
31 %tmp2 = add i64 %tmp1, %indvar
32 %sub = trunc i64 %tmp2 to i32
33 %exitcond = icmp ne i64 %indvar, 1024
34 br i1 %exitcond, label %for.body, label %for.end
36 for.body: ; preds = %for.cond
37 %cmp3 = icmp sle i32 %sub, 1024
38 br i1 %cmp3, label %if.then, label %if.else
40 if.then: ; preds = %for.body
41 store i32 1, ptr %arrayidx
44 if.else: ; preds = %for.body
45 store i32 2, ptr %arrayidx
48 if.end: ; preds = %if.else, %if.then
49 store i32 3, ptr %arrayidx10
52 for.inc: ; preds = %if.end
53 %indvar.next = add i64 %indvar, 1
56 for.end: ; preds = %for.cond
61 define i32 @main() nounwind {
63 call void @llvm.memset.p0.i64(ptr @A, i8 0, i64 4096, i32 1, i1 false)
64 call void @llvm.memset.p0.i64(ptr @B, i8 0, i64 4096, i32 1, i1 false)
65 call void @loop_with_condition(i32 5)
68 for.cond: ; preds = %for.inc, %entry
69 %indvar1 = phi i64 [ %indvar.next2, %for.inc ], [ 0, %entry ]
70 %arrayidx = getelementptr [1024 x i32], ptr @B, i64 0, i64 %indvar1
71 %i.0 = trunc i64 %indvar1 to i32
72 %cmp = icmp slt i32 %i.0, 1024
73 br i1 %cmp, label %for.body, label %for.end
75 for.body: ; preds = %for.cond
76 %tmp3 = load i32, ptr %arrayidx
77 %cmp4 = icmp ne i32 %tmp3, 3
78 br i1 %cmp4, label %if.then, label %if.end
80 if.then: ; preds = %for.body
83 if.end: ; preds = %for.body
86 for.inc: ; preds = %if.end
87 %indvar.next2 = add i64 %indvar1, 1
90 for.end: ; preds = %for.cond
93 for.cond6: ; preds = %for.inc12, %for.end
94 %indvar = phi i64 [ %indvar.next, %for.inc12 ], [ 0, %for.end ]
95 %arrayidx15 = getelementptr [1024 x i32], ptr @A, i64 0, i64 %indvar
96 %i.1 = trunc i64 %indvar to i32
97 %cmp8 = icmp slt i32 %i.1, 1024
98 br i1 %cmp8, label %for.body9, label %for.end35
100 for.body9: ; preds = %for.cond6
101 br i1 true, label %land.lhs.true, label %if.else
103 land.lhs.true: ; preds = %for.body9
104 %tmp16 = load i32, ptr %arrayidx15
105 %cmp17 = icmp ne i32 %tmp16, 1
106 br i1 %cmp17, label %if.then18, label %if.else
108 if.then18: ; preds = %land.lhs.true
111 if.else: ; preds = %land.lhs.true, %for.body9
112 br i1 false, label %land.lhs.true23, label %if.end30
114 land.lhs.true23: ; preds = %if.else
115 %tmp27 = load i32, ptr %arrayidx15
116 %cmp28 = icmp ne i32 %tmp27, 2
117 br i1 %cmp28, label %if.then29, label %if.end30
119 if.then29: ; preds = %land.lhs.true23
122 if.end30: ; preds = %land.lhs.true23, %if.else
125 if.end31: ; preds = %if.end30
128 for.inc12: ; preds = %if.end31
129 %indvar.next = add i64 %indvar, 1
132 for.end35: ; preds = %for.cond6
135 return: ; preds = %for.end35, %if.then29, %if.then18, %if.then
136 %retval.0 = phi i32 [ 1, %if.then ], [ 1, %if.then18 ], [ 1, %if.then29 ], [ 0, %for.end35 ]
140 declare void @llvm.memset.p0.i64(ptr nocapture, i8, i64, i32, i1) nounwind