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
4 ; Verify that the accesses are correctly expanded for MemoryKind::Array
6 ; Original source code :
11 ; void tmp3(double A[Ni], double B[Nj]) {
14 ; for (i = 0; i < Ni; i++) {
16 ; for(int h = 0; h<Nj; h++)
19 ; for(j = 0; j < Nj; j++) {
20 ; for(int k=0; k<Nj; k++) {
28 ; Check if the expanded SAI are created
30 ; CHECK: double MemRef_B_Stmt_for_body3_expanded[10000][10000]; // Element size 8
31 ; CHECK: double MemRef_A_Stmt_for_body11_expanded[10000][10000][10000]; // Element size 8
33 ; Check if the memory accesses are modified
35 ; CHECK: new: { Stmt_for_body3[i0, i1] -> MemRef_B_Stmt_for_body3_expanded[i0, i1] };
36 ; CHECK: new: { Stmt_for_body11[i0, i1, i2] -> MemRef_B_Stmt_for_body3_expanded[i0, i2] };
37 ; CHECK: new: { Stmt_for_body11[i0, i1, i2] -> MemRef_A_Stmt_for_body11_expanded[i0, i1, i2] };
39 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
40 target triple = "x86_64-unknown-linux-gnu"
42 define void @mse(ptr %A, ptr %B) {
46 entry.split: ; preds = %entry
49 for.body: ; preds = %entry.split, %for.inc25
50 %indvars.iv14 = phi i64 [ 0, %entry.split ], [ %indvars.iv.next15, %for.inc25 ]
53 for.body3: ; preds = %for.body, %for.body3
54 %indvars.iv = phi i64 [ 0, %for.body ], [ %indvars.iv.next, %for.body3 ]
55 %0 = trunc i64 %indvars.iv to i32
56 %conv = sitofp i32 %0 to double
57 %arrayidx = getelementptr inbounds double, ptr %B, i64 %indvars.iv
58 store double %conv, ptr %arrayidx, align 8
59 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
60 %exitcond = icmp ne i64 %indvars.iv.next, 10000
61 br i1 %exitcond, label %for.body3, label %for.end
63 for.end: ; preds = %for.body3
66 for.body7: ; preds = %for.end, %for.inc22
67 %indvars.iv9 = phi i64 [ 0, %for.end ], [ %indvars.iv.next10, %for.inc22 ]
70 for.body11: ; preds = %for.body7, %for.body11
71 %indvars.iv5 = phi i64 [ 0, %for.body7 ], [ %indvars.iv.next6, %for.body11 ]
72 %1 = add nuw nsw i64 %indvars.iv9, %indvars.iv14
73 %2 = add nuw nsw i64 %1, %indvars.iv5
74 %3 = trunc i64 %2 to i32
75 %conv13 = sitofp i32 %3 to double
76 %arrayidx15 = getelementptr inbounds double, ptr %B, i64 %indvars.iv5
77 %4 = load double, ptr %arrayidx15, align 8
78 %mul = fmul double %4, %conv13
79 %5 = add nuw nsw i64 %indvars.iv9, %indvars.iv14
80 %arrayidx18 = getelementptr inbounds double, ptr %A, i64 %5
81 store double %mul, ptr %arrayidx18, align 8
82 %indvars.iv.next6 = add nuw nsw i64 %indvars.iv5, 1
83 %exitcond8 = icmp ne i64 %indvars.iv.next6, 10000
84 br i1 %exitcond8, label %for.body11, label %for.inc22
86 for.inc22: ; preds = %for.body11
87 %indvars.iv.next10 = add nuw nsw i64 %indvars.iv9, 1
88 %exitcond13 = icmp ne i64 %indvars.iv.next10, 10000
89 br i1 %exitcond13, label %for.body7, label %for.inc25
91 for.inc25: ; preds = %for.inc22
92 %indvars.iv.next15 = add nuw nsw i64 %indvars.iv14, 1
93 %exitcond16 = icmp ne i64 %indvars.iv.next15, 10000
94 br i1 %exitcond16, label %for.body, label %for.end27
96 for.end27: ; preds = %for.inc25