1; RUN: opt %loadPolly -polly-mse -analyze < %s | FileCheck %s 2; RUN: opt %loadPolly -polly-mse -pass-remarks-analysis="polly-mse" -analyze < %s 2>&1| FileCheck %s --check-prefix=MSE 3; 4; Verify that Polly detects problems and does not expand the array 5; 6; Original source code : 7; 8; #define Ni 2000 9; #define Nj 3000 10; 11; double mse(double A[Ni], double B[Nj]) { 12; int i; 13; double tmp = 6; 14; for (i = 0; i < Ni; i++) { 15; for (int j = 2; j<Nj; j++) { 16; B[j-1] = j; 17; } 18; A[i] = B[i]; 19; } 20; return tmp; 21; } 22; 23; Check that the pass detects the problem of read from original array after expansion. 24; 25; MSE: The expansion of MemRef_B would lead to a read from the original array. 26; 27; CHECK-NOT: double MemRef_B2_expanded[2000][3000]; // Element size 8 28; 29; Check that the memory accesses are not modified 30; 31; CHECK-NOT: new: { Stmt_for_body3[i0, i1] -> MemRef_B_Stmt_for_body3_expanded[i0, i1] }; 32; CHECK-NOT: new: { Stmt_for_end[i0] -> MemRef_B_Stmt_for_body3_expanded 33; 34target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 35target triple = "x86_64-unknown-linux-gnu" 36 37define double @mse(double* %A, double* %B) { 38entry: 39 br label %entry.split 40 41entry.split: ; preds = %entry 42 br label %for.body 43 44for.body: ; preds = %entry.split, %for.end 45 %indvars.iv4 = phi i64 [ 0, %entry.split ], [ %indvars.iv.next5, %for.end ] 46 br label %for.body3 47 48for.body3: ; preds = %for.body, %for.body3 49 %indvars.iv = phi i64 [ 2, %for.body ], [ %indvars.iv.next, %for.body3 ] 50 %0 = trunc i64 %indvars.iv to i32 51 %conv = sitofp i32 %0 to double 52 %1 = add nsw i64 %indvars.iv, -1 53 %arrayidx = getelementptr inbounds double, double* %B, i64 %1 54 store double %conv, double* %arrayidx, align 8 55 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 56 %exitcond = icmp ne i64 %indvars.iv.next, 3000 57 br i1 %exitcond, label %for.body3, label %for.end 58 59for.end: ; preds = %for.body3 60 %arrayidx5 = getelementptr inbounds double, double* %B, i64 %indvars.iv4 61 %2 = bitcast double* %arrayidx5 to i64* 62 %3 = load i64, i64* %2, align 8 63 %arrayidx7 = getelementptr inbounds double, double* %A, i64 %indvars.iv4 64 %4 = bitcast double* %arrayidx7 to i64* 65 store i64 %3, i64* %4, align 8 66 %indvars.iv.next5 = add nuw nsw i64 %indvars.iv4, 1 67 %exitcond6 = icmp ne i64 %indvars.iv.next5, 2000 68 br i1 %exitcond6, label %for.body, label %for.end10 69 70for.end10: ; preds = %for.end 71 ret double 6.000000e+00 72} 73