1 ; RUN: opt -loop-rotate -disable-output -verify-dom-info -verify-loop-info < %s
2 ; RUN: opt -loop-rotate -disable-output -verify-dom-info -verify-loop-info -enable-mssa-loop-dependency=true -verify-memoryssa < %s
4 target 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"
5 target triple = "x86_64-apple-darwin10.0.0"
7 ; PR8955 - Rotating an outer loop that has a condbr for a latch block.
8 define void @test1() nounwind ssp {
12 lbl_283: ; preds = %if.end, %entry
13 br i1 undef, label %if.else, label %if.then
15 if.then: ; preds = %lbl_283
16 br i1 undef, label %if.end, label %for.condthread-pre-split
18 for.condthread-pre-split: ; preds = %if.then
21 for.cond: ; preds = %for.cond, %for.condthread-pre-split
22 br i1 undef, label %lbl_281, label %for.cond
24 lbl_281: ; preds = %if.end, %for.cond
27 if.end: ; preds = %lbl_281, %if.then
28 br i1 undef, label %lbl_283, label %lbl_281
30 if.else: ; preds = %lbl_283
34 %struct.relation = type { [4 x i16], i32, [4 x i16], i32, i32 }
36 define void @test2() {
38 br i1 false, label %bb139, label %bb10.i44
39 bb10.i44: ; preds = %entry
41 bb127: ; preds = %bb139
43 bb139: ; preds = %bb127, %entry
44 br i1 false, label %bb127, label %bb142
45 bb142: ; preds = %bb139
46 %r91.0.lcssa = phi %struct.relation* [ null, %bb139 ] ; <%struct.relation*> [#uses=0]
51 define void @test3() {
53 br i1 false, label %bb139, label %cond_true
54 cond_true: ; preds = %entry
56 bb90: ; preds = %bb139
57 br i1 false, label %bb136, label %cond_next121
58 cond_next121: ; preds = %bb90
59 br i1 false, label %bb136, label %bb127
60 bb127: ; preds = %cond_next121
62 bb136: ; preds = %bb127, %cond_next121, %bb90
63 %changes.1 = phi i32 [ %changes.2, %bb90 ], [ %changes.2, %cond_next121 ], [ 1, %bb127 ] ; <i32> [#uses=1]
65 bb139: ; preds = %bb136, %entry
66 %changes.2 = phi i32 [ %changes.1, %bb136 ], [ 0, %entry ] ; <i32> [#uses=3]
67 br i1 false, label %bb90, label %bb142
68 bb142: ; preds = %bb139
69 %changes.2.lcssa = phi i32 [ %changes.2, %bb139 ] ; <i32> [#uses=0]
73 define void @test4() {
75 br i1 false, label %cond_false485, label %bb405
76 bb405: ; preds = %entry
78 cond_false485: ; preds = %entry
80 bb511: ; preds = %bb830
81 br i1 false, label %bb816, label %bb830
82 cond_next667: ; preds = %bb816
83 br i1 false, label %cond_next695, label %bb680
84 bb676: ; preds = %bb680
86 bb680: ; preds = %bb676, %cond_next667
87 %iftmp.68.0 = zext i1 false to i8 ; <i8> [#uses=1]
88 br i1 false, label %bb676, label %cond_next695
89 cond_next695: ; preds = %bb680, %cond_next667
90 %iftmp.68.2 = phi i8 [ %iftmp.68.0, %bb680 ], [ undef, %cond_next667 ] ; <i8> [#uses=0]
92 bb816: ; preds = %bb816, %bb511
93 br i1 false, label %cond_next667, label %bb816
94 bb830: ; preds = %bb511, %cond_false485
95 br i1 false, label %bb511, label %bb835
96 bb835: ; preds = %bb830
100 %struct.NSArray = type { %struct.NSObject }
101 %struct.NSObject = type { %struct.objc_class* }
102 %struct.NSRange = type { i64, i64 }
103 %struct._message_ref_t = type { %struct.NSObject* (%struct.NSObject*, %struct._message_ref_t*, ...)*, %struct.objc_selector* }
104 %struct.objc_class = type opaque
105 %struct.objc_selector = type opaque
106 @"\01L_OBJC_MESSAGE_REF_26" = external global %struct._message_ref_t ; <%struct._message_ref_t*> [#uses=1]
108 define %struct.NSArray* @test5(%struct.NSArray* %self, %struct._message_ref_t* %_cmd) {
112 bb116: ; preds = %bb131, %entry
113 %tmp123 = call %struct.NSRange null( %struct.NSObject* null, %struct._message_ref_t* @"\01L_OBJC_MESSAGE_REF_26", %struct.NSArray* null ) ; <%struct.NSRange> [#uses=1]
114 br i1 false, label %bb141, label %bb131
116 bb131: ; preds = %bb116
117 %mrv_gr125 = extractvalue %struct.NSRange %tmp123, 1 ; <i64> [#uses=0]
120 bb141: ; preds = %bb116
121 ret %struct.NSArray* null
124 define void @test6(i8* %msg) {
128 %gep.upgrd.1 = zext i32 %offset.1 to i64 ; <i64> [#uses=1]
129 %tmp11 = getelementptr i8, i8* %msg, i64 %gep.upgrd.1 ; <i8*> [#uses=0]
131 bb15: ; preds = %bb6, %entry
132 %offset.1 = add i32 0, 1 ; <i32> [#uses=2]
133 br i1 false, label %bb6, label %bb17
134 bb17: ; preds = %bb15
135 %offset.1.lcssa = phi i32 [ %offset.1, %bb15 ] ; <i32> [#uses=0]
136 %payload_type.1.lcssa = phi i32 [ 0, %bb15 ] ; <i32> [#uses=0]
143 ; PR9523 - Non-canonical loop.
144 define void @test7(i8* %P) nounwind {
146 indirectbr i8* %P, [label %"3", label %"5"]
148 "3": ; preds = %"4", %entry
149 br i1 undef, label %"5", label %"4"
154 "5": ; preds = %"3", %entry
159 define void @test8(i1 %C, i8* %P) #0 {
163 for.cond: ; preds = %for.inc, %entry
164 br i1 %C, label %l_bad, label %for.body
166 for.body: ; preds = %for.cond
167 indirectbr i8* %P, [label %for.inc, label %l_bad]
169 for.inc: ; preds = %for.body
172 l_bad: ; preds = %for.body, %for.cond