1 ; RUN: opt %loadPolly -polly-codegen -S \
2 ; RUN: -polly-codegen-add-debug-printing \
3 ; RUN: -polly-ignore-aliasing < %s | FileCheck %s
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];
19 ; for (long i = 0; i < N; i++) {
20 ; __sync_synchronize();
21 ; A[i] = B[i] = C[i] = D[i] = E[i] = 42;
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"
54 ; CHECK: %0 = shl nuw nsw i64 %polly.indvar, 3
55 ; CHECK: %scevgep = getelementptr i8, ptr %B, i64 %0
56 ; CHECK: %tmp3_p_scalar_ = load double, ptr %scevgep, align 8, !alias.scope !0, !noalias !3
57 ; CHECK: %1 = ptrtoint ptr %scevgep to i64
58 ; CHECK: %2 = call i32 (...) @printf(ptr @3, ptr addrspace(4) @0, i64 %1, ptr addrspace(4) @1, double %tmp3_p_scalar_, ptr addrspace(4) @2)
59 ; CHECK: %3 = call i32 @fflush(ptr null)
60 ; CHECK: %scevgep1 = getelementptr i8, ptr %C, i64 %polly.indvar
61 ; CHECK: %tmp5_p_scalar_ = load i8, ptr %scevgep1, align 1, !alias.scope !8, !noalias !9
62 ; CHECK: %4 = ptrtoint ptr %scevgep1 to i64
63 ; CHECK: %5 = sext i8 %tmp5_p_scalar_ to i64
64 ; CHECK: %6 = call i32 (...) @printf(ptr @7, ptr addrspace(4) @4, i64 %4, ptr addrspace(4) @5, i64 %5, ptr addrspace(4) @6)
65 ; CHECK: %7 = call i32 @fflush(ptr null)
66 ; CHECK: %p_tmp6 = sitofp i8 %tmp5_p_scalar_ to double
67 ; CHECK: %p_tmp7 = fadd double %tmp3_p_scalar_, %p_tmp6
68 ; CHECK: %8 = shl nuw nsw i64 %polly.indvar, 2
69 ; CHECK: %scevgep2 = getelementptr i8, ptr %D, i64 %8
70 ; CHECK: %tmp9_p_scalar_ = load i32, ptr %scevgep2, align 4, !alias.scope !10, !noalias !11
71 ; CHECK: %9 = ptrtoint ptr %scevgep2 to i64
72 ; CHECK: %10 = sext i32 %tmp9_p_scalar_ to i64
73 ; CHECK: %11 = call i32 (...) @printf(ptr @11, ptr addrspace(4) @8, i64 %9, ptr addrspace(4) @9, i64 %10, ptr addrspace(4) @10)
74 ; CHECK: %12 = call i32 @fflush(ptr null)
75 ; CHECK: %p_tmp10 = sitofp i32 %tmp9_p_scalar_ to double
76 ; CHECK: %p_tmp11 = fadd double %p_tmp7, %p_tmp10
77 ; CHECK: %13 = shl nuw nsw i64 %polly.indvar, 3
78 ; CHECK: %scevgep3 = getelementptr i8, ptr %E, i64 %13
79 ; CHECK: %tmp13_p_scalar_ = load i64, ptr %scevgep3, align 8, !alias.scope !12, !noalias !13
80 ; CHECK: %14 = ptrtoint ptr %scevgep3 to i64
81 ; CHECK: %15 = call i32 (...) @printf(ptr @15, ptr addrspace(4) @12, i64 %14, ptr addrspace(4) @13, i64 %tmp13_p_scalar_, ptr addrspace(4) @14)
82 ; CHECK: %16 = call i32 @fflush(ptr null)
83 ; CHECK: %p_tmp14 = sitofp i64 %tmp13_p_scalar_ to double
84 ; CHECK: %p_tmp15 = fadd double %p_tmp11, %p_tmp14
85 ; CHECK: %17 = shl nuw nsw i64 %polly.indvar, 2
86 ; CHECK: %scevgep4 = getelementptr i8, ptr %A, i64 %17
87 ; CHECK: %tmp17_p_scalar_ = load float, ptr %scevgep4, align 4, !alias.scope !14, !noalias !15
88 ; CHECK: %18 = ptrtoint ptr %scevgep4 to i64
89 ; CHECK: %19 = fpext float %tmp17_p_scalar_ to double
90 ; CHECK: %20 = call i32 (...) @printf(ptr @19, ptr addrspace(4) @16, i64 %18, ptr addrspace(4) @17, double %19, ptr addrspace(4) @18)
91 ; CHECK: %21 = call i32 @fflush(ptr null)
92 ; CHECK: %p_tmp18 = fpext float %tmp17_p_scalar_ to double
93 ; CHECK: %p_tmp19 = fadd double %p_tmp18, %p_tmp15
94 ; CHECK: %p_tmp20 = fptrunc double %p_tmp19 to float
95 ; CHECK: %22 = ptrtoint ptr %scevgep4 to i64
96 ; CHECK: %23 = fpext float %p_tmp20 to double
97 ; CHECK: %24 = call i32 (...) @printf(ptr @23, ptr addrspace(4) @20, i64 %22, ptr addrspace(4) @21, double %23, ptr addrspace(4) @22)
98 ; CHECK: %25 = call i32 @fflush(ptr null)
100 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
102 define void @foo(ptr noalias %A, ptr noalias %B, ptr noalias %C, ptr noalias %D, ptr noalias %E) {
106 bb1: ; preds = %bb21, %bb
107 %i.0 = phi i64 [ 0, %bb ], [ %tmp22, %bb21 ]
108 %exitcond = icmp ne i64 %i.0, 10
109 br i1 %exitcond, label %bb2, label %bb23
112 %tmp = getelementptr inbounds double, ptr %B, i64 %i.0
113 %tmp3 = load double, ptr %tmp, align 8
114 %tmp4 = getelementptr inbounds i8, ptr %C, i64 %i.0
115 %tmp5 = load i8, ptr %tmp4, align 1
116 %tmp6 = sitofp i8 %tmp5 to double
117 %tmp7 = fadd double %tmp3, %tmp6
118 %tmp8 = getelementptr inbounds i32, ptr %D, i64 %i.0
119 %tmp9 = load i32, ptr %tmp8, align 4
120 %tmp10 = sitofp i32 %tmp9 to double
121 %tmp11 = fadd double %tmp7, %tmp10
122 %tmp12 = getelementptr inbounds i64, ptr %E, i64 %i.0
123 %tmp13 = load i64, ptr %tmp12, align 8
124 %tmp14 = sitofp i64 %tmp13 to double
125 %tmp15 = fadd double %tmp11, %tmp14
126 %tmp16 = getelementptr inbounds float, ptr %A, i64 %i.0
127 %tmp17 = load float, ptr %tmp16, align 4
128 %tmp18 = fpext float %tmp17 to double
129 %tmp19 = fadd double %tmp18, %tmp15
130 %tmp20 = fptrunc double %tmp19 to float
131 store float %tmp20, ptr %tmp16, align 4
135 %tmp22 = add nsw i64 %i.0, 1
144 %A = alloca [10 x float], align 16
145 %B = alloca [10 x double], align 16
146 %C = alloca [10 x i8], align 1
147 %D = alloca [10 x i32], align 16
148 %E = alloca [10 x i64], align 16
151 bb1: ; preds = %bb7, %bb
152 %i.0 = phi i64 [ 0, %bb ], [ %tmp8, %bb7 ]
153 %exitcond = icmp ne i64 %i.0, 10
154 br i1 %exitcond, label %bb2, label %bb9
158 %tmp = getelementptr inbounds [10 x i64], ptr %E, i64 0, i64 %i.0
159 store i64 42, ptr %tmp, align 8
160 %tmp3 = getelementptr inbounds [10 x i32], ptr %D, i64 0, i64 %i.0
161 store i32 42, ptr %tmp3, align 4
162 %tmp4 = getelementptr inbounds [10 x i8], ptr %C, i64 0, i64 %i.0
163 store i8 42, ptr %tmp4, align 1
164 %tmp5 = getelementptr inbounds [10 x double], ptr %B, i64 0, i64 %i.0
165 store double 4.200000e+01, ptr %tmp5, align 8
166 %tmp6 = getelementptr inbounds [10 x float], ptr %A, i64 0, i64 %i.0
167 store float 4.200000e+01, ptr %tmp6, align 4
171 %tmp8 = add nsw i64 %i.0, 1
175 %tmp10 = getelementptr inbounds [10 x float], ptr %A, i64 0, i64 0
176 %tmp11 = getelementptr inbounds [10 x double], ptr %B, i64 0, i64 0
177 %tmp12 = getelementptr inbounds [10 x i8], ptr %C, i64 0, i64 0
178 %tmp13 = getelementptr inbounds [10 x i32], ptr %D, i64 0, i64 0
179 %tmp14 = getelementptr inbounds [10 x i64], ptr %E, i64 0, i64 0
180 call void @foo(ptr %tmp10, ptr %tmp11, ptr %tmp12, ptr %tmp13, ptr %tmp14)
181 %tmp15 = getelementptr inbounds [10 x float], ptr %A, i64 0, i64 8
182 %tmp16 = load float, ptr %tmp15, align 16
183 %tmp17 = fptosi float %tmp16 to i32