Fix Polly
[polly-mirror.git] / test / Isl / CodeGen / loop_with_condition_2.ll
blob9398e1dc70b887181c9efbf7255c0db10ff208cc
1 ; RUN: opt %loadPolly -basicaa -polly-ast -polly-ast-detect-parallel -analyze < %s | FileCheck %s
3 ; Verify that we actually detect this loop as the innermost loop even though
4 ; there is a conditional inside.
6 ; CHECK: #pragma simd
7 ; CHECK: for (int c0 = 0; c0 <= 1023; c0 += 1) {
8 ; CHECK:   if (c0 >= m + 1025) {
9 ; CHECK:     Stmt_if_else(c0);
10 ; CHECK:   } else
11 ; CHECK:     Stmt_if_then(c0);
12 ; CHECK:   Stmt_if_end(c0);
13 ; CHECK: }
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 {
21 entry:
22   fence seq_cst
23   %tmp = sub i32 0, %m
24   %tmp1 = zext i32 %tmp to i64
25   br label %for.cond
27 for.cond:                                         ; preds = %for.inc, %entry
28   %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
29   %arrayidx = getelementptr [1024 x i32], [1024 x i32]* @A, i64 0, i64 %indvar
30   %arrayidx10 = getelementptr [1024 x i32], [1024 x i32]* @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, i32* %arrayidx
42   br label %if.end
44 if.else:                                          ; preds = %for.body
45   store i32 2, i32* %arrayidx
46   br label %if.end
48 if.end:                                           ; preds = %if.else, %if.then
49   store i32 3, i32* %arrayidx10
50   br label %for.inc
52 for.inc:                                          ; preds = %if.end
53   %indvar.next = add i64 %indvar, 1
54   br label %for.cond
56 for.end:                                          ; preds = %for.cond
57   fence seq_cst
58   ret void
61 define i32 @main() nounwind {
62 entry:
63   call void @llvm.memset.p0i8.i64(i8* bitcast ([1024 x i32]* @A to i8*), i8 0, i64 4096, i32 1, i1 false)
64   call void @llvm.memset.p0i8.i64(i8* bitcast ([1024 x i32]* @B to i8*), i8 0, i64 4096, i32 1, i1 false)
65   call void @loop_with_condition(i32 5)
66   br label %for.cond
68 for.cond:                                         ; preds = %for.inc, %entry
69   %indvar1 = phi i64 [ %indvar.next2, %for.inc ], [ 0, %entry ]
70   %arrayidx = getelementptr [1024 x i32], [1024 x i32]* @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, i32* %arrayidx
77   %cmp4 = icmp ne i32 %tmp3, 3
78   br i1 %cmp4, label %if.then, label %if.end
80 if.then:                                          ; preds = %for.body
81   br label %return
83 if.end:                                           ; preds = %for.body
84   br label %for.inc
86 for.inc:                                          ; preds = %if.end
87   %indvar.next2 = add i64 %indvar1, 1
88   br label %for.cond
90 for.end:                                          ; preds = %for.cond
91   br label %for.cond6
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], [1024 x i32]* @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, i32* %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
109   br label %return
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, i32* %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
120   br label %return
122 if.end30:                                         ; preds = %land.lhs.true23, %if.else
123   br label %if.end31
125 if.end31:                                         ; preds = %if.end30
126   br label %for.inc12
128 for.inc12:                                        ; preds = %if.end31
129   %indvar.next = add i64 %indvar, 1
130   br label %for.cond6
132 for.end35:                                        ; preds = %for.cond6
133   br label %return
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 ]
137   ret i32 %retval.0
140 declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind