1; RUN: opt %loadPolly -polly-import-jscop -polly-import-jscop-postfix=transformed -polly-simplify -analyze < %s | FileCheck %s -match-full-lines
2;
3; Map %phi to A[j], so the scalar write in Stmt_for_bodyA can be removed.
4;
5; for (int j = 0; j < n; j += 1) {
6; bodyA:
7;   val = 21.0 + 21.0;
8;   A[j] = val;
9;
10; bodyB:
11;   B[j] = val;
12; }
13;
14
15define void @sweep_mapped_phi(i32 %n, double* noalias nonnull %A, double* noalias nonnull %B) {
16entry:
17  br label %for
18
19for:
20  %j = phi i32 [0, %entry], [%j.inc, %inc]
21  %j.cmp = icmp slt i32 %j, %n
22  br i1 %j.cmp, label %bodyA, label %exit
23
24    bodyA:
25      %val = fadd double 21.0, 21.0
26      %A_idx = getelementptr inbounds double, double* %A, i32 %j
27      store double %val, double* %A_idx
28      br label %bodyB
29
30    bodyB:
31      %phi = phi double [%val, %bodyA]
32      %B_idx = getelementptr inbounds double, double* %B, i32 %j
33      store double %phi, double* %B_idx
34      br label %inc
35
36inc:
37  %j.inc = add nuw nsw i32 %j, 1
38  br label %for
39
40exit:
41  br label %return
42
43return:
44  ret void
45}
46
47
48; CHECK: Statistics {
49; CHECK:     Dead accesses removed: 1
50; CHECK: }
51
52; CHECK:      After accesses {
53; CHECK-NEXT:     Stmt_bodyA
54; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
55; CHECK-NEXT:                 [n] -> { Stmt_bodyA[i0] -> MemRef_A[i0] };
56; CHECK-NEXT:     Stmt_bodyB
57; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 1]
58; CHECK-NEXT:                 [n] -> { Stmt_bodyB[i0] -> MemRef_phi__phi[] };
59; CHECK-NEXT:            new: [n] -> { Stmt_bodyB[i0] -> MemRef_A[i0] };
60; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
61; CHECK-NEXT:                 [n] -> { Stmt_bodyB[i0] -> MemRef_B[i0] };
62; CHECK-NEXT: }
63