xref: /llvm-project/polly/test/ScopInfo/read-only-scalar-used-in-phi-2.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly '-passes=print<polly-function-scops>' -disable-output < %s 2>&1 | FileCheck %s
2;
3;    float foo(float sum, float A[]) {
4;
5;      for (long i = 0; i < 100; i++)
6;        sum += A[i];
7;
8;      return sum;
9;    }
10
11; Verify that we do not model the read from %sum. Reads that only happen in
12; case control flow reaches the PHI node from outside the SCoP are handled
13; implicitly during code generation.
14
15; CHECK: Stmt_bb1[i0] -> MemRef_phisum__ph
16; CHECK-NOT: Stmt_bb1[i0] -> MemRef_sum[]
17
18target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
19
20define float @foo(float %sum, ptr %A) {
21bb:
22  br label %bb1
23
24bb1:
25  %i = phi i64 [ 0, %bb ], [ %i.next, %bb1 ]
26  %phisum = phi float [ %sum, %bb ], [ %tmp5, %bb1 ]
27  %tmp = getelementptr inbounds float, ptr %A, i64 %i
28  %tmp4 = load float, ptr %tmp, align 4
29  %tmp5 = fadd float %phisum, %tmp4
30  %i.next = add nuw nsw i64 %i, 1
31  %exitcond = icmp ne i64 %i, 100
32  br i1 %exitcond, label %bb1, label %bb7
33
34bb7:
35  ret float %phisum
36}
37