brintos

brintos / llvm-project-archived public Read only

0
0
Text · 25.9 KiB · 50da17c Raw
725 lines · plain
1; RUN: opt < %s -S -passes=loop-flatten -debug-only=loop-flatten 2>&1 | FileCheck %s2; REQUIRES: asserts3 4target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"5 6; Every function in this file has a reason that it can't be transformed.7 8; CHECK-NOT: Checks all passed, doing the transformation9 10; Outer loop does not start at zero11define void @test_1(i32 %N, ptr nocapture %C, ptr nocapture readonly %A, i32 %scale) {12entry:13  %cmp25 = icmp sgt i32 %N, 014  br i1 %cmp25, label %for.body4.lr.ph, label %for.cond.cleanup15 16for.body4.lr.ph:17  %i.026 = phi i32 [ %inc10, %for.cond.cleanup3 ], [ 1, %entry ]18  %mul = mul nsw i32 %i.026, %N19  br label %for.body420 21for.body4:22  %j.024 = phi i32 [ 0, %for.body4.lr.ph ], [ %inc, %for.body4 ]23  %add = add nsw i32 %j.024, %mul24  %arrayidx = getelementptr inbounds i32, ptr %A, i32 %add25  %0 = load i32, ptr %arrayidx, align 426  %mul5 = mul nsw i32 %0, %scale27  %arrayidx8 = getelementptr inbounds i32, ptr %C, i32 %add28  store i32 %mul5, ptr %arrayidx8, align 429  %inc = add nuw nsw i32 %j.024, 130  %exitcond = icmp eq i32 %inc, %N31  br i1 %exitcond, label %for.cond.cleanup3, label %for.body432 33for.cond.cleanup3:34  %inc10 = add nuw nsw i32 %i.026, 135  %exitcond27 = icmp eq i32 %inc10, %N36  br i1 %exitcond27, label %for.cond.cleanup, label %for.body4.lr.ph37 38for.cond.cleanup:39  ret void40}41 42; Inner loop does not start at zero43define void @test_2(i32 %N, ptr nocapture %C, ptr nocapture readonly %A, i32 %scale) {44entry:45  %cmp25 = icmp sgt i32 %N, 046  br i1 %cmp25, label %for.body4.lr.ph, label %for.cond.cleanup47 48for.body4.lr.ph:49  %i.026 = phi i32 [ %inc10, %for.cond.cleanup3 ], [ 0, %entry ]50  %mul = mul nsw i32 %i.026, %N51  br label %for.body452 53for.body4:54  %j.024 = phi i32 [ 1, %for.body4.lr.ph ], [ %inc, %for.body4 ]55  %add = add nsw i32 %j.024, %mul56  %arrayidx = getelementptr inbounds i32, ptr %A, i32 %add57  %0 = load i32, ptr %arrayidx, align 458  %mul5 = mul nsw i32 %0, %scale59  %arrayidx8 = getelementptr inbounds i32, ptr %C, i32 %add60  store i32 %mul5, ptr %arrayidx8, align 461  %inc = add nuw nsw i32 %j.024, 162  %exitcond = icmp eq i32 %inc, %N63  br i1 %exitcond, label %for.cond.cleanup3, label %for.body464 65for.cond.cleanup3:66  %inc10 = add nuw nsw i32 %i.026, 167  %exitcond27 = icmp eq i32 %inc10, %N68  br i1 %exitcond27, label %for.cond.cleanup, label %for.body4.lr.ph69 70for.cond.cleanup:71  ret void72}73 74; Outer IV used directly75define hidden void @test_3(i16 zeroext %N, ptr nocapture %C, ptr nocapture readonly %A, i32 %scale) {76entry:77  %conv = zext i16 %N to i3278  %cmp25 = icmp eq i16 %N, 079  br i1 %cmp25, label %for.cond.cleanup, label %for.body.lr.ph.split.us80 81for.body.lr.ph.split.us:                          ; preds = %entry82  br label %for.body.us83 84for.body.us:                                      ; preds = %for.cond2.for.cond.cleanup6_crit_edge.us, %for.body.lr.ph.split.us85  %i.026.us = phi i32 [ 0, %for.body.lr.ph.split.us ], [ %inc12.us, %for.cond2.for.cond.cleanup6_crit_edge.us ]86  %arrayidx.us = getelementptr inbounds i32, ptr %A, i32 %i.026.us87  %mul9.us = mul nuw nsw i32 %i.026.us, %conv88  br label %for.body7.us89 90for.body7.us:                                     ; preds = %for.body.us, %for.body7.us91  %j.024.us = phi i32 [ 0, %for.body.us ], [ %inc.us, %for.body7.us ]92  %0 = load i32, ptr %arrayidx.us, align 493  %mul.us = mul nsw i32 %0, %scale94  %add.us = add nuw nsw i32 %j.024.us, %mul9.us95  %arrayidx10.us = getelementptr inbounds i32, ptr %C, i32 %add.us96  store i32 %mul.us, ptr %arrayidx10.us, align 497  %inc.us = add nuw nsw i32 %j.024.us, 198  %exitcond = icmp ne i32 %inc.us, %conv99  br i1 %exitcond, label %for.body7.us, label %for.cond2.for.cond.cleanup6_crit_edge.us100 101for.cond2.for.cond.cleanup6_crit_edge.us:         ; preds = %for.body7.us102  %inc12.us = add nuw nsw i32 %i.026.us, 1103  %exitcond27 = icmp ne i32 %inc12.us, %conv104  br i1 %exitcond27, label %for.body.us, label %for.cond.cleanup.loopexit105 106for.cond.cleanup.loopexit:                        ; preds = %for.cond2.for.cond.cleanup6_crit_edge.us107  br label %for.cond.cleanup108 109for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry110  ret void111}112 113; Inner IV used directly114define hidden void @test_4(i16 zeroext %N, ptr nocapture %C, ptr nocapture readonly %A, i32 %scale) {115entry:116  %conv = zext i16 %N to i32117  %cmp25 = icmp eq i16 %N, 0118  br i1 %cmp25, label %for.cond.cleanup, label %for.body.lr.ph.split.us119 120for.body.lr.ph.split.us:                          ; preds = %entry121  br label %for.body.us122 123for.body.us:                                      ; preds = %for.cond2.for.cond.cleanup6_crit_edge.us, %for.body.lr.ph.split.us124  %i.026.us = phi i32 [ 0, %for.body.lr.ph.split.us ], [ %inc12.us, %for.cond2.for.cond.cleanup6_crit_edge.us ]125  %mul9.us = mul nuw nsw i32 %i.026.us, %conv126  br label %for.body7.us127 128for.body7.us:                                     ; preds = %for.body.us, %for.body7.us129  %j.024.us = phi i32 [ 0, %for.body.us ], [ %inc.us, %for.body7.us ]130  %arrayidx.us = getelementptr inbounds i32, ptr %A, i32 %j.024.us131  %0 = load i32, ptr %arrayidx.us, align 4132  %mul.us = mul nsw i32 %0, %scale133  %add.us = add nuw nsw i32 %j.024.us, %mul9.us134  %arrayidx10.us = getelementptr inbounds i32, ptr %C, i32 %add.us135  store i32 %mul.us, ptr %arrayidx10.us, align 4136  %inc.us = add nuw nsw i32 %j.024.us, 1137  %exitcond = icmp ne i32 %inc.us, %conv138  br i1 %exitcond, label %for.body7.us, label %for.cond2.for.cond.cleanup6_crit_edge.us139 140for.cond2.for.cond.cleanup6_crit_edge.us:         ; preds = %for.body7.us141  %inc12.us = add nuw nsw i32 %i.026.us, 1142  %exitcond27 = icmp ne i32 %inc12.us, %conv143  br i1 %exitcond27, label %for.body.us, label %for.cond.cleanup.loopexit144 145for.cond.cleanup.loopexit:                        ; preds = %for.cond2.for.cond.cleanup6_crit_edge.us146  br label %for.cond.cleanup147 148for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry149  ret void150}151 152; Inner iteration count not invariant in outer loop153declare i32 @get_int() readonly154define void @test_5(i16 zeroext %N, ptr nocapture %C, ptr nocapture readonly %A, i32 %scale) {155entry:156  %conv = zext i16 %N to i32157  %cmp27 = icmp eq i16 %N, 0158  br i1 %cmp27, label %for.cond.cleanup, label %for.body.lr.ph159 160for.body.lr.ph:                                   ; preds = %entry161  br label %for.body162 163for.cond.cleanup.loopexit:                        ; preds = %for.cond.cleanup5164  br label %for.cond.cleanup165 166for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry167  ret void168 169for.body:                                         ; preds = %for.body.lr.ph, %for.cond.cleanup5170  %i.028 = phi i32 [ 0, %for.body.lr.ph ], [ %inc12, %for.cond.cleanup5 ]171  %call = tail call i32 @get_int()172  %cmp325 = icmp sgt i32 %call, 0173  br i1 %cmp325, label %for.body6.lr.ph, label %for.cond.cleanup5174 175for.body6.lr.ph:                                  ; preds = %for.body176  %mul = mul nsw i32 %call, %i.028177  br label %for.body6178 179for.cond.cleanup5.loopexit:                       ; preds = %for.body6180  br label %for.cond.cleanup5181 182for.cond.cleanup5:                                ; preds = %for.cond.cleanup5.loopexit, %for.body183  %inc12 = add nuw nsw i32 %i.028, 1184  %exitcond29 = icmp ne i32 %inc12, %conv185  br i1 %exitcond29, label %for.body, label %for.cond.cleanup.loopexit186 187for.body6:                                        ; preds = %for.body6.lr.ph, %for.body6188  %j.026 = phi i32 [ 0, %for.body6.lr.ph ], [ %inc, %for.body6 ]189  %add = add nsw i32 %j.026, %mul190  %arrayidx = getelementptr inbounds i32, ptr %A, i32 %add191  %0 = load i32, ptr %arrayidx, align 4192  %mul7 = mul nsw i32 %0, %scale193  %arrayidx10 = getelementptr inbounds i32, ptr %C, i32 %add194  store i32 %mul7, ptr %arrayidx10, align 4195  %inc = add nuw nsw i32 %j.026, 1196  %exitcond = icmp ne i32 %inc, %call197  br i1 %exitcond, label %for.body6, label %for.cond.cleanup5.loopexit198}199 200; Inner loop has an early exit201define hidden void @test_6(i16 zeroext %N, ptr nocapture %C, ptr nocapture readonly %A, i32 %scale) {202entry:203  %conv = zext i16 %N to i32204  %cmp39 = icmp eq i16 %N, 0205  br i1 %cmp39, label %for.cond.cleanup, label %for.body.us.preheader206 207for.body.us.preheader:                            ; preds = %entry208  br label %for.body.us209 210for.body.us:                                      ; preds = %for.body.us.preheader, %cleanup.us211  %i.040.us = phi i32 [ %inc19.us, %cleanup.us ], [ 0, %for.body.us.preheader ]212  %mul.us = mul nuw nsw i32 %i.040.us, %conv213  br label %for.body7.us214 215for.body7.us:                                     ; preds = %for.body.us, %if.end.us216  %j.038.us = phi i32 [ 0, %for.body.us ], [ %inc.us, %if.end.us ]217  %add.us = add nuw nsw i32 %j.038.us, %mul.us218  %arrayidx.us = getelementptr inbounds i32, ptr %A, i32 %add.us219  %0 = load i32, ptr %arrayidx.us, align 4220  %tobool.us = icmp eq i32 %0, 0221  br i1 %tobool.us, label %if.end.us, label %cleanup.us222 223cleanup.us:                                       ; preds = %if.end.us, %for.body7.us224  %inc19.us = add nuw nsw i32 %i.040.us, 1225  %exitcond = icmp eq i32 %inc19.us, %conv226  br i1 %exitcond, label %for.cond.cleanup, label %for.body.us227 228if.end.us:                                        ; preds = %for.body7.us229  %arrayidx17.us = getelementptr inbounds i32, ptr %C, i32 %add.us230  store i32 0, ptr %arrayidx17.us, align 4231  %inc.us = add nuw nsw i32 %j.038.us, 1232  %cmp4.us = icmp ult i32 %inc.us, %conv233  br i1 %cmp4.us, label %for.body7.us, label %cleanup.us234 235for.cond.cleanup:                                 ; preds = %cleanup.us, %entry236  ret void237}238 239define hidden void @test_7(i16 zeroext %N, ptr nocapture %C, ptr nocapture readonly %A, i32 %scale) {240entry:241  %conv = zext i16 %N to i32242  %cmp30 = icmp eq i16 %N, 0243  br i1 %cmp30, label %cleanup, label %for.body.us.preheader244 245for.body.us.preheader:                            ; preds = %entry246  br label %for.body.us247 248for.body.us:                                      ; preds = %for.body.us.preheader, %for.cond2.for.cond.cleanup6_crit_edge.us249  %i.031.us = phi i32 [ %inc15.us, %for.cond2.for.cond.cleanup6_crit_edge.us ], [ 0, %for.body.us.preheader ]250  %call.us = tail call i32 @get_int() #2251  %tobool.us = icmp eq i32 %call.us, 0252  br i1 %tobool.us, label %for.body7.lr.ph.us, label %cleanup253 254for.body7.us:                                     ; preds = %for.body7.us, %for.body7.lr.ph.us255  %j.029.us = phi i32 [ 0, %for.body7.lr.ph.us ], [ %inc.us, %for.body7.us ]256  %add.us = add nuw nsw i32 %j.029.us, %mul.us257  %arrayidx.us = getelementptr inbounds i32, ptr %A, i32 %add.us258  %0 = load i32, ptr %arrayidx.us, align 4259  %mul9.us = mul nsw i32 %0, %scale260  %arrayidx13.us = getelementptr inbounds i32, ptr %C, i32 %add.us261  store i32 %mul9.us, ptr %arrayidx13.us, align 4262  %inc.us = add nuw nsw i32 %j.029.us, 1263  %exitcond = icmp eq i32 %inc.us, %conv264  br i1 %exitcond, label %for.cond2.for.cond.cleanup6_crit_edge.us, label %for.body7.us265 266for.body7.lr.ph.us:                               ; preds = %for.body.us267  %mul.us = mul nuw nsw i32 %i.031.us, %conv268  br label %for.body7.us269 270for.cond2.for.cond.cleanup6_crit_edge.us:         ; preds = %for.body7.us271  %inc15.us = add nuw nsw i32 %i.031.us, 1272  %cmp.us = icmp ult i32 %inc15.us, %conv273  br i1 %cmp.us, label %for.body.us, label %cleanup274 275cleanup:                                          ; preds = %for.cond2.for.cond.cleanup6_crit_edge.us, %for.body.us, %entry276  ret void277}278 279; Step is not 1280define i32 @test_8(i32 %val, ptr nocapture %A) {281entry:282  br label %for.body283 284for.body:                                         ; preds = %entry, %for.inc6285  %i.018 = phi i32 [ 0, %entry ], [ %inc7, %for.inc6 ]286  %mul = mul nuw nsw i32 %i.018, 20287  br label %for.body3288 289for.body3:                                        ; preds = %for.body, %for.body3290  %j.017 = phi i32 [ 0, %for.body ], [ %inc, %for.body3 ]291  %add = add nuw nsw i32 %j.017, %mul292  %arrayidx = getelementptr inbounds i16, ptr %A, i32 %add293  %0 = load i16, ptr %arrayidx, align 2294  %conv16 = zext i16 %0 to i32295  %add4 = add i32 %conv16, %val296  %conv5 = trunc i32 %add4 to i16297  store i16 %conv5, ptr %arrayidx, align 2298  %inc = add nuw nsw i32 %j.017, 1299  %exitcond = icmp ne i32 %inc, 20300  br i1 %exitcond, label %for.body3, label %for.inc6301 302for.inc6:                                         ; preds = %for.body3303  %inc7 = add nuw nsw i32 %i.018, 2304  %exitcond19 = icmp ne i32 %inc7, 10305  br i1 %exitcond19, label %for.body, label %for.end8306 307for.end8:                                         ; preds = %for.inc6308  ret i32 10309}310 311 312; Step is not 1313define i32 @test_9(i32 %val, ptr nocapture %A) {314entry:315  br label %for.body316 317for.body:                                         ; preds = %entry, %for.inc6318  %i.018 = phi i32 [ 0, %entry ], [ %inc7, %for.inc6 ]319  %mul = mul nuw nsw i32 %i.018, 20320  br label %for.body3321 322for.body3:                                        ; preds = %for.body, %for.body3323  %j.017 = phi i32 [ 0, %for.body ], [ %inc, %for.body3 ]324  %add = add nuw nsw i32 %j.017, %mul325  %arrayidx = getelementptr inbounds i16, ptr %A, i32 %add326  %0 = load i16, ptr %arrayidx, align 2327  %conv16 = zext i16 %0 to i32328  %add4 = add i32 %conv16, %val329  %conv5 = trunc i32 %add4 to i16330  store i16 %conv5, ptr %arrayidx, align 2331  %inc = add nuw nsw i32 %j.017, 2332  %exitcond = icmp ne i32 %inc, 20333  br i1 %exitcond, label %for.body3, label %for.inc6334 335for.inc6:                                         ; preds = %for.body3336  %inc7 = add nuw nsw i32 %i.018, 1337  %exitcond19 = icmp ne i32 %inc7, 10338  br i1 %exitcond19, label %for.body, label %for.end8339 340for.end8:                                         ; preds = %for.inc6341  ret i32 10342}343 344; test_10, test_11 and test_12 are for the case when the345; inner trip count is a constant, then the InstCombine pass346; makes the transformation icmp ult i32 %inc, tripcount ->347; icmp ult i32 %j, tripcount-step.348 349; test_10: The step is not 1.350define i32 @test_10(ptr nocapture %A) {351entry:352  br label %for.cond1.preheader353 354for.cond1.preheader:355  %i.017 = phi i32 [ 0, %entry ], [ %inc, %for.cond.cleanup3 ]356  %mul = mul i32 %i.017, 20357  br label %for.body4358 359for.body4:360  %j.016 = phi i32 [ 0, %for.cond1.preheader ], [ %add5, %for.body4 ]361  %add = add i32 %j.016, %mul362  %arrayidx = getelementptr inbounds i32, ptr %A, i32 %add363  store i32 30, ptr %arrayidx, align 4364  %add5 = add nuw nsw i32 %j.016, 2365  %cmp2 = icmp ult i32 %j.016, 18366  br i1 %cmp2, label %for.body4, label %for.cond.cleanup3367 368for.cond.cleanup3:369  %inc = add i32 %i.017, 1370  %cmp = icmp ult i32 %inc, 11371  br i1 %cmp, label %for.cond1.preheader, label %for.cond.cleanup372 373for.cond.cleanup:374  %0 = load i32, ptr %A, align 4375  ret i32 %0376}377 378; test_11: The inner inducation variable is used in a compare which379; isn't the condition of the inner branch.380define i32 @test_11(ptr nocapture %A) {381entry:382  br label %for.cond1.preheader383 384for.cond1.preheader:385  %i.020 = phi i32 [ 0, %entry ], [ %inc7, %for.cond.cleanup3 ]386  %mul = mul i32 %i.020, 20387  br label %for.body4388 389for.body4:390  %j.019 = phi i32 [ 0, %for.cond1.preheader ], [ %inc, %for.body4 ]391  %cmp5 = icmp ult i32 %j.019, 5392  %cond = select i1 %cmp5, i32 30, i32 15393  %add = add i32 %j.019, %mul394  %arrayidx = getelementptr inbounds i32, ptr %A, i32 %add395  store i32 %cond, ptr %arrayidx, align 4396  %inc = add nuw nsw i32 %j.019, 1397  %cmp2 = icmp ult i32 %j.019, 19398  br i1 %cmp2, label %for.body4, label %for.cond.cleanup3399 400for.cond.cleanup3:401  %inc7 = add i32 %i.020, 1402  %cmp = icmp ult i32 %inc7, 11403  br i1 %cmp, label %for.cond1.preheader, label %for.cond.cleanup404 405for.cond.cleanup:406  %0 = load i32, ptr %A, align 4407  ret i32 %0408}409 410; test_12: Incoming phi node value for preheader is a variable411define i32 @test_12(ptr %A) {412entry:413  br label %while.cond1.preheader414 415while.cond1.preheader:416  %j.017 = phi i32 [ 0, %entry ], [ %j.1, %while.end ]417  %i.016 = phi i32 [ 0, %entry ], [ %inc4, %while.end ]418  %mul = mul i32 %i.016, 20419  %cmp214 = icmp ult i32 %j.017, 20420  br i1 %cmp214, label %while.body3.preheader, label %while.end421 422while.body3.preheader:423  br label %while.body3424 425while.body3:426  %j.115 = phi i32 [ %inc, %while.body3 ], [ %j.017, %while.body3.preheader ]427  %add = add i32 %j.115, %mul428  %arrayidx = getelementptr inbounds i32, ptr %A, i32 %add429  store i32 30, ptr %arrayidx, align 4430  %inc = add nuw nsw i32 %j.115, 1431  %cmp2 = icmp ult i32 %j.115, 19432  br i1 %cmp2, label %while.body3, label %while.end.loopexit433 434while.end.loopexit:435  %inc.lcssa = phi i32 [ %inc, %while.body3 ]436  br label %while.end437 438while.end:439  %j.1 = phi i32 [ %j.017, %while.cond1.preheader], [ %inc.lcssa, %while.end.loopexit ]440  %inc4 = add i32 %i.016, 1441  %cmp = icmp ult i32 %inc4, 11442  br i1 %cmp, label %while.cond1.preheader, label %while.end5443 444while.end5:445  %0 = load i32, ptr %A, align 4446  ret i32 %0447}448 449; Outer loop conditional phi450define i32 @e() {451entry:452  br label %for.body453 454for.body:                                         ; preds = %entry, %for.end16455  %f.033 = phi i32 [ 0, %entry ], [ %inc18, %for.end16 ]456  %g.032 = phi i32 [ undef, %entry ], [ %g.3.lcssa, %for.end16 ]457  %.pr = add i32 10, 10458  %tobool29 = icmp eq i32 %.pr, 0459  br i1 %tobool29, label %for.end, label %for.body2.lr.ph460 461for.body2.lr.ph:                                  ; preds = %for.body462  br label %for.cond1.for.end_crit_edge463 464for.cond1.for.end_crit_edge:                      ; preds = %for.body2.lr.ph465  br label %for.end466 467for.end:                                          ; preds = %for.cond1.for.end_crit_edge, %for.body468  %g.1.lcssa = phi i32 [ 0, %for.cond1.for.end_crit_edge ], [ %g.032, %for.body ]469  br label %for.body5470 471for.body5:                                        ; preds = %for.end, %lor.end472  %i.031 = phi i32 [ 0, %for.end ], [ %inc15, %lor.end ]473  %g.230 = phi i32 [ %g.1.lcssa, %for.end ], [ %g.3, %lor.end ]474  %0 = add i32 10, 10475  %1 = add i32 10, 10476  %tobool9 = icmp eq i32 %1, 0477  br i1 %tobool9, label %lor.rhs, label %lor.end478 479lor.rhs:                                          ; preds = %for.body5480  %2 = add i32 10, 10481  %call11 = add i32 10, 10482  %tobool12 = icmp ne i32 %call11, 0483  br label %lor.end484 485lor.end:                                          ; preds = %for.body5, %lor.rhs486  %g.3 = phi i32 [ %g.230, %for.body5 ], [ %call11, %lor.rhs ]487  %3 = phi i1 [ true, %for.body5 ], [ %tobool12, %lor.rhs ]488  %lor.ext = zext i1 %3 to i32489  %inc15 = add nuw nsw i32 %i.031, 1490  %exitcond = icmp ne i32 %inc15, 9491  br i1 %exitcond, label %for.body5, label %for.end16492 493for.end16:                                        ; preds = %lor.end494  %g.3.lcssa = phi i32 [ %g.3, %lor.end ]495  %inc18 = add nuw nsw i32 %f.033, 1496  %exitcond34 = icmp ne i32 %inc18, 7497  br i1 %exitcond34, label %for.body, label %for.end19498 499for.end19:                                        ; preds = %for.end16500  ret i32 undef501}502 503; A 3d loop corresponding to:504;505; for (int i = 0; i < N; ++i)506;    for (int j = 0; j < N; ++j)507;      for (int k = 0; k < N; ++k)508;        f(&A[i + N * (j + N * k)]);509;510define void @d3_1(ptr %A, i32 %N) {511entry:512  %cmp35 = icmp sgt i32 %N, 0513  br i1 %cmp35, label %for.cond1.preheader.lr.ph, label %for.cond.cleanup514 515for.cond1.preheader.lr.ph:516  br label %for.cond1.preheader.us517 518for.cond1.preheader.us:519  %i.036.us = phi i32 [ 0, %for.cond1.preheader.lr.ph ], [ %inc15.us, %for.cond1.for.cond.cleanup3_crit_edge.us ]520  br i1 true, label %for.cond5.preheader.us.us.preheader, label %for.cond5.preheader.us52.preheader521 522for.cond5.preheader.us52.preheader:523  br label %for.cond5.preheader.us52524 525for.cond5.preheader.us.us.preheader:526  br label %for.cond5.preheader.us.us527 528for.cond5.preheader.us52:529  br i1 false, label %for.cond5.preheader.us52, label %for.cond1.for.cond.cleanup3_crit_edge.us.loopexit58530 531for.cond1.for.cond.cleanup3_crit_edge.us.loopexit:532  br label %for.cond1.for.cond.cleanup3_crit_edge.us533 534for.cond1.for.cond.cleanup3_crit_edge.us.loopexit58:535  br label %for.cond1.for.cond.cleanup3_crit_edge.us536 537for.cond1.for.cond.cleanup3_crit_edge.us:538  %inc15.us = add nuw nsw i32 %i.036.us, 1539  %cmp.us = icmp slt i32 %inc15.us, %N540  br i1 %cmp.us, label %for.cond1.preheader.us, label %for.cond.cleanup.loopexit541 542for.cond5.preheader.us.us:543  %j.033.us.us = phi i32 [ %inc12.us.us, %for.cond5.for.cond.cleanup7_crit_edge.us.us ], [ 0, %for.cond5.preheader.us.us.preheader ]544  br label %for.body8.us.us545 546for.cond5.for.cond.cleanup7_crit_edge.us.us:547  %inc12.us.us = add nuw nsw i32 %j.033.us.us, 1548  %cmp2.us.us = icmp slt i32 %inc12.us.us, %N549  br i1 %cmp2.us.us, label %for.cond5.preheader.us.us, label %for.cond1.for.cond.cleanup3_crit_edge.us.loopexit550 551for.body8.us.us:552  %k.031.us.us = phi i32 [ 0, %for.cond5.preheader.us.us ], [ %inc.us.us, %for.body8.us.us ]553  %mul.us.us = mul nsw i32 %k.031.us.us, %N554  %add.us.us = add nsw i32 %mul.us.us, %j.033.us.us555  %mul9.us.us = mul nsw i32 %add.us.us, %N556  %add10.us.us = add nsw i32 %mul9.us.us, %i.036.us557  %idxprom.us.us = sext i32 %add10.us.us to i64558  %arrayidx.us.us = getelementptr inbounds i32, ptr %A, i64 %idxprom.us.us559  tail call void @f(ptr %arrayidx.us.us) #2560  %inc.us.us = add nuw nsw i32 %k.031.us.us, 1561  %cmp6.us.us = icmp slt i32 %inc.us.us, %N562  br i1 %cmp6.us.us, label %for.body8.us.us, label %for.cond5.for.cond.cleanup7_crit_edge.us.us563 564for.cond.cleanup.loopexit:565  br label %for.cond.cleanup566 567for.cond.cleanup:568  ret void569}570 571; A 3d loop corresponding to:572;573;   for (int i = 0; i < N; ++i)574;     for (int j = 0; j < M; ++j) {575;       A[i*M+j] = 0;576;       for (int k = 0; k < N; ++k)577;         g();578;     }579;580define void @d3_3(ptr nocapture %A, i32 %N, i32 %M) {581entry:582  %cmp29 = icmp sgt i32 %N, 0583  br i1 %cmp29, label %for.cond1.preheader.lr.ph, label %for.cond.cleanup584 585for.cond1.preheader.lr.ph:586  %cmp227 = icmp sgt i32 %M, 0587  br i1 %cmp227, label %for.cond1.preheader.us.preheader, label %for.cond1.preheader.preheader588 589for.cond1.preheader.preheader:590  br label %for.cond.cleanup.loopexit49591 592for.cond1.preheader.us.preheader:593  br label %for.cond1.preheader.us594 595for.cond1.preheader.us:596  %i.030.us = phi i32 [ %inc13.us, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ 0, %for.cond1.preheader.us.preheader ]597  %mul.us = mul nsw i32 %i.030.us, %M598  br i1 true, label %for.body4.us.us.preheader, label %for.body4.us32.preheader599 600for.body4.us32.preheader:601  br label %for.cond1.for.cond.cleanup3_crit_edge.us.loopexit48602 603for.body4.us.us.preheader:604  br label %for.body4.us.us605 606for.cond1.for.cond.cleanup3_crit_edge.us.loopexit:607  br label %for.cond1.for.cond.cleanup3_crit_edge.us608 609for.cond1.for.cond.cleanup3_crit_edge.us.loopexit48:610  br label %for.cond1.for.cond.cleanup3_crit_edge.us611 612for.cond1.for.cond.cleanup3_crit_edge.us:613  %inc13.us = add nuw nsw i32 %i.030.us, 1614  %exitcond51 = icmp ne i32 %inc13.us, %N615  br i1 %exitcond51, label %for.cond1.preheader.us, label %for.cond.cleanup.loopexit616 617for.body4.us.us:618  %j.028.us.us = phi i32 [ %inc10.us.us, %for.cond5.for.cond.cleanup7_crit_edge.us.us ], [ 0, %for.body4.us.us.preheader ]619  %add.us.us = add nsw i32 %j.028.us.us, %mul.us620  %idxprom.us.us = sext i32 %add.us.us to i64621  %arrayidx.us.us = getelementptr inbounds i32, ptr %A, i64 %idxprom.us.us622  store i32 0, ptr %arrayidx.us.us, align 4623  br label %for.body8.us.us624 625for.cond5.for.cond.cleanup7_crit_edge.us.us:626  %inc10.us.us = add nuw nsw i32 %j.028.us.us, 1627  %exitcond50 = icmp ne i32 %inc10.us.us, %M628  br i1 %exitcond50, label %for.body4.us.us, label %for.cond1.for.cond.cleanup3_crit_edge.us.loopexit629 630for.body8.us.us:631  %k.026.us.us = phi i32 [ 0, %for.body4.us.us ], [ %inc.us.us, %for.body8.us.us ]632  tail call void @g() #2633  %inc.us.us = add nuw nsw i32 %k.026.us.us, 1634  %exitcond = icmp ne i32 %inc.us.us, %N635  br i1 %exitcond, label %for.body8.us.us, label %for.cond5.for.cond.cleanup7_crit_edge.us.us636 637for.cond.cleanup.loopexit:638  br label %for.cond.cleanup639 640for.cond.cleanup.loopexit49:641  br label %for.cond.cleanup642 643for.cond.cleanup:644  ret void645}646 647; Backedge-taken count is not predictable.648%struct.Limits = type { i16, i16 }649define void @backedge_count(ptr %lim) {650entry:651  %M = getelementptr inbounds %struct.Limits, ptr %lim, i32 0, i32 1652  %0 = load i16, ptr %lim, align 2653  %cmp20 = icmp sgt i16 %0, 0654  br i1 %cmp20, label %for.cond2.preheader.preheader, label %for.cond.cleanup655 656for.cond2.preheader.preheader:657  %.pre = load i16, ptr %M, align 2658  br label %for.cond2.preheader659 660for.cond2.preheader:661  %1 = phi i16 [ %3, %for.cond.cleanup6 ], [ %0, %for.cond2.preheader.preheader ]662  %2 = phi i16 [ %4, %for.cond.cleanup6 ], [ %.pre, %for.cond2.preheader.preheader ]663  %i.021 = phi i32 [ %inc9, %for.cond.cleanup6 ], [ 0, %for.cond2.preheader.preheader ]664  %cmp417 = icmp sgt i16 %2, 0665  br i1 %cmp417, label %for.body7, label %for.cond.cleanup6666 667for.cond.cleanup:668  ret void669 670for.cond.cleanup6.loopexit:671  %.pre22 = load i16, ptr %lim, align 2672  br label %for.cond.cleanup6673 674for.cond.cleanup6:675  %3 = phi i16 [ %.pre22, %for.cond.cleanup6.loopexit ], [ %1, %for.cond2.preheader ]676  %4 = phi i16 [ %5, %for.cond.cleanup6.loopexit ], [ %2, %for.cond2.preheader ]677  %inc9 = add nuw nsw i32 %i.021, 1678  %conv = sext i16 %3 to i32679  %cmp = icmp slt i32 %inc9, %conv680  br i1 %cmp, label %for.cond2.preheader, label %for.cond.cleanup681 682for.body7:683  %j.018 = phi i32 [ %inc, %for.body7 ], [ 0, %for.cond2.preheader ]684  tail call void @g()685  %inc = add nuw nsw i32 %j.018, 1686  %5 = load i16, ptr %M, align 2687  %conv3 = sext i16 %5 to i32688  %cmp4 = icmp slt i32 %inc, %conv3689  br i1 %cmp4, label %for.body7, label %for.cond.cleanup6.loopexit690}691 692; Invalid trip count693define void @invalid_tripCount(ptr %a, i32 %b, i32 %c, i32 %initial-mutations, i32 %statemutations) {694entry:695  %iszero = icmp eq i32 %b, 0696  br i1 %iszero, label %for.empty, label %for.loopinit697for.loopinit:698  br label %for.loopbody.outer699for.loopbody.outer:700  %for.count.ph = phi i32 [ %c, %for.refetch ], [ %b, %for.loopinit ]701  br label %for.loopbody702for.loopbody:703  %for.index = phi i32 [ %1, %for.notmutated ], [ 0, %for.loopbody.outer ]704  %0 = icmp eq i32 %statemutations, %initial-mutations705  br i1 %0, label %for.notmutated, label %for.mutated706for.mutated:707  call void @objc_enumerationMutation(ptr %a)708  br label %for.notmutated709for.notmutated:710  %1 = add nuw i32 %for.index, 1711  %2 = icmp ult i32 %1, %for.count.ph712  br i1 %2, label %for.loopbody, label %for.refetch713for.refetch:714  %3 = icmp eq i32 %c, 0715  br i1 %3, label %for.empty.loopexit, label %for.loopbody.outer716for.empty.loopexit:717  br label %for.empty718for.empty:719  ret void720}721 722declare void @objc_enumerationMutation(ptr)723declare dso_local void @f(ptr)724declare dso_local void @g(...)725