1; RUN: opt %loadNPMPolly -polly-stmt-granularity=bb "-passes=scop(print<polly-mse>)" -disable-output < %s | FileCheck %s
2;
3; Verify that the accesses are correctly expanded
4;
5; Original source code :
6;
7; #define Ni 2000
8; #define Nj 3000
9;
10; void mse(double A[Ni], double B[Nj], double C[Nj], double D[Nj]) {
11;   int i,j;
12;   for (j = 0; j < Ni; j++) {
13;     for (int i = 0; i<Nj; i++)
14;       B[i] = i;
15;
16;     for (int i = 0; i<Nj; i++)
17;       D[i] = i;
18;
19;     A[j] = B[j];
20;     C[j] = D[j];
21;   }
22; }
23;
24; Check that expanded SAI are created
25;
26; CHECK: double MemRef_B_Stmt_for_body4_expanded[10000][10000]; // Element size 8
27; CHECK: double MemRef_D_Stmt_for_body9_expanded[10000][10000]; // Element size 8
28; CHECK: i64 MemRef_A_Stmt_for_end15_expanded[10000]; // Element size 8
29; CHECK: i64 MemRef_C_Stmt_for_end15_expanded[10000]; // Element size 8
30;
31; Check that the memory accesses are modified
32; CHECK: new: { Stmt_for_body4[i0, i1] -> MemRef_B_Stmt_for_body4_expanded[i0, i1] };
33; CHECK: new: { Stmt_for_body9[i0, i1] -> MemRef_D_Stmt_for_body9_expanded[i0, i1] };
34; CHECK: new: { Stmt_for_end15[i0] -> MemRef_B_Stmt_for_body4_expanded[i0, i0] };
35; CHECK: new: { Stmt_for_end15[i0] -> MemRef_A_Stmt_for_end15_expanded[i0] };
36; CHECK: new: { Stmt_for_end15[i0] -> MemRef_D_Stmt_for_body9_expanded[i0, i0] };
37; CHECK: new: { Stmt_for_end15[i0] -> MemRef_C_Stmt_for_end15_expanded[i0] };
38;
39target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
40target triple = "x86_64-unknown-linux-gnu"
41
42define void @mse(ptr %A, ptr %B, ptr %C, ptr %D) {
43entry:
44  br label %entry.split
45
46entry.split:                                      ; preds = %entry
47  br label %for.body
48
49for.body:                                         ; preds = %entry.split, %for.end15
50  %indvars.iv7 = phi i64 [ 0, %entry.split ], [ %indvars.iv.next8, %for.end15 ]
51  br label %for.body4
52
53for.body4:                                        ; preds = %for.body, %for.body4
54  %indvars.iv = phi i64 [ 0, %for.body ], [ %indvars.iv.next, %for.body4 ]
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.body4, label %for.end
62
63for.end:                                          ; preds = %for.body4
64  br label %for.body9
65
66for.body9:                                        ; preds = %for.end, %for.body9
67  %indvars.iv4 = phi i64 [ 0, %for.end ], [ %indvars.iv.next5, %for.body9 ]
68  %1 = trunc i64 %indvars.iv4 to i32
69  %conv10 = sitofp i32 %1 to double
70  %arrayidx12 = getelementptr inbounds double, ptr %D, i64 %indvars.iv4
71  store double %conv10, ptr %arrayidx12, align 8
72  %indvars.iv.next5 = add nuw nsw i64 %indvars.iv4, 1
73  %exitcond6 = icmp ne i64 %indvars.iv.next5, 10000
74  br i1 %exitcond6, label %for.body9, label %for.end15
75
76for.end15:                                        ; preds = %for.body9
77  %arrayidx17 = getelementptr inbounds double, ptr %B, i64 %indvars.iv7
78  %2 = load i64, ptr %arrayidx17, align 8
79  %arrayidx19 = getelementptr inbounds double, ptr %A, i64 %indvars.iv7
80  store i64 %2, ptr %arrayidx19, align 8
81  %arrayidx21 = getelementptr inbounds double, ptr %D, i64 %indvars.iv7
82  %3 = load i64, ptr %arrayidx21, align 8
83  %arrayidx23 = getelementptr inbounds double, ptr %C, i64 %indvars.iv7
84  store i64 %3, ptr %arrayidx23, align 8
85  %indvars.iv.next8 = add nuw nsw i64 %indvars.iv7, 1
86  %exitcond9 = icmp ne i64 %indvars.iv.next8, 10000
87  br i1 %exitcond9, label %for.body, label %for.end26
88
89for.end26:                                        ; preds = %for.end15
90  ret void
91}
92