1 ; RUN: opt %loadNPMPolly "-passes=scop(print<polly-mse>)" -disable-output < %s | FileCheck %s
3 ; Verify that the accesses are correctly expanded for MemoryKind::Array
5 ; Original source code :
10 ; void tmp3(double A[Ni], double B[Nj]) {
13 ; for (i = 0; i < Ni; i++) {
15 ; for(int h = 0; h<Nj; h++)
18 ; for(j = 0; j < Nj; j++) {
19 ; for(int k=0; k<Nj; k++) {
27 ; Check if the expanded SAI are created
29 ; CHECK: double MemRef_B_Stmt_for_body3_expanded[10000][10000]; // Element size 8
30 ; CHECK: double MemRef_A_Stmt_for_body11_expanded[10000][10000][10000]; // Element size 8
32 ; Check if the memory accesses are modified
34 ; CHECK: new: { Stmt_for_body3[i0, i1] -> MemRef_B_Stmt_for_body3_expanded[i0, i1] };
35 ; CHECK: new: { Stmt_for_body11[i0, i1, i2] -> MemRef_B_Stmt_for_body3_expanded[i0, i2] };
36 ; CHECK: new: { Stmt_for_body11[i0, i1, i2] -> MemRef_A_Stmt_for_body11_expanded[i0, i1, i2] };
38 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
39 target triple = "x86_64-unknown-linux-gnu"
41 define void @mse(ptr %A, ptr %B) {
45 entry.split: ; preds = %entry
48 for.body: ; preds = %entry.split, %for.inc25
49 %indvars.iv14 = phi i64 [ 0, %entry.split ], [ %indvars.iv.next15, %for.inc25 ]
52 for.body3: ; preds = %for.body, %for.body3
53 %indvars.iv = phi i64 [ 0, %for.body ], [ %indvars.iv.next, %for.body3 ]
54 %0 = trunc i64 %indvars.iv to i32
55 %conv = sitofp i32 %0 to double
56 %arrayidx = getelementptr inbounds double, ptr %B, i64 %indvars.iv
57 store double %conv, ptr %arrayidx, align 8
58 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
59 %exitcond = icmp ne i64 %indvars.iv.next, 10000
60 br i1 %exitcond, label %for.body3, label %for.end
62 for.end: ; preds = %for.body3
65 for.body7: ; preds = %for.end, %for.inc22
66 %indvars.iv9 = phi i64 [ 0, %for.end ], [ %indvars.iv.next10, %for.inc22 ]
69 for.body11: ; preds = %for.body7, %for.body11
70 %indvars.iv5 = phi i64 [ 0, %for.body7 ], [ %indvars.iv.next6, %for.body11 ]
71 %1 = add nuw nsw i64 %indvars.iv9, %indvars.iv14
72 %2 = add nuw nsw i64 %1, %indvars.iv5
73 %3 = trunc i64 %2 to i32
74 %conv13 = sitofp i32 %3 to double
75 %arrayidx15 = getelementptr inbounds double, ptr %B, i64 %indvars.iv5
76 %4 = load double, ptr %arrayidx15, align 8
77 %mul = fmul double %4, %conv13
78 %5 = add nuw nsw i64 %indvars.iv9, %indvars.iv14
79 %arrayidx18 = getelementptr inbounds double, ptr %A, i64 %5
80 store double %mul, ptr %arrayidx18, align 8
81 %indvars.iv.next6 = add nuw nsw i64 %indvars.iv5, 1
82 %exitcond8 = icmp ne i64 %indvars.iv.next6, 10000
83 br i1 %exitcond8, label %for.body11, label %for.inc22
85 for.inc22: ; preds = %for.body11
86 %indvars.iv.next10 = add nuw nsw i64 %indvars.iv9, 1
87 %exitcond13 = icmp ne i64 %indvars.iv.next10, 10000
88 br i1 %exitcond13, label %for.body7, label %for.inc25
90 for.inc25: ; preds = %for.inc22
91 %indvars.iv.next15 = add nuw nsw i64 %indvars.iv14, 1
92 %exitcond16 = icmp ne i64 %indvars.iv.next15, 10000
93 br i1 %exitcond16, label %for.body, label %for.end27
95 for.end27: ; preds = %for.inc25