1; RUN: opt %loadPolly -polly-optree -analyze < %s | FileCheck %s -match-full-lines
2;
3; Forward an operand tree consisting of a speculatable instruction (%add)
4; and a load (%val).
5;
6; for (int j = 0; j < n; j += 1) {
7; bodyA:
8;   double val = B[j];
9;   double add = val + 42.0;
10;
11; bodyB:
12;   A[j] = add;
13; }
14;
15define void @func(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      %B_idx = getelementptr inbounds double, double* %B, i32 %j
26      %val = load double, double* %B_idx
27      %add = fadd double %val, 42.0
28      br label %bodyB
29
30    bodyB:
31      %A_idx = getelementptr inbounds double, double* %A, i32 %j
32      store double %add, double* %A_idx
33      br label %inc
34
35inc:
36  %j.inc = add nuw nsw i32 %j, 1
37  br label %for
38
39exit:
40  br label %return
41
42return:
43  ret void
44}
45
46
47; CHECK: Statistics {
48; CHECK:     Instructions copied: 1
49; CHECK:     Known loads forwarded: 1
50; CHECK:     Operand trees forwarded: 1
51; CHECK:     Statements with forwarded operand trees: 1
52; CHECK: }
53
54; CHECK:      After statements {
55; CHECK-NEXT:     Stmt_bodyA
56; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 0]
57; CHECK-NEXT:                 [n] -> { Stmt_bodyA[i0] -> MemRef_B[i0] };
58; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
59; CHECK-NEXT:                 [n] -> { Stmt_bodyA[i0] -> MemRef_add[] };
60; CHECK-NEXT:             Instructions {
61; CHECK-NEXT:                   %val = load double, double* %B_idx, align 8
62; CHECK-NEXT:                   %add = fadd double %val, 4.200000e+01
63; CHECK-NEXT:             }
64; CHECK-NEXT:     Stmt_bodyB
65; CHECK-NEXT:             ReadAccess :=       [Reduction Type: NONE] [Scalar: 0]
66; CHECK-NEXT:                 ;
67; CHECK-NEXT:            new: [n] -> { Stmt_bodyB[i0] -> MemRef_B[i0] };
68; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
69; CHECK-NEXT:                 [n] -> { Stmt_bodyB[i0] -> MemRef_A[i0] };
70; CHECK-NEXT:             Instructions {
71; CHECK-NEXT:                   %val = load double, double* %B_idx, align 8
72; CHECK-NEXT:                   %add = fadd double %val, 4.200000e+01
73; CHECK-NEXT:                   store double %add, double* %A_idx, align 8
74; CHECK-NEXT:             }
75; CHECK-NEXT: }
76