1 ; RUN: opt < %s -S -indvars -verify-scev 2 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" 3 target triple = "x86_64-apple-macosx10.8.0" 4 5 define void @test1() nounwind uwtable ssp { 6 entry: 7 br i1 undef, label %for.end, label %for.body 8 9 for.body: ; preds = %for.body, %entry 10 br i1 false, label %for.end, label %for.body 11 12 for.end: ; preds = %for.body, %entry 13 br i1 undef, label %for.end11, label %for.body3 14 15 for.body3: ; preds = %for.end 16 unreachable 17 18 for.end11: ; preds = %for.end 19 br i1 undef, label %while.body, label %while.end 20 21 while.body: ; preds = %for.end11 22 unreachable 23 24 while.end: ; preds = %for.end11 25 br i1 undef, label %if.end115, label %for.cond109 26 27 for.cond109: ; preds = %while.end 28 unreachable 29 30 if.end115: ; preds = %while.end 31 br i1 undef, label %while.body119.lr.ph.lr.ph, label %for.cond612 32 33 while.body119.lr.ph.lr.ph: ; preds = %if.end115 34 br i1 undef, label %for.cond612, label %if.end123.us 35 36 if.end123.us: ; preds = %while.body119.lr.ph.lr.ph 37 br label %for.cond132.us 38 39 for.cond132.us: ; preds = %for.cond132.us, %if.end123.us 40 br i1 undef, label %if.then136.us, label %for.cond132.us 41 42 if.then136.us: ; preds = %for.cond132.us 43 br i1 undef, label %while.end220, label %while.body211 44 45 while.body211: ; preds = %while.body211, %if.then136.us 46 br i1 undef, label %while.end220, label %while.body211 47 48 while.end220: ; preds = %while.body211, %if.then136.us 49 br label %for.cond246.outer 50 51 for.cond246.outer: ; preds = %for.inc558, %for.cond394.preheader, %if.then274, %for.cond404.preheader, %while.end220 52 br label %for.cond246 53 54 for.cond246: ; preds = %for.cond372.loopexit, %for.cond246.outer 55 br i1 undef, label %for.end562, label %if.end250 56 57 if.end250: ; preds = %for.cond246 58 br i1 undef, label %if.end256, label %for.end562 59 60 if.end256: ; preds = %if.end250 61 %cmp272 = icmp eq i32 undef, undef 62 br i1 %cmp272, label %if.then274, label %for.cond404.preheader 63 64 for.cond404.preheader: ; preds = %if.end256 65 br i1 undef, label %for.cond246.outer, label %for.body409.lr.ph 66 67 for.body409.lr.ph: ; preds = %for.cond404.preheader 68 br label %for.body409 69 70 if.then274: ; preds = %if.end256 71 br i1 undef, label %for.cond246.outer, label %if.end309 72 73 if.end309: ; preds = %if.then274 74 br i1 undef, label %for.cond372.loopexit, label %for.body361 75 76 for.body361: ; preds = %for.body361, %if.end309 77 br i1 undef, label %for.cond372.loopexit, label %for.body361 78 79 for.cond372.loopexit: ; preds = %for.body361, %if.end309 80 br i1 undef, label %for.cond394.preheader, label %for.cond246 81 82 for.cond394.preheader: ; preds = %for.cond372.loopexit 83 br i1 undef, label %for.cond246.outer, label %for.body397 84 85 for.body397: ; preds = %for.cond394.preheader 86 unreachable 87 88 for.body409: ; preds = %for.inc558, %for.body409.lr.ph 89 %k.029 = phi i32 [ 1, %for.body409.lr.ph ], [ %inc559, %for.inc558 ] 90 br i1 undef, label %if.then412, label %if.else433 91 92 if.then412: ; preds = %for.body409 93 br label %if.end440 94 95 if.else433: ; preds = %for.body409 96 br label %if.end440 97 98 if.end440: ; preds = %if.else433, %if.then412 99 br i1 undef, label %for.inc558, label %if.end461 100 101 if.end461: ; preds = %if.end440 102 br i1 undef, label %for.cond528.loopexit, label %for.body517 103 104 for.body517: ; preds = %for.body517, %if.end461 105 br i1 undef, label %for.cond528.loopexit, label %for.body517 106 107 for.cond528.loopexit: ; preds = %for.body517, %if.end461 108 br label %for.inc558 109 110 for.inc558: ; preds = %for.cond528.loopexit, %if.end440 111 %inc559 = add nsw i32 %k.029, 1 112 %cmp407 = icmp sgt i32 %inc559, undef 113 br i1 %cmp407, label %for.cond246.outer, label %for.body409 114 115 for.end562: ; preds = %if.end250, %for.cond246 116 unreachable 117 118 for.cond612: ; preds = %while.body119.lr.ph.lr.ph, %if.end115 119 unreachable 120 } 121 122 define void @test2() nounwind uwtable ssp { 123 entry: 124 br i1 undef, label %for.end, label %for.body 125 126 for.body: ; preds = %for.body, %entry 127 br i1 undef, label %for.end, label %for.body 128 129 for.end: ; preds = %for.body, %entry 130 br i1 undef, label %for.end11, label %for.body3 131 132 for.body3: ; preds = %for.end 133 unreachable 134 135 for.end11: ; preds = %for.end 136 br i1 undef, label %while.body, label %while.end 137 138 while.body: ; preds = %for.end11 139 unreachable 140 141 while.end: ; preds = %for.end11 142 br i1 undef, label %if.end115, label %for.cond109 143 144 for.cond109: ; preds = %while.end 145 unreachable 146 147 if.end115: ; preds = %while.end 148 br i1 undef, label %while.body119.lr.ph.lr.ph, label %for.cond612 149 150 while.body119.lr.ph.lr.ph: ; preds = %if.end115 151 br i1 undef, label %for.cond612, label %if.end123.us 152 153 if.end123.us: ; preds = %while.body119.lr.ph.lr.ph 154 br label %for.cond132.us 155 156 for.cond132.us: ; preds = %for.cond132.us, %if.end123.us 157 br i1 undef, label %if.then136.us, label %for.cond132.us 158 159 if.then136.us: ; preds = %for.cond132.us 160 br i1 undef, label %while.end220, label %while.body211 161 162 while.body211: ; preds = %while.body211, %if.then136.us 163 br i1 undef, label %while.end220, label %while.body211 164 165 while.end220: ; preds = %while.body211, %if.then136.us 166 br label %for.cond246.outer 167 168 for.cond246.outer: ; preds = %for.inc558, %for.cond394.preheader, %if.then274, %for.cond404.preheader, %while.end220 169 br label %for.cond246 170 171 for.cond246: ; preds = %for.cond372.loopexit, %for.cond246.outer 172 br i1 undef, label %for.end562, label %if.end250 173 174 if.end250: ; preds = %for.cond246 175 br i1 undef, label %if.end256, label %for.end562 176 177 if.end256: ; preds = %if.end250 178 %0 = load i32, i32* undef, align 4 179 br i1 undef, label %if.then274, label %for.cond404.preheader 180 181 for.cond404.preheader: ; preds = %if.end256 182 %add406 = add i32 0, %0 183 br i1 undef, label %for.cond246.outer, label %for.body409.lr.ph 184 185 for.body409.lr.ph: ; preds = %for.cond404.preheader 186 br label %for.body409 187 188 if.then274: ; preds = %if.end256 189 br i1 undef, label %for.cond246.outer, label %if.end309 190 191 if.end309: ; preds = %if.then274 192 br i1 undef, label %for.cond372.loopexit, label %for.body361 193 194 for.body361: ; preds = %for.body361, %if.end309 195 br i1 undef, label %for.cond372.loopexit, label %for.body361 196 197 for.cond372.loopexit: ; preds = %for.body361, %if.end309 198 br i1 undef, label %for.cond394.preheader, label %for.cond246 199 200 for.cond394.preheader: ; preds = %for.cond372.loopexit 201 br i1 undef, label %for.cond246.outer, label %for.body397 202 203 for.body397: ; preds = %for.cond394.preheader 204 unreachable 205 206 for.body409: ; preds = %for.inc558, %for.body409.lr.ph 207 %k.029 = phi i32 [ 1, %for.body409.lr.ph ], [ %inc559, %for.inc558 ] 208 br i1 undef, label %if.then412, label %if.else433 209 210 if.then412: ; preds = %for.body409 211 br label %if.end440 212 213 if.else433: ; preds = %for.body409 214 br label %if.end440 215 216 if.end440: ; preds = %if.else433, %if.then412 217 br i1 undef, label %for.inc558, label %if.end461 218 219 if.end461: ; preds = %if.end440 220 br i1 undef, label %for.cond528.loopexit, label %for.body517 221 222 for.body517: ; preds = %for.body517, %if.end461 223 br i1 undef, label %for.cond528.loopexit, label %for.body517 224 225 for.cond528.loopexit: ; preds = %for.body517, %if.end461 226 br label %for.inc558 227 228 for.inc558: ; preds = %for.cond528.loopexit, %if.end440 229 %inc559 = add nsw i32 %k.029, 1 230 %cmp407 = icmp sgt i32 %inc559, %add406 231 br i1 %cmp407, label %for.cond246.outer, label %for.body409 232 233 for.end562: ; preds = %if.end250, %for.cond246 234 unreachable 235 236 for.cond612: ; preds = %while.body119.lr.ph.lr.ph, %if.end115 237 unreachable 238 } 239 240 define void @test3() nounwind uwtable ssp { 241 entry: 242 br i1 undef, label %for.end, label %for.body 243 244 for.body: ; preds = %for.body, %entry 245 br i1 undef, label %for.end, label %for.body 246 247 for.end: ; preds = %for.body, %entry 248 br i1 undef, label %for.end11, label %for.body3 249 250 for.body3: ; preds = %for.end 251 unreachable 252 253 for.end11: ; preds = %for.end 254 br i1 undef, label %while.body, label %while.end 255 256 while.body: ; preds = %for.end11 257 unreachable 258 259 while.end: ; preds = %for.end11 260 br i1 undef, label %if.end115, label %for.cond109 261 262 for.cond109: ; preds = %while.end 263 unreachable 264 265 if.end115: ; preds = %while.end 266 br i1 undef, label %while.body119.lr.ph.lr.ph, label %for.cond612 267 268 while.body119.lr.ph.lr.ph: ; preds = %if.end115 269 br i1 undef, label %for.cond612, label %if.end123.us 270 271 if.end123.us: ; preds = %while.body119.lr.ph.lr.ph 272 br label %for.cond132.us 273 274 for.cond132.us: ; preds = %for.cond132.us, %if.end123.us 275 br i1 undef, label %if.then136.us, label %for.cond132.us 276 277 if.then136.us: ; preds = %for.cond132.us 278 br i1 undef, label %while.end220, label %while.body211 279 280 while.body211: ; preds = %while.body211, %if.then136.us 281 br i1 undef, label %while.end220, label %while.body211 282 283 while.end220: ; preds = %while.body211, %if.then136.us 284 br label %for.cond246.outer 285 286 for.cond246.outer: ; preds = %for.inc558, %for.cond394.preheader, %if.then274, %for.cond404.preheader, %while.end220 287 br label %for.cond246 288 289 for.cond246: ; preds = %for.cond372.loopexit, %for.cond246.outer 290 br i1 undef, label %for.end562, label %if.end250 291 292 if.end250: ; preds = %for.cond246 293 br i1 undef, label %if.end256, label %for.end562 294 295 if.end256: ; preds = %if.end250 296 br i1 undef, label %if.then274, label %for.cond404.preheader 297 298 for.cond404.preheader: ; preds = %if.end256 299 br i1 undef, label %for.cond246.outer, label %for.body409.lr.ph 300 301 for.body409.lr.ph: ; preds = %for.cond404.preheader 302 br label %for.body409 303 304 if.then274: ; preds = %if.end256 305 br i1 undef, label %for.cond246.outer, label %if.end309 306 307 if.end309: ; preds = %if.then274 308 br i1 undef, label %for.cond372.loopexit, label %for.body361 309 310 for.body361: ; preds = %for.body361, %if.end309 311 br i1 undef, label %for.cond372.loopexit, label %for.body361 312 313 for.cond372.loopexit: ; preds = %for.body361, %if.end309 314 br i1 undef, label %for.cond394.preheader, label %for.cond246 315 316 for.cond394.preheader: ; preds = %for.cond372.loopexit 317 br i1 undef, label %for.cond246.outer, label %for.body397 318 319 for.body397: ; preds = %for.cond394.preheader 320 unreachable 321 322 for.body409: ; preds = %for.inc558, %for.body409.lr.ph 323 br i1 undef, label %if.then412, label %if.else433 324 325 if.then412: ; preds = %for.body409 326 br label %if.end440 327 328 if.else433: ; preds = %for.body409 329 br label %if.end440 330 331 if.end440: ; preds = %if.else433, %if.then412 332 br i1 undef, label %for.inc558, label %if.end461 333 334 if.end461: ; preds = %if.end440 335 br i1 undef, label %for.cond528.loopexit, label %for.body517 336 337 for.body517: ; preds = %for.body517, %if.end461 338 br i1 undef, label %for.cond528.loopexit, label %for.body517 339 340 for.cond528.loopexit: ; preds = %for.body517, %if.end461 341 br label %for.inc558 342 343 for.inc558: ; preds = %for.cond528.loopexit, %if.end440 344 br i1 undef, label %for.cond246.outer, label %for.body409 345 346 for.end562: ; preds = %if.end250, %for.cond246 347 unreachable 348 349 for.cond612: ; preds = %while.body119.lr.ph.lr.ph, %if.end115 350 unreachable 351 } 352 353 define void @test4() nounwind uwtable ssp { 354 entry: 355 br i1 undef, label %if.end8, label %if.else 356 357 if.else: ; preds = %entry 358 br label %if.end8 359 360 if.end8: ; preds = %if.else, %entry 361 br i1 undef, label %if.end26, label %if.else22 362 363 if.else22: ; preds = %if.end8 364 br label %if.end26 365 366 if.end26: ; preds = %if.else22, %if.end8 367 br i1 undef, label %if.end35, label %if.else31 368 369 if.else31: ; preds = %if.end26 370 br label %if.end35 371 372 if.end35: ; preds = %if.else31, %if.end26 373 br i1 undef, label %for.end226, label %for.body.lr.ph 374 375 for.body.lr.ph: ; preds = %if.end35 376 br label %for.body48 377 378 for.body48: ; preds = %for.inc221, %for.body.lr.ph 379 br i1 undef, label %for.inc221, label %for.body65.lr.ph 380 381 for.body65.lr.ph: ; preds = %for.body48 382 %0 = load i32, i32* undef, align 4 383 %1 = sext i32 %0 to i64 384 br label %for.body65.us 385 386 for.body65.us: ; preds = %for.inc219.us, %for.body65.lr.ph 387 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc219.us ], [ 1, %for.body65.lr.ph ] 388 br i1 undef, label %for.inc219.us, label %if.end72.us 389 390 if.end72.us: ; preds = %for.body65.us 391 br i1 undef, label %if.end93.us, label %if.then76.us 392 393 if.then76.us: ; preds = %if.end72.us 394 br label %if.end93.us 395 396 if.end93.us: ; preds = %if.then76.us, %if.end72.us 397 br i1 undef, label %if.end110.us, label %for.inc219.us 398 399 if.end110.us: ; preds = %if.end93.us 400 br i1 undef, label %for.inc219.us, label %for.body142.us 401 402 for.body142.us: ; preds = %for.cond139.loopexit.us, %if.end110.us 403 br label %for.cond152.us 404 405 for.cond152.us: ; preds = %for.cond152.us, %for.body142.us 406 br i1 undef, label %for.cond139.loopexit.us, label %for.cond152.us 407 408 for.inc219.us: ; preds = %for.cond139.loopexit.us, %if.end110.us, %if.end93.us, %for.body65.us 409 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 410 %cmp64.us = icmp sgt i64 %indvars.iv.next, %1 411 br i1 %cmp64.us, label %for.inc221, label %for.body65.us 412 413 for.cond139.loopexit.us: ; preds = %for.cond152.us 414 br i1 undef, label %for.inc219.us, label %for.body142.us 415 416 for.inc221: ; preds = %for.inc219.us, %for.body48 417 br label %for.body48 418 419 for.end226: ; preds = %if.end35 420 ret void 421 } 422