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