1 ; RUN: opt %loadPolly -polly-print-scops -polly-invariant-load-hoisting=true -disable-output < %s | FileCheck %s
3 ; Verify that we only have one parameter and one invariant load for all
4 ; three loads that occure in the region but actually access the same
5 ; location. Also check that the execution context is the most generic
6 ; one, e.g., here the universal set.
8 ; CHECK: Invariant Accesses: {
9 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
10 ; CHECK-NEXT: [bounds0l0] -> { Stmt_for_cond_4[i0, i1, i2] -> MemRef_bounds[0] };
11 ; CHECK-NEXT: Execution Context: [bounds0l0] -> { : }
14 ; CHECK: p0: %bounds0l0
18 ; CHECK-NEXT: Stmt_for_body_6
19 ; CHECK-NEXT: Domain :=
20 ; CHECK-NEXT: [bounds0l0] -> { Stmt_for_body_6[i0, i1, i2] : 0 <= i0 < bounds0l0 and 0 <= i1 < bounds0l0 and 0 <= i2 < bounds0l0 };
21 ; CHECK-NEXT: Schedule :=
22 ; CHECK-NEXT: [bounds0l0] -> { Stmt_for_body_6[i0, i1, i2] -> [i0, i1, i2] };
23 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
24 ; CHECK-NEXT: [bounds0l0] -> { Stmt_for_body_6[i0, i1, i2] -> MemRef_data[i0, i1, i2] };
25 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
26 ; CHECK-NEXT: [bounds0l0] -> { Stmt_for_body_6[i0, i1, i2] -> MemRef_data[i0, i1, i2] };
30 ; double data[1024][1024][1024];
34 ; for (k = 0; k < bounds[0]; k++)
35 ; for (j = 0; j < bounds[0]; j++)
36 ; for (i = 0; i < bounds[0]; i++)
37 ; data[k][j][i] += i + j + k;
40 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
42 @bounds = common global [1 x i32] zeroinitializer, align 4
43 @data = common global [1024 x [1024 x [1024 x double]]] zeroinitializer, align 16
49 for.cond: ; preds = %for.inc.16, %entry
50 %indvars.iv5 = phi i64 [ %indvars.iv.next6, %for.inc.16 ], [ 0, %entry ]
51 %bounds0l0 = load i32, ptr @bounds, align 4
52 %tmp7 = sext i32 %bounds0l0 to i64
53 %cmp = icmp slt i64 %indvars.iv5, %tmp7
54 br i1 %cmp, label %for.body, label %for.end.18
56 for.body: ; preds = %for.cond
59 for.cond.1: ; preds = %for.inc.13, %for.body
60 %indvars.iv3 = phi i64 [ %indvars.iv.next4, %for.inc.13 ], [ 0, %for.body ]
61 %bounds0l1 = load i32, ptr @bounds, align 4
62 %tmp9 = sext i32 %bounds0l1 to i64
63 %cmp2 = icmp slt i64 %indvars.iv3, %tmp9
64 br i1 %cmp2, label %for.body.3, label %for.end.15
66 for.body.3: ; preds = %for.cond.1
69 for.cond.4: ; preds = %for.inc, %for.body.3
70 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %for.body.3 ]
71 %bounds0l2 = load i32, ptr @bounds, align 4
72 %tmp11 = sext i32 %bounds0l2 to i64
73 %cmp5 = icmp slt i64 %indvars.iv, %tmp11
74 br i1 %cmp5, label %for.body.6, label %for.end
76 for.body.6: ; preds = %for.cond.4
77 %tmp12 = add nsw i64 %indvars.iv, %indvars.iv3
78 %tmp13 = add nsw i64 %tmp12, %indvars.iv5
79 %tmp14 = trunc i64 %tmp13 to i32
80 %conv = sitofp i32 %tmp14 to double
81 %arrayidx11 = getelementptr inbounds [1024 x [1024 x [1024 x double]]], ptr @data, i64 0, i64 %indvars.iv5, i64 %indvars.iv3, i64 %indvars.iv
82 %tmp15 = load double, ptr %arrayidx11, align 8
83 %add12 = fadd double %tmp15, %conv
84 store double %add12, ptr %arrayidx11, align 8
87 for.inc: ; preds = %for.body.6
88 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
91 for.end: ; preds = %for.cond.4
94 for.inc.13: ; preds = %for.end
95 %indvars.iv.next4 = add nuw nsw i64 %indvars.iv3, 1
98 for.end.15: ; preds = %for.cond.1
101 for.inc.16: ; preds = %for.end.15
102 %indvars.iv.next6 = add nuw nsw i64 %indvars.iv5, 1
105 for.end.18: ; preds = %for.cond