1 ; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-mse -polly-print-scops -disable-output < %s | FileCheck %s
2 ; RUN: opt %loadNPMPolly -polly-stmt-granularity=bb "-passes=scop(print<polly-mse>)" -disable-output < %s | FileCheck %s
4 ; Verify that the accesses are correctly expanded
6 ; Original source code :
11 ; void mse(double A[Ni], double B[Nj], double C[Nj], double D[Nj]) {
13 ; for (j = 0; j < Ni; j++) {
14 ; for (int i = 0; i<Nj; i++)
17 ; for (int i = 0; i<Nj; i++)
25 ; Check that expanded SAI are created
27 ; CHECK: double MemRef_B_Stmt_for_body4_expanded[10000][10000]; // Element size 8
28 ; CHECK: double MemRef_D_Stmt_for_body9_expanded[10000][10000]; // Element size 8
29 ; CHECK: i64 MemRef_A_Stmt_for_end15_expanded[10000]; // Element size 8
30 ; CHECK: i64 MemRef_C_Stmt_for_end15_expanded[10000]; // Element size 8
32 ; Check that the memory accesses are modified
33 ; CHECK: new: { Stmt_for_body4[i0, i1] -> MemRef_B_Stmt_for_body4_expanded[i0, i1] };
34 ; CHECK: new: { Stmt_for_body9[i0, i1] -> MemRef_D_Stmt_for_body9_expanded[i0, i1] };
35 ; CHECK: new: { Stmt_for_end15[i0] -> MemRef_B_Stmt_for_body4_expanded[i0, i0] };
36 ; CHECK: new: { Stmt_for_end15[i0] -> MemRef_A_Stmt_for_end15_expanded[i0] };
37 ; CHECK: new: { Stmt_for_end15[i0] -> MemRef_D_Stmt_for_body9_expanded[i0, i0] };
38 ; CHECK: new: { Stmt_for_end15[i0] -> MemRef_C_Stmt_for_end15_expanded[i0] };
40 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
41 target triple = "x86_64-unknown-linux-gnu"
43 define void @mse(ptr %A, ptr %B, ptr %C, ptr %D) {
47 entry.split: ; preds = %entry
50 for.body: ; preds = %entry.split, %for.end15
51 %indvars.iv7 = phi i64 [ 0, %entry.split ], [ %indvars.iv.next8, %for.end15 ]
54 for.body4: ; preds = %for.body, %for.body4
55 %indvars.iv = phi i64 [ 0, %for.body ], [ %indvars.iv.next, %for.body4 ]
56 %0 = trunc i64 %indvars.iv to i32
57 %conv = sitofp i32 %0 to double
58 %arrayidx = getelementptr inbounds double, ptr %B, i64 %indvars.iv
59 store double %conv, ptr %arrayidx, align 8
60 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
61 %exitcond = icmp ne i64 %indvars.iv.next, 10000
62 br i1 %exitcond, label %for.body4, label %for.end
64 for.end: ; preds = %for.body4
67 for.body9: ; preds = %for.end, %for.body9
68 %indvars.iv4 = phi i64 [ 0, %for.end ], [ %indvars.iv.next5, %for.body9 ]
69 %1 = trunc i64 %indvars.iv4 to i32
70 %conv10 = sitofp i32 %1 to double
71 %arrayidx12 = getelementptr inbounds double, ptr %D, i64 %indvars.iv4
72 store double %conv10, ptr %arrayidx12, align 8
73 %indvars.iv.next5 = add nuw nsw i64 %indvars.iv4, 1
74 %exitcond6 = icmp ne i64 %indvars.iv.next5, 10000
75 br i1 %exitcond6, label %for.body9, label %for.end15
77 for.end15: ; preds = %for.body9
78 %arrayidx17 = getelementptr inbounds double, ptr %B, i64 %indvars.iv7
79 %2 = load i64, ptr %arrayidx17, align 8
80 %arrayidx19 = getelementptr inbounds double, ptr %A, i64 %indvars.iv7
81 store i64 %2, ptr %arrayidx19, align 8
82 %arrayidx21 = getelementptr inbounds double, ptr %D, i64 %indvars.iv7
83 %3 = load i64, ptr %arrayidx21, align 8
84 %arrayidx23 = getelementptr inbounds double, ptr %C, i64 %indvars.iv7
85 store i64 %3, ptr %arrayidx23, align 8
86 %indvars.iv.next8 = add nuw nsw i64 %indvars.iv7, 1
87 %exitcond9 = icmp ne i64 %indvars.iv.next8, 10000
88 br i1 %exitcond9, label %for.body, label %for.end26
90 for.end26: ; preds = %for.end15