[ForwardOpTree] Support synthesizable values.
[polly-mirror.git] / test / ForwardOpTree / forward_synthesizable_useinloop.ll
blobc43787d8a582c15832db075a0b88266b737f1482
1 ; RUN: opt %loadPolly -polly-optree -analyze < %s | FileCheck %s -match-full-lines
3 ; Synthesizable values defined outside of a loop can be used
4 ; inside the loop.
6 ; for (int j = 0; j < n; j += 1) {
7 ; bodyA:
8 ;   double val = j;
10 ;   for (int i = 0; i < n; i += 1) {
11 ; bodyB:
12 ;     A[0] = val;
13 ;   }
14 ; }
16 define void @func(i32 %n, double* noalias nonnull %A) {
17 entry:
18   br label %for
20 for:
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
25     bodyA:
26       %val = sitofp i32 %j to double
27       br label %inner.for
30     inner.for:
31       %i = phi i32 [0, %bodyA], [%i.inc, %inner.inc]
32       %i.cmp = icmp slt i32 %i, %n
33       br i1 %i.cmp, label %bodyB, label %inner.exit
36         bodyB:
37           store double %val, double* %A
38           br label %inner.inc
41     inner.inc:
42       %i.inc = add nuw nsw i32 %i, 1
43       br label %inner.for
45     inner.exit:
46       br label %inc
48 inc:
49   %j.inc = add nuw nsw i32 %j, 1
50   br label %for
52 exit:
53   br label %return
55 return:
56   ret void
60 ; CHECK: Statistics {
61 ; CHECK:     Instructions copied: 1
62 ; CHECK:     Operand trees forwarded: 1
63 ; CHECK:     Statements with forwarded operand trees: 1
64 ; CHECK: }
66 ; CHECK:      After statements {
67 ; CHECK-NEXT:     Stmt_bodyA
68 ; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 1]
69 ; CHECK-NEXT:                 [n] -> { Stmt_bodyA[i0] -> MemRef_val[] };
70 ; CHECK-NEXT:             Instructions {
71 ; CHECK-NEXT:                   %val = sitofp i32 %j to double
72 ; CHECK-NEXT:             }
73 ; CHECK-NEXT:     Stmt_bodyB
74 ; CHECK-NEXT:             MustWriteAccess :=  [Reduction Type: NONE] [Scalar: 0]
75 ; CHECK-NEXT:                 [n] -> { Stmt_bodyB[i0, i1] -> MemRef_A[0] };
76 ; CHECK-NEXT:             Instructions {
77 ; CHECK-NEXT:                   %val = sitofp i32 %j to double
78 ; CHECK-NEXT:                   store double %val, double* %A
79 ; CHECK-NEXT:             }
80 ; CHECK-NEXT: }