87 lines · plain
1; RUN: opt %loadNPMPolly '-passes=polly-custom<scops>' -polly-print-scops -disable-output < %s 2>&1 | FileCheck %s2; RUN: opt %loadNPMPolly '-passes=polly-custom<ast>' -polly-print-ast -disable-output < %s 2>&1 | FileCheck %s --check-prefix=AST3;4; This only works after the post-dominator tree has been fixed.5;6; XFAIL: *7;8; void exception() __attribute__((noreturn));9;10; void foo(long n, float A[100]) {11; for (long i = 0; i < n; i++) {12; if (i < 0)13; exception();14;15; if (i >= 100)16; exception();17;18; A[i] += i;19; }20; }21 22; We should detect this kernel as a SCoP and derive run-time conditions such23; that the bound-checked blocks are not part of the optimized SCoP.24 25; CHECK: Invalid Context:26; CHECK: [n] -> { : n >= 101 }27 28; AST: if (1 && 0 == n >= 101)29; AST: for (int c0 = 0; c0 < n; c0 += 1)30; AST: Stmt_if_end_4(c0);31;32; AST-NOT: for33; AST-NOT: Stmt34;35; AST: else36; AST: { /* original code */ }37 38target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"39 40; Function Attrs: nounwind uwtable41define void @foo(i64 %n, ptr %A) {42entry:43 br label %for.cond44 45for.cond: ; preds = %for.inc, %entry46 %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.inc ]47 %cmp = icmp slt i64 %i.0, %n48 br i1 %cmp, label %for.body, label %for.end49 50for.body: ; preds = %for.cond51 br i1 false, label %if.then, label %if.end52 53if.then: ; preds = %for.body54 call void (...) @exception()55 unreachable56 57if.end: ; preds = %for.body58 %cmp2 = icmp sgt i64 %i.0, 9959 br i1 %cmp2, label %if.then.3, label %if.end.460 61if.then.3: ; preds = %if.end62 call void (...) @exception()63 unreachable64 65if.end.4: ; preds = %if.end66 %conv = sitofp i64 %i.0 to float67 %arrayidx = getelementptr inbounds float, ptr %A, i64 %i.068 %tmp = load float, ptr %arrayidx, align 469 %add = fadd float %tmp, %conv70 store float %add, ptr %arrayidx, align 471 br label %for.inc72 73for.inc: ; preds = %if.end.474 %inc = add nuw nsw i64 %i.0, 175 br label %for.cond76 77for.end: ; preds = %for.cond78 ret void79}80 81; Function Attrs: noreturn82declare void @exception(...)83 84!llvm.ident = !{!0}85 86!0 = !{!"clang version 3.8.0 (trunk 246853)"}87