1 ; RUN: opt %loadPolly -polly-print-scops -disable-output < %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(ptr %A, ptr %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 store i32 0, ptr %A, align 4
64 br label %for.cond.pre
67 %tmp = sext i32 %N to i64
70 for.cond: ; preds = %for.inc, %if.end
71 %indvars.iv1 = phi i64 [ %indvars.iv.next2, %for.inc ], [ 0, %for.cond.pre ]
72 %cmp = icmp slt i64 %indvars.iv1, %tmp
73 br i1 %cmp, label %for.body, label %for.end
75 for.body: ; preds = %for.cond
76 %arrayidx = getelementptr inbounds i32, ptr %B, i64 %indvars.iv1
77 %tmp3 = load i32, ptr %arrayidx, align 4
78 %arrayidx2 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv1
79 %tmp4 = load i32, ptr %arrayidx2, align 4
80 %add = add nsw i32 %tmp4, %tmp3
81 store i32 %add, ptr %arrayidx2, align 4
84 for.inc: ; preds = %for.body
85 %indvars.iv.next2 = add nuw nsw i64 %indvars.iv1, 1
88 for.end: ; preds = %for.cond
89 %tobool3 = icmp eq i32 %timeit, 0
90 br i1 %tobool3, label %if.end.5, label %if.then.4
92 if.then.4: ; preds = %for.end
93 call void @timer_stop()
94 %na = fcmp one float 4.0, 5.0
95 br i1 %na, label %if.end.5, label %if.then.4.rem
97 if.then.4.rem: ; preds = %for.end
98 call void @timer_start()
101 if.end.5: ; preds = %for.end, %if.then.4
102 %tmp5 = sext i32 %N to i64
105 for.cond.7: ; preds = %for.inc.15, %if.end.5
106 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc.15 ], [ 0, %if.end.5 ]
107 %cmp8 = icmp slt i64 %indvars.iv, %tmp5
108 br i1 %cmp8, label %for.body.9, label %for.end.17
110 for.body.9: ; preds = %for.cond.7
111 %arrayidx11 = getelementptr inbounds i32, ptr %B, i64 %indvars.iv
112 %tmp6 = load i32, ptr %arrayidx11, align 4
113 %arrayidx13 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
114 %tmp7 = load i32, ptr %arrayidx13, align 4
115 %add14 = add nsw i32 %tmp7, %tmp6
116 store i32 %add14, ptr %arrayidx13, align 4
119 for.inc.15: ; preds = %for.body.9
120 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
123 for.end.17: ; preds = %for.cond.7
124 %tobool18 = icmp eq i32 %timeit, 0
125 br i1 %tobool18, label %if.end.20, label %if.then.19
127 if.then.19: ; preds = %for.end.17
128 call void @timer_stop()
131 if.end.20: ; preds = %for.end.17, %if.then.19
135 declare void @timer_start()
136 declare void @timer_stop()