1; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s 2; 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. 6; 7; void timer_start(void); 8; void timer_stop(void); 9; void kernel(int *A, int *B, int timeit, int N) { 10; 11; if (timeit) { 12; timer_start(); 13; // split BB 14; A[0] = 0; // Do not create a statement for this block 15; } 16; 17; for (int i = 0; i < N; i++) 18; A[i] += B[i]; 19; 20; if (timeit) { 21; timer_stop(); 22; if (invalid float branch) // Do not crash on the float branch 23; timer_start(); 24; } 25; 26; for (int i = 0; i < N; i++) 27; A[i] += B[i]; 28; 29; if (timeit) 30; timer_stop(); 31; } 32; 33; The assumed context should not be empty even though all statements are 34; executed only if timeit != 0. 35; 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 } 41; CHECK: Statements { 42; CHECK-NOT: Stmt_if_then_split 43; CHECK: Stmt_for_body 44; CHECK: Stmt_for_body_9 45; CHECK: } 46; 47target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 48 49define void @kernel(i32* %A, i32* %B, i32 %timeit, i32 %N) { 50entry: 51 br label %entry.split 52 53entry.split: 54 %tobool = icmp eq i32 %timeit, 0 55 br i1 %tobool, label %for.cond.pre, label %if.then 56 57if.then: ; preds = %entry 58 call void @timer_start() 59 br label %if.then.split 60 61; Dead block if we assume if.then not to be executed because of the call 62if.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 66 67for.cond.pre: 68 %tmp = sext i32 %N to i64 69 br label %for.cond 70 71for.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 75 76for.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 83 br label %for.inc 84 85for.inc: ; preds = %for.body 86 %indvars.iv.next2 = add nuw nsw i64 %indvars.iv1, 1 87 br label %for.cond 88 89for.end: ; preds = %for.cond 90 %tobool3 = icmp eq i32 %timeit, 0 91 br i1 %tobool3, label %if.end.5, label %if.then.4 92 93if.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 97 98if.then.4.rem: ; preds = %for.end 99 call void @timer_start() 100 br label %if.end.5 101 102if.end.5: ; preds = %for.end, %if.then.4 103 %tmp5 = sext i32 %N to i64 104 br label %for.cond.7 105 106for.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 110 111for.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 118 br label %for.inc.15 119 120for.inc.15: ; preds = %for.body.9 121 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 122 br label %for.cond.7 123 124for.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 127 128if.then.19: ; preds = %for.end.17 129 call void @timer_stop() 130 br label %if.end.20 131 132if.end.20: ; preds = %for.end.17, %if.then.19 133 ret void 134} 135 136declare void @timer_start() 137declare void @timer_stop() 138