1; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
2; RUN: opt %loadPolly -polly-ast -analyze < %s | FileCheck %s --check-prefix=AST
3;
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 such
23; 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: for
33; AST-NOT: Stmt
34;
35; AST: else
36; AST:     {  /* original code */ }
37
38target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
39
40; Function Attrs: nounwind uwtable
41define void @foo(i64 %n, float* %A) #0 {
42entry:
43  br label %for.cond
44
45for.cond:                                         ; preds = %for.inc, %entry
46  %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.inc ]
47  %cmp = icmp slt i64 %i.0, %n
48  br i1 %cmp, label %for.body, label %for.end
49
50for.body:                                         ; preds = %for.cond
51  br i1 false, label %if.then, label %if.end
52
53if.then:                                          ; preds = %for.body
54  call void (...) @exception() #2
55  unreachable
56
57if.end:                                           ; preds = %for.body
58  %cmp2 = icmp sgt i64 %i.0, 99
59  br i1 %cmp2, label %if.then.3, label %if.end.4
60
61if.then.3:                                        ; preds = %if.end
62  call void (...) @exception() #2
63  unreachable
64
65if.end.4:                                         ; preds = %if.end
66  %conv = sitofp i64 %i.0 to float
67  %arrayidx = getelementptr inbounds float, float* %A, i64 %i.0
68  %tmp = load float, float* %arrayidx, align 4
69  %add = fadd float %tmp, %conv
70  store float %add, float* %arrayidx, align 4
71  br label %for.inc
72
73for.inc:                                          ; preds = %if.end.4
74  %inc = add nuw nsw i64 %i.0, 1
75  br label %for.cond
76
77for.end:                                          ; preds = %for.cond
78  ret void
79}
80
81; Function Attrs: noreturn
82declare void @exception(...) #1
83
84attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
85attributes #1 = { noreturn "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
86attributes #2 = { noreturn nounwind }
87
88!llvm.ident = !{!0}
89
90!0 = !{!"clang version 3.8.0 (trunk 246853)"}
91