1; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-mse -analyze < %s | FileCheck %s 2; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-mse -pass-remarks-analysis="polly-mse" -analyze < %s 2>&1| FileCheck %s --check-prefix=MSE 3; 4; Verify that the expansion of an array with load after store in a same statement is not done. 5; 6; Original source code : 7; 8; #define Ni 2000 9; #define Nj 3000 10; 11; void mse(double A[Ni], double B[Nj], double C[Nj], double D[Nj]) { 12; int i,j; 13; for (i = 0; i < Ni; i++) { 14; for (int j = 0; j<Nj; j++) { 15; B[j] = j; 16; C[j] = B[j]; 17; } 18; } 19; } 20; 21; Check that C is expanded 22; 23; CHECK: i64 MemRef_C_Stmt_for_body4_expanded[10000][10000]; // Element size 8 24; CHECK: new: { Stmt_for_body4[i0, i1] -> MemRef_C_Stmt_for_body4_expanded[i0, i1] }; 25; 26; Check that B is not expanded 27; 28; CHECK-NOT: double MemRef_B_Stmt_for_body4_expanded[10000][10000]; // Element size 8 29; MSE: MemRef_B has read after write to the same element in same statement. The dependences found during analysis may be wrong because Polly is not able to handle such case for now. 30; 31target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 32target triple = "x86_64-unknown-linux-gnu" 33 34define void @mse(double* %A, double* %B, double* %C, double* %D) { 35entry: 36 br label %entry.split 37 38entry.split: ; preds = %entry 39 br label %for.body 40 41for.body: ; preds = %entry.split, %for.inc9 42 %i.02 = phi i32 [ 0, %entry.split ], [ %inc10, %for.inc9 ] 43 br label %for.body4 44 45for.body4: ; preds = %for.body, %for.body4 46 %indvars.iv = phi i64 [ 0, %for.body ], [ %indvars.iv.next, %for.body4 ] 47 %0 = trunc i64 %indvars.iv to i32 48 %conv = sitofp i32 %0 to double 49 %arrayidx = getelementptr inbounds double, double* %B, i64 %indvars.iv 50 store double %conv, double* %arrayidx, align 8 51 %arrayidx6 = getelementptr inbounds double, double* %B, i64 %indvars.iv 52 %1 = bitcast double* %arrayidx6 to i64* 53 %2 = load i64, i64* %1, align 8 54 %arrayidx8 = getelementptr inbounds double, double* %C, i64 %indvars.iv 55 %3 = bitcast double* %arrayidx8 to i64* 56 store i64 %2, i64* %3, align 8 57 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 58 %exitcond = icmp ne i64 %indvars.iv.next, 10000 59 br i1 %exitcond, label %for.body4, label %for.inc9 60 61for.inc9: ; preds = %for.body4 62 %inc10 = add nuw nsw i32 %i.02, 1 63 %exitcond3 = icmp ne i32 %inc10, 10000 64 br i1 %exitcond3, label %for.body, label %for.end11 65 66for.end11: ; preds = %for.inc9 67 ret void 68} 69