• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %loadPolly -polly-codegen -S \
2; RUN: -polly-codegen-add-debug-printing \
3; RUN: -polly-ignore-aliasing < %s | FileCheck %s
4
5;    #define N 10
6;    void foo(float A[restrict], double B[restrict], char C[restrict],
7;             int D[restrict], long E[restrict]) {
8;      for (long i = 0; i < N; i++)
9;        A[i] += B[i] + C[i] + D[i] + E[i];
10;    }
11;
12;    int main() {
13;      float A[N];
14;      double B[N];
15;      char C[N];
16;      int D[N];
17;      long E[N];
18;
19;      for (long i = 0; i < N; i++) {
20;        __sync_synchronize();
21;        A[i] = B[i] = C[i] = D[i] = E[i] = 42;
22;      }
23;
24;      foo(A, B, C, D, E);
25;
26;      return A[8];
27;    }
28
29; CHECK: @0 = private unnamed_addr addrspace(4) constant [11 x i8] c"Load from \00"
30; CHECK: @1 = private unnamed_addr addrspace(4) constant [3 x i8] c": \00"
31; CHECK: @2 = private unnamed_addr addrspace(4) constant [2 x i8] c"\0A\00"
32; CHECK: @3 = private unnamed_addr constant [12 x i8] c"%s%ld%s%f%s\00"
33; CHECK: @4 = private unnamed_addr addrspace(4) constant [11 x i8] c"Load from \00"
34; CHECK: @5 = private unnamed_addr addrspace(4) constant [3 x i8] c": \00"
35; CHECK: @6 = private unnamed_addr addrspace(4) constant [2 x i8] c"\0A\00"
36; CHECK: @7 = private unnamed_addr constant [13 x i8] c"%s%ld%s%ld%s\00"
37; CHECK: @8 = private unnamed_addr addrspace(4) constant [11 x i8] c"Load from \00"
38; CHECK: @9 = private unnamed_addr addrspace(4) constant [3 x i8] c": \00"
39; CHECK: @10 = private unnamed_addr addrspace(4) constant [2 x i8] c"\0A\00"
40; CHECK: @11 = private unnamed_addr constant [13 x i8] c"%s%ld%s%ld%s\00"
41; CHECK: @12 = private unnamed_addr addrspace(4) constant [11 x i8] c"Load from \00"
42; CHECK: @13 = private unnamed_addr addrspace(4) constant [3 x i8] c": \00"
43; CHECK: @14 = private unnamed_addr addrspace(4) constant [2 x i8] c"\0A\00"
44; CHECK: @15 = private unnamed_addr constant [13 x i8] c"%s%ld%s%ld%s\00"
45; CHECK: @16 = private unnamed_addr addrspace(4) constant [11 x i8] c"Load from \00"
46; CHECK: @17 = private unnamed_addr addrspace(4) constant [3 x i8] c": \00"
47; CHECK: @18 = private unnamed_addr addrspace(4) constant [2 x i8] c"\0A\00"
48; CHECK: @19 = private unnamed_addr constant [12 x i8] c"%s%ld%s%f%s\00"
49; CHECK: @20 = private unnamed_addr addrspace(4) constant [11 x i8] c"Store to  \00"
50; CHECK: @21 = private unnamed_addr addrspace(4) constant [3 x i8] c": \00"
51; CHECK: @22 = private unnamed_addr addrspace(4) constant [2 x i8] c"\0A\00"
52; CHECK: @23 = private unnamed_addr constant [12 x i8] c"%s%ld%s%f%s\00"
53
54; CHECK: %0 = ptrtoint double* %scevgep to i64
55; CHECK: %1 = call i32 (...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @3, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([11 x i8], [11 x i8] addrspace(4)* @0, i32 0, i32 0), i64 %0, i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @1, i32 0, i32 0), double %tmp3_p_scalar_, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @2, i32 0, i32 0))
56; CHECK: %2 = call i32 @fflush(i8* null)
57; CHECK: %scevgep1 = getelementptr i8, i8* %C, i64 %polly.indvar
58; CHECK: %tmp5_p_scalar_ = load i8, i8* %scevgep1
59; CHECK: %3 = ptrtoint i8* %scevgep1 to i64
60; CHECK: %4 = sext i8 %tmp5_p_scalar_ to i64
61; CHECK: %5 = call i32 (...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @7, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([11 x i8], [11 x i8] addrspace(4)* @4, i32 0, i32 0), i64 %3, i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @5, i32 0, i32 0), i64 %4, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @6, i32 0, i32 0))
62; CHECK: %6 = call i32 @fflush(i8* null)
63; CHECK: %p_tmp6 = sitofp i8 %tmp5_p_scalar_ to double
64; CHECK: %p_tmp7 = fadd double %tmp3_p_scalar_, %p_tmp6
65; CHECK: %scevgep2 = getelementptr i32, i32* %D, i64 %polly.indvar
66; CHECK: %tmp9_p_scalar_ = load i32, i32* %scevgep2
67; CHECK: %7 = ptrtoint i32* %scevgep2 to i64
68; CHECK: %8 = sext i32 %tmp9_p_scalar_ to i64
69; CHECK: %9 = call i32 (...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @11, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([11 x i8], [11 x i8] addrspace(4)* @8, i32 0, i32 0), i64 %7, i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @9, i32 0, i32 0), i64 %8, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @10, i32 0, i32 0))
70; CHECK: %10 = call i32 @fflush(i8* null)
71; CHECK: %p_tmp10 = sitofp i32 %tmp9_p_scalar_ to double
72; CHECK: %p_tmp11 = fadd double %p_tmp7, %p_tmp10
73; CHECK: %scevgep3 = getelementptr i64, i64* %E, i64 %polly.indvar
74; CHECK: %tmp13_p_scalar_ = load i64, i64* %scevgep3
75; CHECK: %11 = ptrtoint i64* %scevgep3 to i64
76; CHECK: %12 = call i32 (...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @15, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([11 x i8], [11 x i8] addrspace(4)* @12, i32 0, i32 0), i64 %11, i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @13, i32 0, i32 0), i64 %tmp13_p_scalar_, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @14, i32 0, i32 0))
77; CHECK: %13 = call i32 @fflush(i8* null)
78; CHECK: %p_tmp14 = sitofp i64 %tmp13_p_scalar_ to double
79; CHECK: %p_tmp15 = fadd double %p_tmp11, %p_tmp14
80; CHECK: %scevgep4 = getelementptr float, float* %A, i64 %polly.indvar
81; CHECK: %tmp17_p_scalar_ = load float, float* %scevgep4
82; CHECK: %14 = ptrtoint float* %scevgep4 to i64
83; CHECK: %15 = fpext float %tmp17_p_scalar_ to double
84; CHECK: %16 = call i32 (...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @19, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([11 x i8], [11 x i8] addrspace(4)* @16, i32 0, i32 0), i64 %14, i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @17, i32 0, i32 0), double %15, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @18, i32 0, i32 0))
85; CHECK: %17 = call i32 @fflush(i8* null)
86; CHECK: %p_tmp18 = fpext float %tmp17_p_scalar_ to double
87; CHECK: %p_tmp19 = fadd double %p_tmp18, %p_tmp15
88; CHECK: %p_tmp20 = fptrunc double %p_tmp19 to float
89; CHECK: %18 = ptrtoint float* %scevgep4 to i64
90; CHECK: %19 = fpext float %p_tmp20 to double
91; CHECK: %20 = call i32 (...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @23, i32 0, i32 0), i8 addrspace(4)* getelementptr inbounds ([11 x i8], [11 x i8] addrspace(4)* @20, i32 0, i32 0), i64 %18, i8 addrspace(4)* getelementptr inbounds ([3 x i8], [3 x i8] addrspace(4)* @21, i32 0, i32 0), double %19, i8 addrspace(4)* getelementptr inbounds ([2 x i8], [2 x i8] addrspace(4)* @22, i32 0, i32 0))
92; CHECK: %21 = call i32 @fflush(i8* null)
93
94target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
95
96define void @foo(float* noalias %A, double* noalias %B, i8* noalias %C, i32* noalias %D, i64* noalias %E) {
97bb:
98  br label %bb1
99
100bb1:                                              ; preds = %bb21, %bb
101  %i.0 = phi i64 [ 0, %bb ], [ %tmp22, %bb21 ]
102  %exitcond = icmp ne i64 %i.0, 10
103  br i1 %exitcond, label %bb2, label %bb23
104
105bb2:                                              ; preds = %bb1
106  %tmp = getelementptr inbounds double, double* %B, i64 %i.0
107  %tmp3 = load double, double* %tmp, align 8
108  %tmp4 = getelementptr inbounds i8, i8* %C, i64 %i.0
109  %tmp5 = load i8, i8* %tmp4, align 1
110  %tmp6 = sitofp i8 %tmp5 to double
111  %tmp7 = fadd double %tmp3, %tmp6
112  %tmp8 = getelementptr inbounds i32, i32* %D, i64 %i.0
113  %tmp9 = load i32, i32* %tmp8, align 4
114  %tmp10 = sitofp i32 %tmp9 to double
115  %tmp11 = fadd double %tmp7, %tmp10
116  %tmp12 = getelementptr inbounds i64, i64* %E, i64 %i.0
117  %tmp13 = load i64, i64* %tmp12, align 8
118  %tmp14 = sitofp i64 %tmp13 to double
119  %tmp15 = fadd double %tmp11, %tmp14
120  %tmp16 = getelementptr inbounds float, float* %A, i64 %i.0
121  %tmp17 = load float, float* %tmp16, align 4
122  %tmp18 = fpext float %tmp17 to double
123  %tmp19 = fadd double %tmp18, %tmp15
124  %tmp20 = fptrunc double %tmp19 to float
125  store float %tmp20, float* %tmp16, align 4
126  br label %bb21
127
128bb21:                                             ; preds = %bb2
129  %tmp22 = add nsw i64 %i.0, 1
130  br label %bb1
131
132bb23:                                             ; preds = %bb1
133  ret void
134}
135
136define i32 @main() {
137bb:
138  %A = alloca [10 x float], align 16
139  %B = alloca [10 x double], align 16
140  %C = alloca [10 x i8], align 1
141  %D = alloca [10 x i32], align 16
142  %E = alloca [10 x i64], align 16
143  br label %bb1
144
145bb1:                                              ; preds = %bb7, %bb
146  %i.0 = phi i64 [ 0, %bb ], [ %tmp8, %bb7 ]
147  %exitcond = icmp ne i64 %i.0, 10
148  br i1 %exitcond, label %bb2, label %bb9
149
150bb2:                                              ; preds = %bb1
151  fence seq_cst
152  %tmp = getelementptr inbounds [10 x i64], [10 x i64]* %E, i64 0, i64 %i.0
153  store i64 42, i64* %tmp, align 8
154  %tmp3 = getelementptr inbounds [10 x i32], [10 x i32]* %D, i64 0, i64 %i.0
155  store i32 42, i32* %tmp3, align 4
156  %tmp4 = getelementptr inbounds [10 x i8], [10 x i8]* %C, i64 0, i64 %i.0
157  store i8 42, i8* %tmp4, align 1
158  %tmp5 = getelementptr inbounds [10 x double], [10 x double]* %B, i64 0, i64 %i.0
159  store double 4.200000e+01, double* %tmp5, align 8
160  %tmp6 = getelementptr inbounds [10 x float], [10 x float]* %A, i64 0, i64 %i.0
161  store float 4.200000e+01, float* %tmp6, align 4
162  br label %bb7
163
164bb7:                                              ; preds = %bb2
165  %tmp8 = add nsw i64 %i.0, 1
166  br label %bb1
167
168bb9:                                              ; preds = %bb1
169  %tmp10 = getelementptr inbounds [10 x float], [10 x float]* %A, i64 0, i64 0
170  %tmp11 = getelementptr inbounds [10 x double], [10 x double]* %B, i64 0, i64 0
171  %tmp12 = getelementptr inbounds [10 x i8], [10 x i8]* %C, i64 0, i64 0
172  %tmp13 = getelementptr inbounds [10 x i32], [10 x i32]* %D, i64 0, i64 0
173  %tmp14 = getelementptr inbounds [10 x i64], [10 x i64]* %E, i64 0, i64 0
174  call void @foo(float* %tmp10, double* %tmp11, i8* %tmp12, i32* %tmp13, i64* %tmp14)
175  %tmp15 = getelementptr inbounds [10 x float], [10 x float]* %A, i64 0, i64 8
176  %tmp16 = load float, float* %tmp15, align 16
177  %tmp17 = fptosi float %tmp16 to i32
178  ret i32 %tmp17
179}
180