1; RUN: opt %loadPolly -polly-stmt-granularity=scalar-indep -polly-print-instructions -polly-scops -analyze < %s | FileCheck %s -match-full-lines
2;
3; Check that the PHI Write of value that is defined in the same basic
4; block is in the statement where it is defined.
5;
6; for (int j = 0; j < n; j += 1) {
7; bodyA:
8;   double valA = A[0];
9;   A[0] = valA;
10;   double valB = B[0];
11;   B[0] = valB;
12;
13; bodyB:
14;   phi = valA;
15; }
16;
17define void @func(i32 %n, double* noalias nonnull %A, double* noalias nonnull %B) {
18entry:
19  br label %for
20
21for:
22  %j = phi i32 [0, %entry], [%j.inc, %inc]
23  %j.cmp = icmp slt i32 %j, %n
24  br i1 %j.cmp, label %bodyA, label %exit
25
26    bodyA:
27      %valA = load double, double* %A
28      store double %valA, double* %A
29      %valB = load double, double* %B
30      store double %valB, double* %B
31      br label %bodyB
32
33    bodyB:
34      %phi = phi double [%valA, %bodyA]
35      br label %inc
36
37inc:
38  %j.inc = add nuw nsw i32 %j, 1
39  br label %for
40
41exit:
42  br label %return
43
44return:
45  ret void
46}
47
48
49; CHECK:      Statements {
50; CHECK-NEXT:     Stmt_bodyA
51; CHECK-NEXT:         Domain :=
52; CHECK-NEXT:             [n] -> { Stmt_bodyA[i0] : 0 <= i0 < n };
53; CHECK-NEXT:         Schedule :=
54; CHECK-NEXT:             [n] -> { Stmt_bodyA[i0] -> [i0, 0] };
55; CHECK-NEXT:         ReadAccess :=       [Reduction Type: NONE] [Scalar: 0]
56; CHECK-NEXT:             [n] -> { Stmt_bodyA[i0] -> MemRef_A[0] };
57; CHECK-NEXT:         MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
58; CHECK-NEXT:             [n] -> { Stmt_bodyA[i0] -> MemRef_A[0] };
59; CHECK-NEXT:         MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
60; CHECK-NEXT:             [n] -> { Stmt_bodyA[i0] -> MemRef_phi__phi[] };
61; CHECK-NEXT:         Instructions {
62; CHECK-NEXT:               %valA = load double, double* %A, align 8
63; CHECK-NEXT:               store double %valA, double* %A, align 8
64; CHECK-NEXT:         }
65; CHECK-NEXT:     Stmt_bodyA_b
66; CHECK-NEXT:         Domain :=
67; CHECK-NEXT:             [n] -> { Stmt_bodyA_b[i0] : 0 <= i0 < n };
68; CHECK-NEXT:         Schedule :=
69; CHECK-NEXT:             [n] -> { Stmt_bodyA_b[i0] -> [i0, 1] };
70; CHECK-NEXT:         ReadAccess :=       [Reduction Type: NONE] [Scalar: 0]
71; CHECK-NEXT:             [n] -> { Stmt_bodyA_b[i0] -> MemRef_B[0] };
72; CHECK-NEXT:         MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
73; CHECK-NEXT:             [n] -> { Stmt_bodyA_b[i0] -> MemRef_B[0] };
74; CHECK-NEXT:         Instructions {
75; CHECK-NEXT:               %valB = load double, double* %B, align 8
76; CHECK-NEXT:               store double %valB, double* %B, align 8
77; CHECK-NEXT:         }
78; CHECK-NEXT: }
79