1; RUN: opt %loadPolly -polly-optree -analyze < %s | FileCheck %s -match-full-lines
2;
3; Rematerialize a load.
4; The non-analyzable store to C[0] is unrelated and can be ignored.
5;
6; for (int j = 0; j < n; j += 1) {
7; bodyA:
8;   double val = B[j];
9;   C[0] = 21.0;
10;   C[0] = 42.0;
11;
12; bodyB:
13;   A[j] = val;
14; }
15;
16define void @func(i32 %n, double* noalias nonnull %A, double* noalias nonnull %B, double *noalias %C) {
17entry:
18  br label %for
19
20for:
21  %j = phi i32 [0, %entry], [%j.inc, %inc]
22  %j.cmp = icmp slt i32 %j, %n
23  br i1 %j.cmp, label %bodyA, label %exit
24
25    bodyA:
26      %B_idx = getelementptr inbounds double, double* %B, i32 %j
27      %val = load double, double* %B_idx
28      store double 21.0, double* %C
29      store double 41.0, double* %C
30      br label %bodyB
31
32    bodyB:
33      %A_idx = getelementptr inbounds double, double* %A, i32 %j
34      store double %val, double* %A_idx
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: Statistics {
50; CHECK:     Known loads forwarded: 1
51; CHECK:     Operand trees forwarded: 1
52; CHECK:     Statements with forwarded operand trees: 1
53; CHECK: }
54
55; CHECK:      Stmt_bodyB
56; CHECK-NEXT:         ReadAccess :=       [Reduction Type: NONE] [Scalar: 0]
57; CHECK-NEXT:             ;
58; CHECK-NEXT:        new: [n] -> { Stmt_bodyB[i0] -> MemRef_B[i0] };
59; CHECK-NEXT:         MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
60; CHECK-NEXT:             [n] -> { Stmt_bodyB[i0] -> MemRef_A[i0] };
61; CHECK-NEXT:         Instructions {
62; CHECK-NEXT:               %val = load double, double* %B_idx, align 8
63; CHECK-NEXT:               store double %val, double* %A_idx, align 8
64; CHECK-NEXT:         }
65