1; RUN: opt -loop-rotate -disable-output -verify-dom-info -verify-loop-info < %s 2 3target 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" 4target triple = "x86_64-apple-darwin10.0.0" 5 6; PR8955 - Rotating an outer loop that has a condbr for a latch block. 7define void @test1() nounwind ssp { 8entry: 9 br label %lbl_283 10 11lbl_283: ; preds = %if.end, %entry 12 br i1 undef, label %if.else, label %if.then 13 14if.then: ; preds = %lbl_283 15 br i1 undef, label %if.end, label %for.condthread-pre-split 16 17for.condthread-pre-split: ; preds = %if.then 18 br label %for.cond 19 20for.cond: ; preds = %for.cond, %for.condthread-pre-split 21 br i1 undef, label %lbl_281, label %for.cond 22 23lbl_281: ; preds = %if.end, %for.cond 24 br label %if.end 25 26if.end: ; preds = %lbl_281, %if.then 27 br i1 undef, label %lbl_283, label %lbl_281 28 29if.else: ; preds = %lbl_283 30 ret void 31} 32 33 %struct.relation = type { [4 x i16], i32, [4 x i16], i32, i32 } 34 35define void @test2() { 36entry: 37 br i1 false, label %bb139, label %bb10.i44 38bb10.i44: ; preds = %entry 39 ret void 40bb127: ; preds = %bb139 41 br label %bb139 42bb139: ; preds = %bb127, %entry 43 br i1 false, label %bb127, label %bb142 44bb142: ; preds = %bb139 45 %r91.0.lcssa = phi %struct.relation* [ null, %bb139 ] ; <%struct.relation*> [#uses=0] 46 ret void 47} 48 49 50define void @test3() { 51entry: 52 br i1 false, label %bb139, label %cond_true 53cond_true: ; preds = %entry 54 ret void 55bb90: ; preds = %bb139 56 br i1 false, label %bb136, label %cond_next121 57cond_next121: ; preds = %bb90 58 br i1 false, label %bb136, label %bb127 59bb127: ; preds = %cond_next121 60 br label %bb136 61bb136: ; preds = %bb127, %cond_next121, %bb90 62 %changes.1 = phi i32 [ %changes.2, %bb90 ], [ %changes.2, %cond_next121 ], [ 1, %bb127 ] ; <i32> [#uses=1] 63 br label %bb139 64bb139: ; preds = %bb136, %entry 65 %changes.2 = phi i32 [ %changes.1, %bb136 ], [ 0, %entry ] ; <i32> [#uses=3] 66 br i1 false, label %bb90, label %bb142 67bb142: ; preds = %bb139 68 %changes.2.lcssa = phi i32 [ %changes.2, %bb139 ] ; <i32> [#uses=0] 69 ret void 70} 71 72define void @test4() { 73entry: 74 br i1 false, label %cond_false485, label %bb405 75bb405: ; preds = %entry 76 ret void 77cond_false485: ; preds = %entry 78 br label %bb830 79bb511: ; preds = %bb830 80 br i1 false, label %bb816, label %bb830 81cond_next667: ; preds = %bb816 82 br i1 false, label %cond_next695, label %bb680 83bb676: ; preds = %bb680 84 br label %bb680 85bb680: ; preds = %bb676, %cond_next667 86 %iftmp.68.0 = zext i1 false to i8 ; <i8> [#uses=1] 87 br i1 false, label %bb676, label %cond_next695 88cond_next695: ; preds = %bb680, %cond_next667 89 %iftmp.68.2 = phi i8 [ %iftmp.68.0, %bb680 ], [ undef, %cond_next667 ] ; <i8> [#uses=0] 90 ret void 91bb816: ; preds = %bb816, %bb511 92 br i1 false, label %cond_next667, label %bb816 93bb830: ; preds = %bb511, %cond_false485 94 br i1 false, label %bb511, label %bb835 95bb835: ; preds = %bb830 96 ret void 97} 98 99 %struct.NSArray = type { %struct.NSObject } 100 %struct.NSObject = type { %struct.objc_class* } 101 %struct.NSRange = type { i64, i64 } 102 %struct._message_ref_t = type { %struct.NSObject* (%struct.NSObject*, %struct._message_ref_t*, ...)*, %struct.objc_selector* } 103 %struct.objc_class = type opaque 104 %struct.objc_selector = type opaque 105@"\01L_OBJC_MESSAGE_REF_26" = external global %struct._message_ref_t ; <%struct._message_ref_t*> [#uses=1] 106 107define %struct.NSArray* @test5(%struct.NSArray* %self, %struct._message_ref_t* %_cmd) { 108entry: 109 br label %bb116 110 111bb116: ; preds = %bb131, %entry 112 %tmp123 = call %struct.NSRange null( %struct.NSObject* null, %struct._message_ref_t* @"\01L_OBJC_MESSAGE_REF_26", %struct.NSArray* null ) ; <%struct.NSRange> [#uses=1] 113 br i1 false, label %bb141, label %bb131 114 115bb131: ; preds = %bb116 116 %mrv_gr125 = extractvalue %struct.NSRange %tmp123, 1 ; <i64> [#uses=0] 117 br label %bb116 118 119bb141: ; preds = %bb116 120 ret %struct.NSArray* null 121} 122 123define void @test6(i8* %msg) { 124entry: 125 br label %bb15 126bb6: ; preds = %bb15 127 %gep.upgrd.1 = zext i32 %offset.1 to i64 ; <i64> [#uses=1] 128 %tmp11 = getelementptr i8, i8* %msg, i64 %gep.upgrd.1 ; <i8*> [#uses=0] 129 br label %bb15 130bb15: ; preds = %bb6, %entry 131 %offset.1 = add i32 0, 1 ; <i32> [#uses=2] 132 br i1 false, label %bb6, label %bb17 133bb17: ; preds = %bb15 134 %offset.1.lcssa = phi i32 [ %offset.1, %bb15 ] ; <i32> [#uses=0] 135 %payload_type.1.lcssa = phi i32 [ 0, %bb15 ] ; <i32> [#uses=0] 136 ret void 137} 138 139 140 141 142; PR9523 - Non-canonical loop. 143define void @test7(i8* %P) nounwind { 144entry: 145 indirectbr i8* %P, [label %"3", label %"5"] 146 147"3": ; preds = %"4", %entry 148 br i1 undef, label %"5", label %"4" 149 150"4": ; preds = %"3" 151 br label %"3" 152 153"5": ; preds = %"3", %entry 154 ret void 155} 156 157; PR21968 158define void @test8(i1 %C, i8* %P) #0 { 159entry: 160 br label %for.cond 161 162for.cond: ; preds = %for.inc, %entry 163 br i1 %C, label %l_bad, label %for.body 164 165for.body: ; preds = %for.cond 166 indirectbr i8* %P, [label %for.inc, label %l_bad] 167 168for.inc: ; preds = %for.body 169 br label %for.cond 170 171l_bad: ; preds = %for.body, %for.cond 172 ret void 173} 174