1; RUN: opt -S -loop-simplify -disable-output -verify-loop-info -verify-dom-info < %s 2; PR5235 3 4; When loopsimplify inserts a preheader for this loop, it should add the new 5; block to the enclosing loop and not get confused by the unreachable 6; bogus loop entry. 7 8define void @is_extract_cab() nounwind { 9entry: 10 br label %header 11 12header: ; preds = %if.end206, %cond.end66, %if.end23 13 br label %while.body115 14 15while.body115: ; preds = %9, %if.end192, %if.end101 16 br i1 undef, label %header, label %while.body115 17 18foo: 19 br label %while.body115 20} 21 22; When loopsimplify generates dedicated exit block for blocks that are landing 23; pads (i.e. innerLoopExit in this test), we should not get confused with the 24; unreachable pred (unreachableB) to innerLoopExit. 25define void @baz(i32 %trip) personality i32* ()* @wobble { 26entry: 27 br label %outerHeader 28 29outerHeader: 30 invoke void @foo() 31 to label %innerPreheader unwind label %innerLoopExit 32 33innerPreheader: 34 br label %innerH 35 36innerH: 37 %tmp50 = invoke i8 * undef() 38 to label %innerLatch unwind label %innerLoopExit 39 40innerLatch: 41 %cmp = icmp slt i32 %trip, 42 42 br i1 %cmp, label %innerH, label %retblock 43 44unreachableB: ; No predecessors! 45 %tmp62 = invoke i8 * undef() 46 to label %retblock unwind label %innerLoopExit 47 48; undedicated exit block (preds from inner and outer loop) 49; Also has unreachableB as pred. 50innerLoopExit: 51 %tmp65 = landingpad { i8*, i32 } 52 cleanup 53 invoke void @foo() 54 to label %outerHeader unwind label %unwindblock 55 56unwindblock: 57 %tmp67 = landingpad { i8*, i32 } 58 cleanup 59 ret void 60 61retblock: 62 ret void 63} 64 65; Function Attrs: nounwind 66declare i32* @wobble() 67 68; Function Attrs: uwtable 69declare void @foo() 70