1 ; RUN: opt %loadPolly -polly-mse -polly-print-scops -disable-output < %s | FileCheck %s
2 ; RUN: opt %loadNPMPolly "-passes=scop(print<polly-mse>)" -disable-output < %s | FileCheck %s
3 ; RUN: opt %loadPolly -polly-mse -polly-print-scops -pass-remarks-analysis="polly-mse" -disable-output < %s 2>&1 | FileCheck %s --check-prefix=MSE
4 ; RUN: opt %loadNPMPolly -polly-stmt-granularity=bb "-passes=scop(print<polly-mse>)" -pass-remarks-analysis="polly-mse" -disable-output < %s 2>&1 | FileCheck %s --check-prefix=MSE
6 ; Verify that the accesses are correctly expanded for MemoryKind::Array and MemoryKind::PHI.
7 ; tmp_06_phi is not expanded because it need copy in.
9 ; Original source code :
14 ; void tmp3(double A[Ni], double B[Nj]) {
17 ; for (i = 0; i < Ni; i++) {
19 ; for(int h = 0; h<Nj; h++)
22 ; for(j = 0; j < Nj; j++) {
23 ; for(int k=0; k<Nj; k++) {
31 ; Check if the expanded SAI are created except for tmp_06_phi
33 ; MSE: MemRef_tmp_06__phi read from its original value.
35 ; CHECK-DAG: double MemRef_A_Stmt_for_body11_expanded[10000][10000][10000]; // Element size 8
36 ; CHECK-DAG: double MemRef_add16_lcssa__phi_Stmt_for_inc25_expanded[10000][10000]; // Element size 8
37 ; CHECK-DAG: double MemRef_B_Stmt_for_body3_expanded[10000][10000]; // Element size 8
38 ; CHECK-DAG: double MemRef_tmp_06_Stmt_for_body_expanded[10000]; // Element size 8
39 ; CHECK-DAG: double MemRef_add16_lcssa_lcssa__phi_Stmt_for_inc28_expanded[10000]; // Element size 8
40 ; CHECK-DAG: double MemRef_tmp_14__phi_Stmt_for_body7_expanded[10000][10000]; // Element size 8
41 ; CHECK-DAG: double MemRef_tmp_22__phi_Stmt_for_body11_expanded[10000][10000][10000]; // Element size 8
42 ; CHECK-NOT: double MemRef_tmp_06__phi_Stmt_for_body_expanded[10000]; // Element size 8
44 ; Check if the memory accesses are modified except those of tmp_06_phi
46 ; CHECK-NOT: new: { Stmt_for_body[i0] -> MemRef_tmp_06__phi_Stmt_for_body_expanded[i0] };
47 ; CHECK-DAG: new: { Stmt_for_body[i0] -> MemRef_tmp_06_Stmt_for_body_expanded[i0] };
48 ; CHECK-DAG: new: { Stmt_for_body3[i0, i1] -> MemRef_B_Stmt_for_body3_expanded[i0, i1] };
49 ; CHECK-DAG: new: { Stmt_for_end[i0] -> MemRef_tmp_06_Stmt_for_body_expanded[i0] };
50 ; CHECK-DAG: new: { Stmt_for_end[i0] -> MemRef_tmp_14__phi_Stmt_for_body7_expanded[i0, 0] };
51 ; CHECK-DAG: new: { Stmt_for_body7[i0, i1] -> MemRef_tmp_14__phi_Stmt_for_body7_expanded[i0, i1] };
52 ; CHECK-DAG: new: { Stmt_for_body7[i0, i1] -> MemRef_tmp_22__phi_Stmt_for_body11_expanded[i0, i1, 0] };
53 ; CHECK-DAG: new: { Stmt_for_body11[i0, i1, i2] -> MemRef_tmp_22__phi_Stmt_for_body11_expanded[i0, i1, 1 + i2] : i2 <= 9998 };
54 ; CHECK-DAG: new: { Stmt_for_body11[i0, i1, i2] -> MemRef_tmp_22__phi_Stmt_for_body11_expanded[i0, i1, i2] };
55 ; CHECK-DAG: new: { Stmt_for_body11[i0, i1, i2] -> MemRef_B_Stmt_for_body3_expanded[i0, i2] };
56 ; CHECK-DAG: new: { Stmt_for_body11[i0, i1, i2] -> MemRef_A_Stmt_for_body11_expanded[i0, i1, i2] };
57 ; CHECK-DAG: new: { Stmt_for_body11[i0, i1, 9999] -> MemRef_add16_lcssa__phi_Stmt_for_inc25_expanded[i0, i1] };
58 ; CHECK-DAG: new: { Stmt_for_inc25[i0, i1] -> MemRef_tmp_14__phi_Stmt_for_body7_expanded[i0, 1 + i1] : i1 <= 9998 };
59 ; CHECK-DAG: new: { Stmt_for_inc25[i0, i1] -> MemRef_add16_lcssa__phi_Stmt_for_inc25_expanded[i0, i1] };
60 ; CHECK-DAG: new: { Stmt_for_inc25[i0, 9999] -> MemRef_add16_lcssa_lcssa__phi_Stmt_for_inc28_expanded[i0] };
61 ; CHECK-DAG: new: { Stmt_for_inc28[i0] -> MemRef_add16_lcssa_lcssa__phi_Stmt_for_inc28_expanded[i0] };
62 ; CHECK-NOT: new: { Stmt_for_inc28[i0] -> MemRef_tmp_06__phi_Stmt_for_body_expanded[1 + i0] : i0 <= 9998 };
64 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
65 target triple = "x86_64-unknown-linux-gnu"
67 define void @mse(ptr %A, ptr %B) {
71 entry.split: ; preds = %entry
74 for.body: ; preds = %entry.split, %for.inc28
75 %indvars.iv15 = phi i64 [ 0, %entry.split ], [ %indvars.iv.next16, %for.inc28 ]
76 %tmp.06 = phi double [ 6.000000e+00, %entry.split ], [ %add16.lcssa.lcssa, %for.inc28 ]
79 for.body3: ; preds = %for.body, %for.body3
80 %indvars.iv = phi i64 [ 0, %for.body ], [ %indvars.iv.next, %for.body3 ]
81 %0 = trunc i64 %indvars.iv to i32
82 %conv = sitofp i32 %0 to double
83 %arrayidx = getelementptr inbounds double, ptr %B, i64 %indvars.iv
84 store double %conv, ptr %arrayidx, align 8
85 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
86 %exitcond = icmp ne i64 %indvars.iv.next, 10000
87 br i1 %exitcond, label %for.body3, label %for.end
89 for.end: ; preds = %for.body3
92 for.body7: ; preds = %for.end, %for.inc25
93 %indvars.iv11 = phi i64 [ 0, %for.end ], [ %indvars.iv.next12, %for.inc25 ]
94 %tmp.14 = phi double [ %tmp.06, %for.end ], [ %add16.lcssa, %for.inc25 ]
97 for.body11: ; preds = %for.body7, %for.body11
98 %indvars.iv8 = phi i64 [ 0, %for.body7 ], [ %indvars.iv.next9, %for.body11 ]
99 %tmp.22 = phi double [ %tmp.14, %for.body7 ], [ %add16, %for.body11 ]
100 %1 = trunc i64 %indvars.iv15 to i32
101 %conv12 = sitofp i32 %1 to double
102 %add = fadd double %tmp.22, %conv12
103 %2 = trunc i64 %indvars.iv8 to i32
104 %conv13 = sitofp i32 %2 to double
105 %add14 = fadd double %add, %conv13
106 %3 = trunc i64 %indvars.iv11 to i32
107 %conv15 = sitofp i32 %3 to double
108 %add16 = fadd double %add14, %conv15
109 %arrayidx18 = getelementptr inbounds double, ptr %B, i64 %indvars.iv8
110 %4 = load double, ptr %arrayidx18, align 8
111 %mul = fmul double %add16, %4
112 %5 = add nuw nsw i64 %indvars.iv11, %indvars.iv15
113 %arrayidx21 = getelementptr inbounds double, ptr %A, i64 %5
114 store double %mul, ptr %arrayidx21, align 8
115 %indvars.iv.next9 = add nuw nsw i64 %indvars.iv8, 1
116 %exitcond10 = icmp ne i64 %indvars.iv.next9, 10000
117 br i1 %exitcond10, label %for.body11, label %for.inc25
119 for.inc25: ; preds = %for.body11
120 %add16.lcssa = phi double [ %add16, %for.body11 ]
121 %indvars.iv.next12 = add nuw nsw i64 %indvars.iv11, 1
122 %exitcond14 = icmp ne i64 %indvars.iv.next12, 10000
123 br i1 %exitcond14, label %for.body7, label %for.inc28
125 for.inc28: ; preds = %for.inc25
126 %add16.lcssa.lcssa = phi double [ %add16.lcssa, %for.inc25 ]
127 %indvars.iv.next16 = add nuw nsw i64 %indvars.iv15, 1
128 %exitcond17 = icmp ne i64 %indvars.iv.next16, 10000
129 br i1 %exitcond17, label %for.body, label %for.end30
131 for.end30: ; preds = %for.inc28