236
|
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
|
|
3 ; RUN: opt %loadPolly -polly-mse -polly-print-scops -pass-remarks-analysis="polly-mse" -disable-output < %s 2>&1| FileCheck %s --check-prefix=MSE
|
|
4 ; RUN: opt %loadNPMPolly "-passes=scop(print<polly-mse>)" -pass-remarks-analysis="polly-mse" -disable-output < %s 2>&1 | FileCheck %s --check-prefix=MSE
|
150
|
5 ;
|
|
6 ; Verify that Polly detects problems and does not expand the array
|
|
7 ;
|
|
8 ; Original source code :
|
|
9 ;
|
|
10 ; #define Ni 2000
|
|
11 ; #define Nj 3000
|
236
|
12 ;
|
150
|
13 ; double mse(double A[Ni], double B[Nj]) {
|
|
14 ; int i;
|
|
15 ; double tmp = 6;
|
|
16 ; for (i = 0; i < Ni; i++) {
|
|
17 ; for (int j = 2; j<Nj; j++) {
|
|
18 ; B[j-1] = j;
|
|
19 ; }
|
236
|
20 ; A[i] = B[i];
|
150
|
21 ; }
|
|
22 ; return tmp;
|
|
23 ; }
|
|
24 ;
|
|
25 ; Check that the pass detects the problem of read from original array after expansion.
|
|
26 ;
|
|
27 ; MSE: The expansion of MemRef_B would lead to a read from the original array.
|
|
28 ;
|
|
29 ; CHECK-NOT: double MemRef_B2_expanded[2000][3000]; // Element size 8
|
|
30 ;
|
|
31 ; Check that the memory accesses are not modified
|
|
32 ;
|
|
33 ; CHECK-NOT: new: { Stmt_for_body3[i0, i1] -> MemRef_B_Stmt_for_body3_expanded[i0, i1] };
|
|
34 ; CHECK-NOT: new: { Stmt_for_end[i0] -> MemRef_B_Stmt_for_body3_expanded
|
|
35 ;
|
|
36 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
|
37 target triple = "x86_64-unknown-linux-gnu"
|
|
38
|
252
|
39 define double @mse(ptr %A, ptr %B) {
|
150
|
40 entry:
|
|
41 br label %entry.split
|
|
42
|
|
43 entry.split: ; preds = %entry
|
|
44 br label %for.body
|
|
45
|
|
46 for.body: ; preds = %entry.split, %for.end
|
|
47 %indvars.iv4 = phi i64 [ 0, %entry.split ], [ %indvars.iv.next5, %for.end ]
|
|
48 br label %for.body3
|
|
49
|
|
50 for.body3: ; preds = %for.body, %for.body3
|
|
51 %indvars.iv = phi i64 [ 2, %for.body ], [ %indvars.iv.next, %for.body3 ]
|
|
52 %0 = trunc i64 %indvars.iv to i32
|
|
53 %conv = sitofp i32 %0 to double
|
|
54 %1 = add nsw i64 %indvars.iv, -1
|
252
|
55 %arrayidx = getelementptr inbounds double, ptr %B, i64 %1
|
|
56 store double %conv, ptr %arrayidx, align 8
|
150
|
57 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
|
|
58 %exitcond = icmp ne i64 %indvars.iv.next, 3000
|
|
59 br i1 %exitcond, label %for.body3, label %for.end
|
|
60
|
|
61 for.end: ; preds = %for.body3
|
252
|
62 %arrayidx5 = getelementptr inbounds double, ptr %B, i64 %indvars.iv4
|
|
63 %2 = load i64, ptr %arrayidx5, align 8
|
|
64 %arrayidx7 = getelementptr inbounds double, ptr %A, i64 %indvars.iv4
|
|
65 store i64 %2, ptr %arrayidx7, align 8
|
150
|
66 %indvars.iv.next5 = add nuw nsw i64 %indvars.iv4, 1
|
|
67 %exitcond6 = icmp ne i64 %indvars.iv.next5, 2000
|
|
68 br i1 %exitcond6, label %for.body, label %for.end10
|
|
69
|
|
70 for.end10: ; preds = %for.end
|
|
71 ret double 6.000000e+00
|
|
72 }
|