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 < Nj; j++) {
14 ; for (int i = 0; i<Ni; i++) {
23 ; Check that expanded SAI are created
24 ; CHECK: double MemRef_B_Stmt_for_body4_expanded[10000][10000]; // Element size 8
25 ; CHECK: double MemRef_D_Stmt_for_body4_expanded[10000][10000]; // Element size 8
26 ; CHECK: i64 MemRef_A_Stmt_for_end_expanded[10000]; // Element size 8
27 ; CHECK: i64 MemRef_C_Stmt_for_end_expanded[10000]; // Element size 8
29 ; Check that the memory access are modified
31 ; CHECK: new: { Stmt_for_body4[i0, i1] -> MemRef_B_Stmt_for_body4_expanded[i0, i1] };
32 ; CHECK: new: { Stmt_for_body4[i0, i1] -> MemRef_D_Stmt_for_body4_expanded[i0, i1] };
33 ; CHECK: new: { Stmt_for_end[i0] -> MemRef_B_Stmt_for_body4_expanded[i0, i0] };
34 ; CHECK: new: { Stmt_for_end[i0] -> MemRef_A_Stmt_for_end_expanded[i0] };
35 ; CHECK: new: { Stmt_for_end[i0] -> MemRef_D_Stmt_for_body4_expanded[i0, i0] };
36 ; CHECK: new: { Stmt_for_end[i0] -> MemRef_C_Stmt_for_end_expanded[i0] };
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, ptr %C, ptr %D) {
45 entry.split: ; preds = %entry
48 for.body: ; preds = %entry.split, %for.end
49 %indvars.iv3 = phi i64 [ 0, %entry.split ], [ %indvars.iv.next4, %for.end ]
52 for.body4: ; preds = %for.body, %for.body4
53 %indvars.iv = phi i64 [ 0, %for.body ], [ %indvars.iv.next, %for.body4 ]
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 %1 = trunc i64 %indvars.iv to i32
59 %conv5 = sitofp i32 %1 to double
60 %arrayidx7 = getelementptr inbounds double, ptr %D, i64 %indvars.iv
61 store double %conv5, ptr %arrayidx7, align 8
62 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
63 %exitcond = icmp ne i64 %indvars.iv.next, 10000
64 br i1 %exitcond, label %for.body4, label %for.end
66 for.end: ; preds = %for.body4
67 %arrayidx9 = getelementptr inbounds double, ptr %B, i64 %indvars.iv3
68 %2 = load i64, ptr %arrayidx9, align 8
69 %arrayidx11 = getelementptr inbounds double, ptr %A, i64 %indvars.iv3
70 store i64 %2, ptr %arrayidx11, align 8
71 %arrayidx13 = getelementptr inbounds double, ptr %D, i64 %indvars.iv3
72 %3 = load i64, ptr %arrayidx13, align 8
73 %arrayidx15 = getelementptr inbounds double, ptr %C, i64 %indvars.iv3
74 store i64 %3, ptr %arrayidx15, align 8
75 %indvars.iv.next4 = add nuw nsw i64 %indvars.iv3, 1
76 %exitcond5 = icmp ne i64 %indvars.iv.next4, 10000
77 br i1 %exitcond5, label %for.body, label %for.end18
79 for.end18: ; preds = %for.end