1; RUN: opt %loadPolly -S -polly-print-scops -polly-invariant-load-hoisting=true -disable-output < %s | FileCheck %s -check-prefix=SCOPS
2; RUN: opt %loadPolly -S -polly-codegen -polly-invariant-load-hoisting=true %s | FileCheck %s
3;
4; Check we generate valid code.
5
6; SCOPS:         Statements {
7; SCOPS-NEXT:     	Stmt_if_then2457
8; SCOPS-NEXT:             Domain :=
9; SCOPS-NEXT:                 [p_0] -> { Stmt_if_then2457[] : p_0 = 1 };
10; SCOPS-NEXT:             Schedule :=
11; SCOPS-NEXT:                 [p_0] -> { Stmt_if_then2457[] -> [1] };
12; SCOPS-NEXT:             MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 1]
13; SCOPS-NEXT:                 [p_0] -> { Stmt_if_then2457[] -> MemRef_sub2464[] };
14; SCOPS-NEXT:     	Stmt_cond_false2468
15; SCOPS-NEXT:             Domain :=
16; SCOPS-NEXT:                 [p_0] -> { Stmt_cond_false2468[] : p_0 = 1 };
17; SCOPS-NEXT:             Schedule :=
18; SCOPS-NEXT:                 [p_0] -> { Stmt_cond_false2468[] -> [2] };
19; SCOPS-NEXT:             ReadAccess :=	[Reduction Type: NONE] [Scalar: 1]
20; SCOPS-NEXT:                 [p_0] -> { Stmt_cond_false2468[] -> MemRef_sub2464[] };
21; SCOPS-NEXT:             MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
22; SCOPS-NEXT:                 [p_0] -> { Stmt_cond_false2468[] -> MemRef_A[0] };
23; SCOPS-NEXT:     	Stmt_if_else2493
24; SCOPS-NEXT:             Domain :=
25; SCOPS-NEXT:                 [p_0] -> { Stmt_if_else2493[] : p_0 >= 2 or p_0 = 0 };
26; SCOPS-NEXT:             Schedule :=
27; SCOPS-NEXT:                 [p_0] -> { Stmt_if_else2493[] -> [0] : p_0 >= 2 or p_0 = 0 };
28; SCOPS-NEXT:             MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
29; SCOPS-NEXT:                 [p_0] -> { Stmt_if_else2493[] -> MemRef_B[0] };
30; SCOPS-NEXT:     }
31
32; CHECK: polly.start
33
34target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
35target triple = "x86_64-unknown-linux-gnu"
36
37%struct.s = type { i32, i32, i32, i32, i32, i32, [6 x [33 x i64]], [6 x [33 x i64]], [6 x [33 x i64]], [6 x [33 x i64]], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i16**, i16*, i16*, i16**, i16**, i16***, i8*, i16***, i64***, i64***, i16****, i8**, i8**, %struct.s*, %struct.s*, %struct.s*, i32, i32, i32, i32, i32, i32, i32 }
38
39@enc_picture = external global %struct.s*, align 8
40
41; Function Attrs: nounwind uwtable
42define void @compute_colocated(%struct.s*** %listX, i1* %A, i32* %B) #0 {
43entry:
44  br label %for.body2414
45
46for.body2414:                                     ; preds = %for.inc2621, %entry
47  %indvars.iv902 = phi i64 [ %indvars.iv.next903, %for.inc2621 ], [ 0, %entry ]
48  br label %if.else2454
49
50if.else2454:                                      ; preds = %for.body2414
51  %cmp2455 = icmp eq i64 %indvars.iv902, 2
52  br i1 %cmp2455, label %if.then2457, label %if.else2493
53
54if.then2457:                                      ; preds = %if.else2454
55  %arrayidx2461 = getelementptr inbounds %struct.s**, %struct.s*** %listX, i64 %indvars.iv902
56  %tmp1 = load %struct.s**, %struct.s*** %arrayidx2461, align 8, !tbaa !1
57  %arrayidx2462 = getelementptr inbounds %struct.s*, %struct.s** %tmp1, i64 0
58  %tmp2 = load %struct.s*, %struct.s** %arrayidx2462, align 8, !tbaa !1
59  %poc2463 = getelementptr inbounds %struct.s, %struct.s* %tmp2, i64 0, i32 1
60  %tmp3 = load i32, i32* %poc2463, align 4, !tbaa !5
61  %sub2464 = sub nsw i32 0, %tmp3
62  br label %cond.false2468
63
64cond.false2468:                                   ; preds = %if.then2457
65  %cmp2477 = icmp sgt i32 %sub2464, 127
66  store i1 %cmp2477, i1* %A
67  br label %for.inc2621
68
69if.else2493:                                      ; preds = %if.else2454
70  %arrayidx2497 = getelementptr inbounds %struct.s**, %struct.s*** %listX, i64 %indvars.iv902
71  %tmp4 = load %struct.s**, %struct.s*** %arrayidx2497, align 8, !tbaa !1
72  %arrayidx2498 = getelementptr inbounds %struct.s*, %struct.s** %tmp4, i64 0
73  %tmp5 = load %struct.s*, %struct.s** %arrayidx2498, align 8, !tbaa !1
74  %poc2499 = getelementptr inbounds %struct.s, %struct.s* %tmp5, i64 0, i32 1
75  %tmp6 = load i32, i32* %poc2499, align 4, !tbaa !5
76  store i32 %tmp6, i32* %B
77  br label %for.inc2621
78
79for.inc2621:                                      ; preds = %if.else2493, %cond.false2468
80  %indvars.iv.next903 = add nuw nsw i64 %indvars.iv902, 2
81  br i1 undef, label %for.body2414, label %if.end2624
82
83if.end2624:                                       ; preds = %for.inc2621
84  ret void
85}
86
87attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
88
89!llvm.ident = !{!0}
90
91!0 = !{!"clang version 3.9.0"}
92!1 = !{!2, !2, i64 0}
93!2 = !{!"any pointer", !3, i64 0}
94!3 = !{!"omnipotent char", !4, i64 0}
95!4 = !{!"Simple C/C++ TBAA"}
96!5 = !{!6, !7, i64 4}
97!6 = !{!"storable_picture", !3, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !3, i64 24, !3, i64 1608, !3, i64 3192, !3, i64 4776, !7, i64 6360, !7, i64 6364, !7, i64 6368, !7, i64 6372, !7, i64 6376, !7, i64 6380, !7, i64 6384, !7, i64 6388, !7, i64 6392, !7, i64 6396, !7, i64 6400, !7, i64 6404, !7, i64 6408, !7, i64 6412, !7, i64 6416, !2, i64 6424, !2, i64 6432, !2, i64 6440, !2, i64 6448, !2, i64 6456, !2, i64 6464, !2, i64 6472, !2, i64 6480, !2, i64 6488, !2, i64 6496, !2, i64 6504, !2, i64 6512, !2, i64 6520, !2, i64 6528, !2, i64 6536, !2, i64 6544, !7, i64 6552, !7, i64 6556, !7, i64 6560, !7, i64 6564, !7, i64 6568, !7, i64 6572, !7, i64 6576}
98!7 = !{!"int", !3, i64 0}
99