1; RUN: opt %loadNPMPolly '-passes=print<polly-function-scops>' -disable-output < %s 2>&1 | 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, ptr %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, ptr %A, i64 %tmp 61 %arrayidx4 = getelementptr inbounds %struct.com, ptr %arrayidx, i64 %j.0 62 %Img = getelementptr inbounds %struct.com, ptr %arrayidx4, i64 0, i32 1 63 %tmp2 = load double, ptr %Img, align 8 64 %tmp3 = mul nsw i64 %i.0, %n 65 %arrayidx5 = getelementptr inbounds %struct.com, ptr %A, i64 %tmp3 66 %arrayidx6 = getelementptr inbounds %struct.com, ptr %arrayidx5, i64 %j.0 67 %tmp4 = load double, ptr %arrayidx6, align 8 68 %add = fadd double %tmp4, %tmp2 69 store double %add, ptr %arrayidx6, align 8 70 br label %for.inc 71 72for.inc: ; preds = %for.body3 73 %inc = add nuw nsw i64 %j.0, 1 74 br label %for.cond1 75 76for.end: ; preds = %for.cond1 77 br label %for.inc7 78 79for.inc7: ; preds = %for.end 80 %inc8 = add nuw nsw i64 %i.0, 1 81 br label %for.cond 82 83for.end9: ; preds = %for.cond 84 ret void 85} 86 87; CHECK: Arrays { 88; CHECK-NEXT: double MemRef_O[*][%n]; // Element size 8 89; CHECK-NEXT: } 90 91define void @foo_overflow(i64 %n, ptr nocapture %O) local_unnamed_addr #0 { 92entry: 93 br label %for.body 94 95for.cond.cleanup: ; preds = %for.cond.cleanup3 96 ret void 97 98for.body: ; preds = %for.cond.cleanup3, %entry 99 %i.024 = phi i64 [ 0, %entry ], [ %inc12, %for.cond.cleanup3 ] 100 %0 = mul nsw i64 %i.024, %n 101 %arrayidx = getelementptr inbounds %struct.com2, ptr %O, i64 %0 102 br label %for.body4 103 104for.cond.cleanup3: ; preds = %for.body4 105 %inc12 = add nuw nsw i64 %i.024, 1 106 %exitcond25 = icmp eq i64 %inc12, 100 107 br i1 %exitcond25, label %for.cond.cleanup, label %for.body 108 109for.body4: ; preds = %for.body4, %for.body 110 %j.023 = phi i64 [ 0, %for.body ], [ %inc, %for.body4 ] 111 %arrayidx5 = getelementptr inbounds %struct.com2, ptr %arrayidx, i64 %j.023 112 %arrayidx6 = getelementptr inbounds [20000000000 x double], ptr %arrayidx5, i64 0, i64 1 113 %1 = load double, ptr %arrayidx6, align 8 114 %2 = load double, ptr %arrayidx5, align 8 115 %add = fadd double %1, %2 116 store double %add, ptr %arrayidx5, align 8 117 %inc = add nuw nsw i64 %j.023, 1 118 %exitcond = icmp eq i64 %inc, 1000 119 br i1 %exitcond, label %for.cond.cleanup3, label %for.body4 120} 121