1; RUN: opt %loadPolly -polly-scops -analyze -S < %s | FileCheck %s 2; 3; struct com { 4; double Real; 5; double Img; 6; }; 7; 8; void foo(long n, struct com A[][n]) { 9; for (long i = 0; i < 100; i++) 10; for (long j = 0; j < 1000; j++) 11; A[i][j].Real += A[i][j].Img; 12; } 13; 14; int main() { 15; struct com A[100][1000]; 16; foo(1000, A); 17; } 18 19; CHECK: Arrays { 20; CHECK-NEXT: double MemRef_A[*][(2 * %n)]; // Element size 8 21; CHECK-NEXT: } 22 23; CHECK: Stmt_for_body3 24; CHECK-NEXT: Domain := 25; CHECK-NEXT: [n] -> { Stmt_for_body3[i0, i1] : 0 <= i0 <= 99 and 0 <= i1 <= 999 }; 26; CHECK-NEXT: Schedule := 27; CHECK-NEXT: [n] -> { Stmt_for_body3[i0, i1] -> [i0, i1] }; 28; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 29; CHECK-NEXT: [n] -> { Stmt_for_body3[i0, i1] -> MemRef_A[i0, 1 + 2i1] }; 30; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 31; CHECK-NEXT: [n] -> { Stmt_for_body3[i0, i1] -> MemRef_A[i0, 2i1] }; 32; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0] 33; CHECK-NEXT: [n] -> { Stmt_for_body3[i0, i1] -> MemRef_A[i0, 2i1] }; 34 35source_filename = "/tmp/test.c" 36target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 37 38%struct.com = type { double, double } 39%struct.com2 = type { [20000000000 x double] } 40 41define void @foo(i64 %n, %struct.com* %A) { 42entry: 43 br label %for.cond 44 45for.cond: ; preds = %for.inc7, %entry 46 %i.0 = phi i64 [ 0, %entry ], [ %inc8, %for.inc7 ] 47 %exitcond1 = icmp ne i64 %i.0, 100 48 br i1 %exitcond1, label %for.body, label %for.end9 49 50for.body: ; preds = %for.cond 51 br label %for.cond1 52 53for.cond1: ; preds = %for.inc, %for.body 54 %j.0 = phi i64 [ 0, %for.body ], [ %inc, %for.inc ] 55 %exitcond = icmp ne i64 %j.0, 1000 56 br i1 %exitcond, label %for.body3, label %for.end 57 58for.body3: ; preds = %for.cond1 59 %tmp = mul nsw i64 %i.0, %n 60 %arrayidx = getelementptr inbounds %struct.com, %struct.com* %A, i64 %tmp 61 %arrayidx4 = getelementptr inbounds %struct.com, %struct.com* %arrayidx, i64 %j.0 62 %Img = getelementptr inbounds %struct.com, %struct.com* %arrayidx4, i64 0, i32 1 63 %tmp2 = load double, double* %Img, align 8 64 %tmp3 = mul nsw i64 %i.0, %n 65 %arrayidx5 = getelementptr inbounds %struct.com, %struct.com* %A, i64 %tmp3 66 %arrayidx6 = getelementptr inbounds %struct.com, %struct.com* %arrayidx5, i64 %j.0 67 %Real = getelementptr inbounds %struct.com, %struct.com* %arrayidx6, i64 0, i32 0 68 %tmp4 = load double, double* %Real, align 8 69 %add = fadd double %tmp4, %tmp2 70 store double %add, double* %Real, align 8 71 br label %for.inc 72 73for.inc: ; preds = %for.body3 74 %inc = add nuw nsw i64 %j.0, 1 75 br label %for.cond1 76 77for.end: ; preds = %for.cond1 78 br label %for.inc7 79 80for.inc7: ; preds = %for.end 81 %inc8 = add nuw nsw i64 %i.0, 1 82 br label %for.cond 83 84for.end9: ; preds = %for.cond 85 ret void 86} 87 88; CHECK: Arrays { 89; CHECK-NEXT: double MemRef_O[*][%n]; // Element size 8 90; CHECK-NEXT: } 91 92define void @foo_overflow(i64 %n, %struct.com2* nocapture %O) local_unnamed_addr #0 { 93entry: 94 br label %for.body 95 96for.cond.cleanup: ; preds = %for.cond.cleanup3 97 ret void 98 99for.body: ; preds = %for.cond.cleanup3, %entry 100 %i.024 = phi i64 [ 0, %entry ], [ %inc12, %for.cond.cleanup3 ] 101 %0 = mul nsw i64 %i.024, %n 102 %arrayidx = getelementptr inbounds %struct.com2, %struct.com2* %O, i64 %0 103 br label %for.body4 104 105for.cond.cleanup3: ; preds = %for.body4 106 %inc12 = add nuw nsw i64 %i.024, 1 107 %exitcond25 = icmp eq i64 %inc12, 100 108 br i1 %exitcond25, label %for.cond.cleanup, label %for.body 109 110for.body4: ; preds = %for.body4, %for.body 111 %j.023 = phi i64 [ 0, %for.body ], [ %inc, %for.body4 ] 112 %arrayidx5 = getelementptr inbounds %struct.com2, %struct.com2* %arrayidx, i64 %j.023 113 %Real = getelementptr inbounds %struct.com2, %struct.com2* %arrayidx5, i64 0, i32 0 114 %arrayidx6 = getelementptr inbounds [20000000000 x double], [20000000000 x double]* %Real, i64 0, i64 1 115 %1 = load double, double* %arrayidx6, align 8 116 %arrayidx10 = getelementptr inbounds [20000000000 x double], [20000000000 x double]* %Real, i64 0, i64 0 117 %2 = load double, double* %arrayidx10, align 8 118 %add = fadd double %1, %2 119 store double %add, double* %arrayidx10, align 8 120 %inc = add nuw nsw i64 %j.023, 1 121 %exitcond = icmp eq i64 %inc, 1000 122 br i1 %exitcond, label %for.cond.cleanup3, label %for.body4 123} 124