1; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-scops -analyze -polly-import-jscop -polly-import-jscop-postfix=transformed < %s | FileCheck %s 2; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-import-jscop -polly-import-jscop-postfix=transformed -polly-codegen -S < %s | FileCheck %s --check-prefix=CODEGEN 3; 4; #define Ni 1056 5; #define Nj 1056 6; #define Nk 1024 7; 8; void create_arrays_heap(double beta, double A[Ni][Nk], double B[Ni][Nj]) { 9; int i,j,k; 10; 11; for (i = 0; i < Ni; i++) { 12; for (j = 0; j < Nj; j++) { 13; for (k = 0; k < Nk; ++k) { 14; B[i][j] = beta * A[i][k]; 15; } 16; } 17; } 18; } 19; 20; Check if the info from the JSON file has been analysed without errors. 21; CHECK: Arrays { 22; CHECK: double MemRef_A[*][1024]; // Element size 8 23; CHECK: double MemRef_beta; // Element size 8 24; CHECK: double MemRef_B[*][1056]; // Element size 8 25; CHECK: double D[270336]; // Element size 8 26; CHECK: double E[270336][200000]; // Element size 8 27; CHECK: i64 F[270336]; // Element size 8 28; 29; Check if there are the 3 expected malloc calls with the right parameters at polly.start. 30; %D : size(D) = product_all_dimensions*sizeof(type) = 270336*8 = 2162688 cast to double* 31; %E : size(E) = 270336*200000*8 = 432537600000 cast to double* 32; %F : size(F) = 270336*8 = 2162688 cast to i64* 33; CODEGEN: polly.start: 34; CODEGEN: %malloccall = tail call i8* @malloc(i64 2162688) 35; CODEGEN: %D = bitcast i8* %malloccall to double* 36; CODEGEN: %malloccall1 = tail call i8* @malloc(i64 432537600000) 37; CODEGEN: %E = bitcast i8* %malloccall1 to double* 38; CODEGEN: %malloccall2 = tail call i8* @malloc(i64 2162688) 39; CODEGEN: %F = bitcast i8* %malloccall2 to i64* 40; 41; Check if there are the 3 expected malloc calls with the right parameters at polly.exiting. 42; Cast to i8* before freeing because malloc give us a i8 and free is waiting for a i8* 43; CODEGEN: polly.exiting: 44; CODEGEN: %12 = bitcast double* %D to i8* 45; CODEGEN: tail call void @free(i8* %12) 46; CODEGEN: %13 = bitcast double* %E to i8* 47; CODEGEN: tail call void @free(i8* %13) 48; CODEGEN: %14 = bitcast i64* %F to i8* 49; CODEGEN: tail call void @free(i8* %14) 50; 51; Check if the new access for array E is present. 52; CODEGEN: %polly.access.mul.E = mul nsw i64 %polly.indvar, 200000 53; CODEGEN: %polly.access.add.E = add nsw i64 %polly.access.mul.E, % 54; CODEGEN: %polly.access.E = getelementptr double, double* %E, i64 %polly.access.add.E 55; 56; ModuleID = 'create_arrays_heap.ll' 57; 58target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 59target triple = "x86_64-unknown-linux-gnu" 60 61; Function Attrs: nounwind uwtable 62define void @create_arrays_heap(double %beta, [1024 x double]* nocapture readonly %A, [1056 x double]* nocapture %B) local_unnamed_addr { 63entry: 64 br label %for.cond1.preheader 65 66for.cond1.preheader: ; preds = %for.inc16, %entry 67 %indvars.iv35 = phi i64 [ 0, %entry ], [ %indvars.iv.next36, %for.inc16 ] 68 br label %for.cond4.preheader 69 70for.cond4.preheader: ; preds = %for.inc13, %for.cond1.preheader 71 %indvars.iv32 = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next33, %for.inc13 ] 72 %arrayidx12 = getelementptr inbounds [1056 x double], [1056 x double]* %B, i64 %indvars.iv35, i64 %indvars.iv32 73 br label %for.body6 74 75for.body6: ; preds = %for.body6, %for.cond4.preheader 76 %indvars.iv = phi i64 [ 0, %for.cond4.preheader ], [ %indvars.iv.next.3, %for.body6 ] 77 %arrayidx8 = getelementptr inbounds [1024 x double], [1024 x double]* %A, i64 %indvars.iv35, i64 %indvars.iv 78 %0 = load double, double* %arrayidx8, align 8 79 %mul = fmul double %0, %beta 80 store double %mul, double* %arrayidx12, align 8 81 %indvars.iv.next = or i64 %indvars.iv, 1 82 %arrayidx8.1 = getelementptr inbounds [1024 x double], [1024 x double]* %A, i64 %indvars.iv35, i64 %indvars.iv.next 83 %1 = load double, double* %arrayidx8.1, align 8 84 %mul.1 = fmul double %1, %beta 85 store double %mul.1, double* %arrayidx12, align 8 86 %indvars.iv.next.1 = or i64 %indvars.iv, 2 87 %arrayidx8.2 = getelementptr inbounds [1024 x double], [1024 x double]* %A, i64 %indvars.iv35, i64 %indvars.iv.next.1 88 %2 = load double, double* %arrayidx8.2, align 8 89 %mul.2 = fmul double %2, %beta 90 store double %mul.2, double* %arrayidx12, align 8 91 %indvars.iv.next.2 = or i64 %indvars.iv, 3 92 %arrayidx8.3 = getelementptr inbounds [1024 x double], [1024 x double]* %A, i64 %indvars.iv35, i64 %indvars.iv.next.2 93 %3 = load double, double* %arrayidx8.3, align 8 94 %mul.3 = fmul double %3, %beta 95 store double %mul.3, double* %arrayidx12, align 8 96 %indvars.iv.next.3 = add nsw i64 %indvars.iv, 4 97 %exitcond.3 = icmp eq i64 %indvars.iv.next.3, 1024 98 br i1 %exitcond.3, label %for.inc13, label %for.body6 99 100for.inc13: ; preds = %for.body6 101 %indvars.iv.next33 = add nuw nsw i64 %indvars.iv32, 1 102 %exitcond34 = icmp eq i64 %indvars.iv.next33, 1056 103 br i1 %exitcond34, label %for.inc16, label %for.cond4.preheader 104 105for.inc16: ; preds = %for.inc13 106 %indvars.iv.next36 = add nuw nsw i64 %indvars.iv35, 1 107 %exitcond37 = icmp eq i64 %indvars.iv.next36, 1056 108 br i1 %exitcond37, label %for.end18, label %for.cond1.preheader 109 110for.end18: ; preds = %for.inc16 111 ret void 112} 113 114