blob: a6d4f5b3dbcc3d895e59705ba7134b0ac00e4b3e [file] [log] [blame]
Chris Lattner81ba7042002-03-11 22:09:43 +00001; When constant propogating terminator instructions, the basic block iterator
2; was not updated to refer to the final position of the new terminator. This
3; can be bad, f.e. because constproping a terminator can lead to the
4; destruction of PHI nodes, which invalidates the iterator!
5;
6; Fixed by adding new arguments to ConstantFoldTerminator
7;
Dan Gohmanf2f6ce62009-09-11 18:01:28 +00008; RUN: opt < %s -constprop
Chris Lattner81ba7042002-03-11 22:09:43 +00009
Tanya Lattner2ad38be2008-02-19 01:44:26 +000010define void @build_tree(i32 %ml) {
11; <label>:0
12 br label %bb2
Chris Lattner81ba7042002-03-11 22:09:43 +000013
Tanya Lattner2ad38be2008-02-19 01:44:26 +000014bb2: ; preds = %bb2, %0
15 %reg137 = phi i32 [ %reg140, %bb2 ], [ 12, %0 ] ; <i32> [#uses=1]
16 %reg138 = phi i32 [ %reg139, %bb2 ], [ 0, %0 ] ; <i32> [#uses=1]
17 %reg139 = add i32 %reg138, 1 ; <i32> [#uses=1]
18 %reg140 = add i32 %reg137, -1 ; <i32> [#uses=1]
19 br i1 false, label %bb2, label %bb3
Chris Lattner81ba7042002-03-11 22:09:43 +000020
Tanya Lattner2ad38be2008-02-19 01:44:26 +000021bb3: ; preds = %bb2
22 ret void
23}
Chris Lattner81ba7042002-03-11 22:09:43 +000024