1; RUN: opt %loadPolly -polly-delicm -polly-simplify -polly-parallel -polly-codegen -S < %s | FileCheck %s
2;
3; Test that parallel codegen handles scalars mapped to other arrays.
4; After mapping "store double %add10" references the array "MemRef2".
5; Its base pointer therefore needs to be made available in the subfunction.
6
7target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
8
9define void @reference_latest(float* nocapture readonly %data, i32 %n, i32 %m) {
10entry:
11  %0 = alloca double, i64 undef, align 16
12  %conv1 = sext i32 %m to i64
13  br label %while.body
14
15while.body:
16  %indvars.iv211 = phi i64 [ %conv1, %entry ], [ %indvars.iv.next212, %for.end ]
17  br label %for.body
18
19for.body:
20  %indvars.iv207 = phi i64 [ %indvars.iv211, %while.body ], [ %indvars.iv.next208, %for.body ]
21  %arrayidx7 = getelementptr inbounds float, float* %data, i64 0
22  %1 = load float, float* %arrayidx7, align 4
23  %add10 = fadd double undef, undef
24  %indvars.iv.next208 = add nsw i64 %indvars.iv207, 1
25  %lftr.wideiv = trunc i64 %indvars.iv.next208 to i32
26  %exitcond210 = icmp eq i32 %lftr.wideiv, %n
27  br i1 %exitcond210, label %for.end, label %for.body
28
29for.end:
30  %arrayidx12 = getelementptr inbounds double, double* %0, i64 %indvars.iv211
31  store double %add10, double* %arrayidx12, align 8
32  %indvars.iv.next212 = add nsw i64 %indvars.iv211, -1
33  %2 = trunc i64 %indvars.iv211 to i32
34  %tobool = icmp eq i32 %2, 0
35  br i1 %tobool, label %while.end, label %while.body
36
37while.end:
38  ret void
39}
40
41; CHECK-LABEL: define internal void @reference_latest_polly_subfn(i8* %polly.par.userContext)
42
43; CHECK:      %polly.access.polly.subfunc.arg. = getelementptr double, double* %polly.subfunc.arg., i64 %{{[0-9]+}}
44; CHECK-NEXT: store double %p_add{{[0-9]*}}, double* %polly.access.polly.subfunc.arg.
45