1; RUN: opt %loadPolly -S \
2; RUN: -polly-analyze-read-only-scalars=false -polly-codegen < %s | FileCheck %s
3
4; RUN: opt %loadPolly -S \
5; RUN: -polly-analyze-read-only-scalars=true -polly-codegen < %s | FileCheck %s
6;
7;    float f(float *A, int N) {
8;      float tmp = 0;
9;      for (int i = 0; i < N; i++)
10;        tmp += A[i];
11;      return tmp;
12;    }
13
14; CHECK-LABEL: polly.merge_new_and_old:
15; CHECK-NEXT:    %tmp.0.merge = phi float [ %tmp.0.final_reload, %polly.exiting ], [ %tmp.0, %bb8 ]
16; CHECK-NEXT:    br label %exit
17
18; CHECK-LABEL: polly.start:
19; CHECK-NEXT:    store float 0.000000e+00, float* %tmp.0.phiops
20; CHECK-NEXT:    sext
21
22; CHECK-LABEL: polly.exiting:
23; CHECK-NEXT:    %tmp.0.final_reload = load float, float* %tmp.0.s2a
24; CHECK-NEXT:    br label %polly.merge_new_and_old
25
26; CHECK-LABEL: polly.stmt.bb1{{[0-9]*}}:
27; CHECK-NEXT:    %tmp.0.phiops.reload[[R1:[0-9]*]] = load float, float* %tmp.0.phiops
28; CHECK-:        store float %tmp.0.phiops.reload[[R1]], float* %tmp.0.s2a
29
30; CHECK-LABEL: polly.stmt.bb4:
31; CHECK:         %tmp.0.s2a.reload[[R3:[0-9]*]] = load float, float* %tmp.0.s2a
32; CHECK:         %tmp[[R5:[0-9]*]]_p_scalar_ = load float, float* %scevgep, align 4, !alias.scope !0, !noalias !2
33; CHECK:         %p_tmp[[R4:[0-9]*]] = fadd float %tmp.0.s2a.reload[[R3]], %tmp[[R5]]_p_scalar_
34; CHECK:         store float %p_tmp[[R4]], float* %tmp.0.phiops
35
36; CHECK-LABEL: polly.stmt.bb1{{[0-9]*}}:
37; CHECK-NEXT:    %tmp.0.phiops.reload[[R2:[0-9]*]] = load float, float* %tmp.0.phiops
38; CHECK:         store float %tmp.0.phiops.reload[[R2]], float* %tmp.0.s2a
39
40target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
41
42define float @f(float* %A, i32 %N) {
43bb:
44  %tmp = sext i32 %N to i64
45  br label %bb1
46
47bb1:                                              ; preds = %bb4, %bb
48  %indvars.iv = phi i64 [ %indvars.iv.next, %bb4 ], [ 0, %bb ]
49  %tmp.0 = phi float [ 0.000000e+00, %bb ], [ %tmp7, %bb4 ]
50  %tmp2 = icmp slt i64 %indvars.iv, %tmp
51  br i1 %tmp2, label %bb3, label %bb8
52
53bb3:                                              ; preds = %bb1
54  br label %bb4
55
56bb4:                                              ; preds = %bb3
57  %tmp5 = getelementptr inbounds float, float* %A, i64 %indvars.iv
58  %tmp6 = load float, float* %tmp5, align 4
59  %tmp7 = fadd float %tmp.0, %tmp6
60  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
61  br label %bb1
62
63bb8:                                              ; preds = %bb1
64  br label %exit
65
66exit:
67  ret float %tmp.0
68}
69