1 ; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
3 ; Error blocks are skipped during SCoP detection. We skip them during
4 ; SCoP formation too as they might contain instructions we can not handle.
5 ; However statements / basic blocks that follow error blocks are modeled.
7 ; void timer_start(void);
8 ; void timer_stop(void);
9 ; void kernel(int *A, int *B, int timeit, int N) {
14 ; A[0] = 0; // Do not create a statement for this block
17 ; for (int i = 0; i < N; i++)
22 ; if (invalid float branch) // Do not crash on the float branch
26 ; for (int i = 0; i < N; i++)
33 ; The assumed context should not be empty even though all statements are
34 ; executed only if timeit != 0.
36 ; CHECK: Region: %entry.split---%if.end.20
37 ; CHECK: Assumed Context:
38 ; CHECK-NEXT: [timeit, N] -> { : }
39 ; CHECK: Invalid Context:
40 ; CHECK-NEXT: [timeit, N] -> { : timeit < 0 or timeit > 0 }
42 ; CHECK-NOT: Stmt_if_then_split
43 ; CHECK: Stmt_for_body
44 ; CHECK: Stmt_for_body_9
47 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
49 define void @kernel(i32* %A, i32* %B, i32 %timeit, i32 %N) {
54 %tobool = icmp eq i32 %timeit, 0
55 br i1 %tobool, label %for.cond.pre, label %if.then
57 if.then: ; preds = %entry
58 call void @timer_start()
59 br label %if.then.split
61 ; Dead block if we assume if.then not to be executed because of the call
62 if.then.split: ; preds = %if.then
63 %A0 = getelementptr inbounds i32, i32* %A, i64 0
64 store i32 0, i32* %A0, align 4
65 br label %for.cond.pre
68 %tmp = sext i32 %N to i64
71 for.cond: ; preds = %for.inc, %if.end
72 %indvars.iv1 = phi i64 [ %indvars.iv.next2, %for.inc ], [ 0, %for.cond.pre ]
73 %cmp = icmp slt i64 %indvars.iv1, %tmp
74 br i1 %cmp, label %for.body, label %for.end
76 for.body: ; preds = %for.cond
77 %arrayidx = getelementptr inbounds i32, i32* %B, i64 %indvars.iv1
78 %tmp3 = load i32, i32* %arrayidx, align 4
79 %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv1
80 %tmp4 = load i32, i32* %arrayidx2, align 4
81 %add = add nsw i32 %tmp4, %tmp3
82 store i32 %add, i32* %arrayidx2, align 4
85 for.inc: ; preds = %for.body
86 %indvars.iv.next2 = add nuw nsw i64 %indvars.iv1, 1
89 for.end: ; preds = %for.cond
90 %tobool3 = icmp eq i32 %timeit, 0
91 br i1 %tobool3, label %if.end.5, label %if.then.4
93 if.then.4: ; preds = %for.end
94 call void @timer_stop()
95 %na = fcmp one float 4.0, 5.0
96 br i1 %na, label %if.end.5, label %if.then.4.rem
98 if.then.4.rem: ; preds = %for.end
99 call void @timer_start()
102 if.end.5: ; preds = %for.end, %if.then.4
103 %tmp5 = sext i32 %N to i64
106 for.cond.7: ; preds = %for.inc.15, %if.end.5
107 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc.15 ], [ 0, %if.end.5 ]
108 %cmp8 = icmp slt i64 %indvars.iv, %tmp5
109 br i1 %cmp8, label %for.body.9, label %for.end.17
111 for.body.9: ; preds = %for.cond.7
112 %arrayidx11 = getelementptr inbounds i32, i32* %B, i64 %indvars.iv
113 %tmp6 = load i32, i32* %arrayidx11, align 4
114 %arrayidx13 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
115 %tmp7 = load i32, i32* %arrayidx13, align 4
116 %add14 = add nsw i32 %tmp7, %tmp6
117 store i32 %add14, i32* %arrayidx13, align 4
120 for.inc.15: ; preds = %for.body.9
121 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
124 for.end.17: ; preds = %for.cond.7
125 %tobool18 = icmp eq i32 %timeit, 0
126 br i1 %tobool18, label %if.end.20, label %if.then.19
128 if.then.19: ; preds = %for.end.17
129 call void @timer_stop()
132 if.end.20: ; preds = %for.end.17, %if.then.19
136 declare void @timer_start()
137 declare void @timer_stop()