1; RUN: opt %loadPolly -polly-scops -polly-invariant-load-hoisting=true -analyze < %s | FileCheck %s 2; 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. 7; 8; CHECK: Invariant Accesses: { 9; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 10; CHECK-NEXT: [bounds0l0, p] -> { Stmt_for_cond_4[i0, i1, i2] -> MemRef_bounds[0] }; 11; CHECK-NEXT: Execution Context: [bounds0l0, p] -> { : } 12; CHECK-NEXT: } 13; 14; CHECK: p0: %bounds0l0 15; CHECK-NEXT: p1: %p 16; CHECK-NOT: p2 17; 18; CHECK: Statements { 19; CHECK-NEXT: Stmt_for_body_6 20; CHECK-NEXT: Domain := 21; CHECK-NEXT: [bounds0l0, p] -> { Stmt_for_body_6[i0, i1, i2] : p = 0 and 0 <= i0 < bounds0l0 and 0 <= i1 < bounds0l0 and 0 <= i2 < bounds0l0 }; 22; CHECK-NEXT: Schedule := 23; CHECK-NEXT: [bounds0l0, p] -> { Stmt_for_body_6[i0, i1, i2] -> [i0, i1, i2] }; 24; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 25; CHECK-NEXT: [bounds0l0, p] -> { Stmt_for_body_6[i0, i1, i2] -> MemRef_data[i0, i1, i2] }; 26; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0] 27; CHECK-NEXT: [bounds0l0, p] -> { Stmt_for_body_6[i0, i1, i2] -> MemRef_data[i0, i1, i2] }; 28; CHECK-NEXT: } 29; 30; int bounds[1]; 31; double data[1024][1024][1024]; 32; 33; void foo(int p) { 34; int i, j, k; 35; for (k = 0; k < bounds[0]; k++) 36; if (p == 0) 37; for (j = 0; j < bounds[0]; j++) 38; for (i = 0; i < bounds[0]; i++) 39; data[k][j][i] += i + j + k; 40; } 41; 42target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 43 44@bounds = common global [1 x i32] zeroinitializer, align 4 45@data = common global [1024 x [1024 x [1024 x double]]] zeroinitializer, align 16 46 47define void @foo(i32 %p) { 48entry: 49 br label %for.cond 50 51for.cond: ; preds = %for.inc.16, %entry 52 %indvars.iv5 = phi i64 [ %indvars.iv.next6, %for.inc.16 ], [ 0, %entry ] 53 %bounds0l0 = load i32, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @bounds, i64 0, i64 0), align 4 54 %tmp7 = sext i32 %bounds0l0 to i64 55 %cmp = icmp slt i64 %indvars.iv5, %tmp7 56 br i1 %cmp, label %for.body, label %for.end.18 57 58for.body: ; preds = %for.cond 59 %cmpp = icmp eq i32 %p, 0 60 br i1 %cmpp, label %for.cond.1, label %for.inc.16 61 62for.cond.1: ; preds = %for.inc.13, %for.body 63 %indvars.iv3 = phi i64 [ %indvars.iv.next4, %for.inc.13 ], [ 0, %for.body ] 64 %bounds0l1 = load i32, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @bounds, i64 0, i64 0), align 4 65 %tmp9 = sext i32 %bounds0l1 to i64 66 %cmp2 = icmp slt i64 %indvars.iv3, %tmp9 67 br i1 %cmp2, label %for.body.3, label %for.end.15 68 69for.body.3: ; preds = %for.cond.1 70 br label %for.cond.4 71 72for.cond.4: ; preds = %for.inc, %for.body.3 73 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %for.body.3 ] 74 %bounds0l2 = load i32, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @bounds, i64 0, i64 0), align 4 75 %tmp11 = sext i32 %bounds0l2 to i64 76 %cmp5 = icmp slt i64 %indvars.iv, %tmp11 77 br i1 %cmp5, label %for.body.6, label %for.end 78 79for.body.6: ; preds = %for.cond.4 80 %tmp12 = add nsw i64 %indvars.iv, %indvars.iv3 81 %tmp13 = add nsw i64 %tmp12, %indvars.iv5 82 %tmp14 = trunc i64 %tmp13 to i32 83 %conv = sitofp i32 %tmp14 to double 84 %arrayidx11 = getelementptr inbounds [1024 x [1024 x [1024 x double]]], [1024 x [1024 x [1024 x double]]]* @data, i64 0, i64 %indvars.iv5, i64 %indvars.iv3, i64 %indvars.iv 85 %tmp15 = load double, double* %arrayidx11, align 8 86 %add12 = fadd double %tmp15, %conv 87 store double %add12, double* %arrayidx11, align 8 88 br label %for.inc 89 90for.inc: ; preds = %for.body.6 91 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 92 br label %for.cond.4 93 94for.end: ; preds = %for.cond.4 95 br label %for.inc.13 96 97for.inc.13: ; preds = %for.end 98 %indvars.iv.next4 = add nuw nsw i64 %indvars.iv3, 1 99 br label %for.cond.1 100 101for.end.15: ; preds = %for.cond.1 102 br label %for.inc.16 103 104for.inc.16: ; preds = %for.end.15 105 %indvars.iv.next6 = add nuw nsw i64 %indvars.iv5, 1 106 br label %for.cond 107 108for.end.18: ; preds = %for.cond 109 ret void 110} 111