Update Polly tests to handle explicitly typed gep changes in LLVM
[polly-mirror.git] / test / Isl / CodeGen / loop_with_condition_2.ll
blobbd44e0fbaeb3231438ecf1ed696c74fe912b0b34
1 ; RUN: opt %loadPolly -polly-detect-unprofitable -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"
16 target triple = "x86_64-unknown-linux-gnu"
18 @A = common global [1024 x i32] zeroinitializer, align 16
19 @B = common global [1024 x i32] zeroinitializer, align 16
21 define void @loop_with_condition(i32 %m) nounwind {
22 entry:
23   fence seq_cst
24   %tmp = sub i32 0, %m
25   %tmp1 = zext i32 %tmp to i64
26   br label %for.cond
28 for.cond:                                         ; preds = %for.inc, %entry
29   %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
30   %arrayidx = getelementptr [1024 x i32], [1024 x i32]* @A, i64 0, i64 %indvar
31   %arrayidx10 = getelementptr [1024 x i32], [1024 x i32]* @B, i64 0, i64 %indvar
32   %tmp2 = add i64 %tmp1, %indvar
33   %sub = trunc i64 %tmp2 to i32
34   %exitcond = icmp ne i64 %indvar, 1024
35   br i1 %exitcond, label %for.body, label %for.end
37 for.body:                                         ; preds = %for.cond
38   %cmp3 = icmp sle i32 %sub, 1024
39   br i1 %cmp3, label %if.then, label %if.else
41 if.then:                                          ; preds = %for.body
42   store i32 1, i32* %arrayidx
43   br label %if.end
45 if.else:                                          ; preds = %for.body
46   store i32 2, i32* %arrayidx
47   br label %if.end
49 if.end:                                           ; preds = %if.else, %if.then
50   store i32 3, i32* %arrayidx10
51   br label %for.inc
53 for.inc:                                          ; preds = %if.end
54   %indvar.next = add i64 %indvar, 1
55   br label %for.cond
57 for.end:                                          ; preds = %for.cond
58   fence seq_cst
59   ret void
62 define i32 @main() nounwind {
63 entry:
64   call void @llvm.memset.p0i8.i64(i8* bitcast ([1024 x i32]* @A to i8*), i8 0, i64 4096, i32 1, i1 false)
65   call void @llvm.memset.p0i8.i64(i8* bitcast ([1024 x i32]* @B to i8*), i8 0, i64 4096, i32 1, i1 false)
66   call void @loop_with_condition(i32 5)
67   br label %for.cond
69 for.cond:                                         ; preds = %for.inc, %entry
70   %indvar1 = phi i64 [ %indvar.next2, %for.inc ], [ 0, %entry ]
71   %arrayidx = getelementptr [1024 x i32], [1024 x i32]* @B, i64 0, i64 %indvar1
72   %i.0 = trunc i64 %indvar1 to i32
73   %cmp = icmp slt i32 %i.0, 1024
74   br i1 %cmp, label %for.body, label %for.end
76 for.body:                                         ; preds = %for.cond
77   %tmp3 = load i32* %arrayidx
78   %cmp4 = icmp ne i32 %tmp3, 3
79   br i1 %cmp4, label %if.then, label %if.end
81 if.then:                                          ; preds = %for.body
82   br label %return
84 if.end:                                           ; preds = %for.body
85   br label %for.inc
87 for.inc:                                          ; preds = %if.end
88   %indvar.next2 = add i64 %indvar1, 1
89   br label %for.cond
91 for.end:                                          ; preds = %for.cond
92   br label %for.cond6
94 for.cond6:                                        ; preds = %for.inc12, %for.end
95   %indvar = phi i64 [ %indvar.next, %for.inc12 ], [ 0, %for.end ]
96   %arrayidx15 = getelementptr [1024 x i32], [1024 x i32]* @A, i64 0, i64 %indvar
97   %i.1 = trunc i64 %indvar to i32
98   %cmp8 = icmp slt i32 %i.1, 1024
99   br i1 %cmp8, label %for.body9, label %for.end35
101 for.body9:                                        ; preds = %for.cond6
102   br i1 true, label %land.lhs.true, label %if.else
104 land.lhs.true:                                    ; preds = %for.body9
105   %tmp16 = load i32* %arrayidx15
106   %cmp17 = icmp ne i32 %tmp16, 1
107   br i1 %cmp17, label %if.then18, label %if.else
109 if.then18:                                        ; preds = %land.lhs.true
110   br label %return
112 if.else:                                          ; preds = %land.lhs.true, %for.body9
113   br i1 false, label %land.lhs.true23, label %if.end30
115 land.lhs.true23:                                  ; preds = %if.else
116   %tmp27 = load i32* %arrayidx15
117   %cmp28 = icmp ne i32 %tmp27, 2
118   br i1 %cmp28, label %if.then29, label %if.end30
120 if.then29:                                        ; preds = %land.lhs.true23
121   br label %return
123 if.end30:                                         ; preds = %land.lhs.true23, %if.else
124   br label %if.end31
126 if.end31:                                         ; preds = %if.end30
127   br label %for.inc12
129 for.inc12:                                        ; preds = %if.end31
130   %indvar.next = add i64 %indvar, 1
131   br label %for.cond6
133 for.end35:                                        ; preds = %for.cond6
134   br label %return
136 return:                                           ; preds = %for.end35, %if.then29, %if.then18, %if.then
137   %retval.0 = phi i32 [ 1, %if.then ], [ 1, %if.then18 ], [ 1, %if.then29 ], [ 0, %for.end35 ]
138   ret i32 %retval.0
141 declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind