1; RUN: opt %loadPolly -polly-codegen -polly-invariant-load-hoisting=true -polly-parallel \
2; RUN: -polly-parallel-force -S < %s | FileCheck %s
3;
4; Test to verify that we hand down the preloaded A[0] to the OpenMP subfunction but
5; not B[0] as it is not needed
6;
7;    void f(float *A, float *B) {
8;      // Not parallel
9;      for (int i = 1; i < 1000; i++) {
10;        B[i] = B[i+1] + B[0];
11;        // Parallel
12;        for (int j = 1; j < 1000; j++)
13;          A[j] += A[0];
14;      }
15;    }
16;
17;                                           i    A[0]    A
18; CHECK: %polly.par.userContext = alloca { i64, float, float* }
19;
20; CHECK:  %polly.access.B.load =
21; CHECK:  %polly.subfn.storeaddr.polly.access.A.load = getelementptr inbounds
22; CHECK:  store float %polly.access.A.load, float* %polly.subfn.storeaddr.polly.access.A.load
23; CHECK-NOT:  store float %polly.access.B.load, float* %polly.subfn.storeaddr.polly.access.B.load
24;
25target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
26
27define void @f(float* %A, float* %B) {
28entry:
29  br label %for.cond
30
31for.cond:                                         ; preds = %for.inc.9, %entry
32  %indvars.iv1 = phi i64 [ %indvars.iv.next2, %for.inc.9 ], [ 1, %entry ]
33  %exitcond3 = icmp ne i64 %indvars.iv1, 1000
34  br i1 %exitcond3, label %for.body, label %for.end.11
35
36for.body:                                         ; preds = %for.cond
37  %tmp = load float, float* %B, align 4
38  %arrayidx1 = getelementptr inbounds float, float* %B, i64 %indvars.iv1
39  %iv.add = add nsw i64 %indvars.iv1, 1
40  %arrayidx2 = getelementptr inbounds float, float* %B, i64 %iv.add
41  %tmp4 = load float, float* %arrayidx2, align 4
42  %add = fadd float %tmp4, %tmp
43  store float %add, float* %arrayidx1, align 4
44  br label %for.cond.2
45
46for.cond.2:                                       ; preds = %for.inc, %for.body
47  %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 1, %for.body ]
48  %exitcond = icmp ne i64 %indvars.iv, 1000
49  br i1 %exitcond, label %for.body.4, label %for.end
50
51for.body.4:                                       ; preds = %for.cond.2
52  %tmp5 = load float, float* %A, align 4
53  %arrayidx7 = getelementptr inbounds float, float* %A, i64 %indvars.iv
54  %tmp6 = load float, float* %arrayidx7, align 4
55  %add8 = fadd float %tmp6, %tmp5
56  store float %add8, float* %arrayidx7, align 4
57  br label %for.inc
58
59for.inc:                                          ; preds = %for.body.4
60  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
61  br label %for.cond.2
62
63for.end:                                          ; preds = %for.cond.2
64  br label %for.inc.9
65
66for.inc.9:                                        ; preds = %for.end
67  %indvars.iv.next2 = add nuw nsw i64 %indvars.iv1, 1
68  br label %for.cond
69
70for.end.11:                                       ; preds = %for.cond
71  ret void
72}
73