1; RUN: opt %loadPolly -polly-detect -stats -disable-output < %s 2>&1 | FileCheck %s 2 3; REQUIRES: asserts 4 5; CHECK-DAG: 4 polly-detect - Maximal number of loops in scops (profitable scops only) 6; CHECK-DAG: 4 polly-detect - Maximal number of loops in scops 7; CHECK-DAG: 11 polly-detect - Number of loops in scops (profitable scops only) 8; CHECK-DAG: 11 polly-detect - Number of loops in scops 9; CHECK-DAG: 11 polly-detect - Number of total loops 10; CHECK-DAG: 6 polly-detect - Number of scops (profitable scops only) 11; CHECK-DAG: 1 polly-detect - Number of scops with maximal loop depth 4 (profitable scops only) 12; CHECK-DAG: 2 polly-detect - Number of scops with maximal loop depth 1 (profitable scops only) 13; CHECK-DAG: 1 polly-detect - Number of scops with maximal loop depth 3 (profitable scops only) 14; CHECK-DAG: 1 polly-detect - Number of scops with maximal loop depth 2 (profitable scops only) 15; CHECK-DAG: 1 polly-detect - Number of scops with maximal loop depth 0 (profitable scops only) 16; CHECK-DAG: 6 polly-detect - Number of scops 17; CHECK-DAG: 1 polly-detect - Number of scops with maximal loop depth 4 18; CHECK-DAG: 2 polly-detect - Number of scops with maximal loop depth 1 19; CHECK-DAG: 1 polly-detect - Number of scops with maximal loop depth 3 20; CHECK-DAG: 1 polly-detect - Number of scops with maximal loop depth 2 21; CHECK-DAG: 1 polly-detect - Number of scops with maximal loop depth 0 22 23; void foo_0d(float *A) { 24; if (true) 25; A[0] += i; 26; } 27; 28; void foo_1d(float *A) { 29; for (long i = 0; i < 1024; i++) 30; A[i] += i; 31; } 32; 33; void foo_2d(float *A) { 34; for (long i = 0; i < 1024; i++) 35; for (long j = 0; j < 1024; j++) 36; A[i + j] += i + j; 37; } 38; 39; void foo_3d(float *A) { 40; for (long i = 0; i < 1024; i++) 41; for (long j = 0; j < 1024; j++) 42; for (long k = 0; k < 1024; k++) 43; A[i + j + k] += i + j + k; 44; } 45; 46; void foo_4d(float *A) { 47; for (long i = 0; i < 1024; i++) 48; for (long j = 0; j < 1024; j++) 49; for (long k = 0; k < 1024; k++) 50; for (long l = 0; l < 1024; l++) 51; A[i + j + k + l] += i + j + k + l; 52; } 53; 54; void foo_zero_iterations(float *S) { 55; for (long i = 0; i < 0; i++) 56; A[i] += i; 57; } 58target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 59 60define void @foo_0d(float* %A) { 61bb: 62 br label %bb1 63 64bb1: 65 br i1 true, label %exit, label %block 66 67block: 68 store float 42.0, float* %A 69 br label %exit 70 71exit: 72 ret void 73} 74 75define void @foo_1d(float* %A) { 76bb: 77 br label %bb1 78 79bb1: ; preds = %bb6, %bb 80 %i.0 = phi i64 [ 0, %bb ], [ %tmp7, %bb6 ] 81 %exitcond = icmp ne i64 %i.0, 1024 82 br i1 %exitcond, label %bb2, label %bb8 83 84bb2: ; preds = %bb1 85 %tmp = sitofp i64 %i.0 to float 86 %tmp3 = getelementptr inbounds float, float* %A, i64 %i.0 87 %tmp4 = load float, float* %tmp3, align 4 88 %tmp5 = fadd float %tmp4, %tmp 89 store float %tmp5, float* %tmp3, align 4 90 br label %bb6 91 92bb6: ; preds = %bb2 93 %tmp7 = add nuw nsw i64 %i.0, 1 94 br label %bb1 95 96bb8: ; preds = %bb1 97 ret void 98} 99 100define void @foo_2d(float* %A) { 101bb: 102 br label %bb2 103 104bb2: ; preds = %bb14, %bb 105 %i.0 = phi i64 [ 0, %bb ], [ %tmp15, %bb14 ] 106 %exitcond1 = icmp ne i64 %i.0, 1024 107 br i1 %exitcond1, label %bb3, label %bb16 108 109bb3: ; preds = %bb2 110 br label %bb4 111 112bb4: ; preds = %bb11, %bb3 113 %j.0 = phi i64 [ 0, %bb3 ], [ %tmp12, %bb11 ] 114 %exitcond = icmp ne i64 %j.0, 1024 115 br i1 %exitcond, label %bb5, label %bb13 116 117bb5: ; preds = %bb4 118 %tmp = add nuw nsw i64 %i.0, %j.0 119 %tmp6 = sitofp i64 %tmp to float 120 %tmp7 = add nuw nsw i64 %i.0, %j.0 121 %tmp8 = getelementptr inbounds float, float* %A, i64 %tmp7 122 %tmp9 = load float, float* %tmp8, align 4 123 %tmp10 = fadd float %tmp9, %tmp6 124 store float %tmp10, float* %tmp8, align 4 125 br label %bb11 126 127bb11: ; preds = %bb5 128 %tmp12 = add nuw nsw i64 %j.0, 1 129 br label %bb4 130 131bb13: ; preds = %bb4 132 br label %bb14 133 134bb14: ; preds = %bb13 135 %tmp15 = add nuw nsw i64 %i.0, 1 136 br label %bb2 137 138bb16: ; preds = %bb2 139 ret void 140} 141 142define void @foo_3d(float* %A) { 143bb: 144 br label %bb3 145 146bb3: ; preds = %bb22, %bb 147 %i.0 = phi i64 [ 0, %bb ], [ %tmp23, %bb22 ] 148 %exitcond2 = icmp ne i64 %i.0, 1024 149 br i1 %exitcond2, label %bb4, label %bb24 150 151bb4: ; preds = %bb3 152 br label %bb5 153 154bb5: ; preds = %bb19, %bb4 155 %j.0 = phi i64 [ 0, %bb4 ], [ %tmp20, %bb19 ] 156 %exitcond1 = icmp ne i64 %j.0, 1024 157 br i1 %exitcond1, label %bb6, label %bb21 158 159bb6: ; preds = %bb5 160 br label %bb7 161 162bb7: ; preds = %bb16, %bb6 163 %k.0 = phi i64 [ 0, %bb6 ], [ %tmp17, %bb16 ] 164 %exitcond = icmp ne i64 %k.0, 1024 165 br i1 %exitcond, label %bb8, label %bb18 166 167bb8: ; preds = %bb7 168 %tmp = add nuw nsw i64 %i.0, %j.0 169 %tmp9 = add nuw nsw i64 %tmp, %k.0 170 %tmp10 = sitofp i64 %tmp9 to float 171 %tmp11 = add nuw nsw i64 %i.0, %j.0 172 %tmp12 = add nuw nsw i64 %tmp11, %k.0 173 %tmp13 = getelementptr inbounds float, float* %A, i64 %tmp12 174 %tmp14 = load float, float* %tmp13, align 4 175 %tmp15 = fadd float %tmp14, %tmp10 176 store float %tmp15, float* %tmp13, align 4 177 br label %bb16 178 179bb16: ; preds = %bb8 180 %tmp17 = add nuw nsw i64 %k.0, 1 181 br label %bb7 182 183bb18: ; preds = %bb7 184 br label %bb19 185 186bb19: ; preds = %bb18 187 %tmp20 = add nuw nsw i64 %j.0, 1 188 br label %bb5 189 190bb21: ; preds = %bb5 191 br label %bb22 192 193bb22: ; preds = %bb21 194 %tmp23 = add nuw nsw i64 %i.0, 1 195 br label %bb3 196 197bb24: ; preds = %bb3 198 ret void 199} 200 201define void @foo_4d(float* %A) { 202bb: 203 br label %bb4 204 205bb4: ; preds = %bb30, %bb 206 %i.0 = phi i64 [ 0, %bb ], [ %tmp31, %bb30 ] 207 %exitcond3 = icmp ne i64 %i.0, 1024 208 br i1 %exitcond3, label %bb5, label %bb32 209 210bb5: ; preds = %bb4 211 br label %bb6 212 213bb6: ; preds = %bb27, %bb5 214 %j.0 = phi i64 [ 0, %bb5 ], [ %tmp28, %bb27 ] 215 %exitcond2 = icmp ne i64 %j.0, 1024 216 br i1 %exitcond2, label %bb7, label %bb29 217 218bb7: ; preds = %bb6 219 br label %bb8 220 221bb8: ; preds = %bb24, %bb7 222 %k.0 = phi i64 [ 0, %bb7 ], [ %tmp25, %bb24 ] 223 %exitcond1 = icmp ne i64 %k.0, 1024 224 br i1 %exitcond1, label %bb9, label %bb26 225 226bb9: ; preds = %bb8 227 br label %bb10 228 229bb10: ; preds = %bb21, %bb9 230 %l.0 = phi i64 [ 0, %bb9 ], [ %tmp22, %bb21 ] 231 %exitcond = icmp ne i64 %l.0, 1024 232 br i1 %exitcond, label %bb11, label %bb23 233 234bb11: ; preds = %bb10 235 %tmp = add nuw nsw i64 %i.0, %j.0 236 %tmp12 = add nuw nsw i64 %tmp, %k.0 237 %tmp13 = add nuw nsw i64 %tmp12, %l.0 238 %tmp14 = sitofp i64 %tmp13 to float 239 %tmp15 = add nuw nsw i64 %i.0, %j.0 240 %tmp16 = add nuw nsw i64 %tmp15, %k.0 241 %tmp17 = add nuw nsw i64 %tmp16, %l.0 242 %tmp18 = getelementptr inbounds float, float* %A, i64 %tmp17 243 %tmp19 = load float, float* %tmp18, align 4 244 %tmp20 = fadd float %tmp19, %tmp14 245 store float %tmp20, float* %tmp18, align 4 246 br label %bb21 247 248bb21: ; preds = %bb11 249 %tmp22 = add nuw nsw i64 %l.0, 1 250 br label %bb10 251 252bb23: ; preds = %bb10 253 br label %bb24 254 255bb24: ; preds = %bb23 256 %tmp25 = add nuw nsw i64 %k.0, 1 257 br label %bb8 258 259bb26: ; preds = %bb8 260 br label %bb27 261 262bb27: ; preds = %bb26 263 %tmp28 = add nuw nsw i64 %j.0, 1 264 br label %bb6 265 266bb29: ; preds = %bb6 267 br label %bb30 268 269bb30: ; preds = %bb29 270 %tmp31 = add nuw nsw i64 %i.0, 1 271 br label %bb4 272 273bb32: ; preds = %bb4 274 ret void 275} 276 277define void @foo_zero_iterations(float* %A) { 278bb: 279 br label %bb1 280 281bb1: ; preds = %bb6, %bb 282 %i.0 = phi i64 [ 0, %bb ], [ %tmp7, %bb6 ] 283 %exitcond = icmp ne i64 %i.0, 0 284 br i1 %exitcond, label %bb2, label %bb8 285 286bb2: ; preds = %bb1 287 %tmp = sitofp i64 %i.0 to float 288 %tmp3 = getelementptr inbounds float, float* %A, i64 %i.0 289 %tmp4 = load float, float* %tmp3, align 4 290 %tmp5 = fadd float %tmp4, %tmp 291 store float %tmp5, float* %tmp3, align 4 292 br label %bb6 293 294bb6: ; preds = %bb2 295 %tmp7 = add nuw nsw i64 %i.0, 1 296 br label %bb1 297 298bb8: ; preds = %bb1 299 ret void 300} 301