1*9880d681SAndroid Build Coastguard Worker; RUN: opt -loop-reduce -S < %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker; 3*9880d681SAndroid Build Coastguard Worker; <rdar://10701050> "Cannot split an edge from an IndirectBrInst" assert. 4*9880d681SAndroid Build Coastguard Worker 5*9880d681SAndroid Build Coastguard Workertarget 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" 6*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-apple-darwin10.0.0" 7*9880d681SAndroid Build Coastguard Worker 8*9880d681SAndroid Build Coastguard Worker; while.cond197 is a dominates the simplified loop while.cond238 but 9*9880d681SAndroid Build Coastguard Worker; has no with no preheader. 10*9880d681SAndroid Build Coastguard Worker; 11*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @nopreheader( 12*9880d681SAndroid Build Coastguard Worker; CHECK: %while.cond238 13*9880d681SAndroid Build Coastguard Worker; CHECK: phi i64 14*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: phi 15*9880d681SAndroid Build Coastguard Worker; CHECK: indirectbr 16*9880d681SAndroid Build Coastguard Workerdefine void @nopreheader(i8* %end) nounwind { 17*9880d681SAndroid Build Coastguard Workerentry: 18*9880d681SAndroid Build Coastguard Worker br label %while.cond179 19*9880d681SAndroid Build Coastguard Worker 20*9880d681SAndroid Build Coastguard Workerwhile.cond179: ; preds = %if.end434, %if.end369, %if.end277, %if.end165 21*9880d681SAndroid Build Coastguard Worker %s.1 = phi i8* [ undef, %if.end434 ], [ %incdec.ptr356, %if.end348 ], [ undef, %entry ] 22*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %land.rhs184, label %while.end453] 23*9880d681SAndroid Build Coastguard Worker 24*9880d681SAndroid Build Coastguard Workerland.rhs184: ; preds = %while.cond179 25*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %while.end453, label %while.cond197] 26*9880d681SAndroid Build Coastguard Worker 27*9880d681SAndroid Build Coastguard Workerwhile.cond197: ; preds = %land.rhs202, %land.rhs184 28*9880d681SAndroid Build Coastguard Worker %0 = phi i64 [ %indvar.next11, %land.rhs202 ], [ 0, %land.rhs184 ] 29*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %land.rhs202, label %while.end215] 30*9880d681SAndroid Build Coastguard Worker 31*9880d681SAndroid Build Coastguard Workerland.rhs202: ; preds = %while.cond197 32*9880d681SAndroid Build Coastguard Worker %indvar.next11 = add i64 %0, 1 33*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %while.end215, label %while.cond197] 34*9880d681SAndroid Build Coastguard Worker 35*9880d681SAndroid Build Coastguard Workerwhile.end215: ; preds = %land.rhs202, %while.cond197 36*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %PREMATURE, label %if.end221] 37*9880d681SAndroid Build Coastguard Worker 38*9880d681SAndroid Build Coastguard Workerif.end221: ; preds = %while.end215 39*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %while.cond238.preheader, label %lor.lhs.false227] 40*9880d681SAndroid Build Coastguard Worker 41*9880d681SAndroid Build Coastguard Workerlor.lhs.false227: ; preds = %if.end221 42*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %while.cond238.preheader, label %if.else] 43*9880d681SAndroid Build Coastguard Worker 44*9880d681SAndroid Build Coastguard Workerwhile.cond238.preheader: ; preds = %lor.lhs.false227, %if.end221 45*9880d681SAndroid Build Coastguard Worker %tmp16 = add i64 %0, 2 46*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %while.cond238] 47*9880d681SAndroid Build Coastguard Worker 48*9880d681SAndroid Build Coastguard Workerwhile.cond238: ; preds = %land.rhs243, %while.cond238.preheader 49*9880d681SAndroid Build Coastguard Worker %1 = phi i64 [ %indvar.next15, %land.rhs243 ], [ 0, %while.cond238.preheader ] 50*9880d681SAndroid Build Coastguard Worker %tmp36 = add i64 %tmp16, %1 51*9880d681SAndroid Build Coastguard Worker %s.3 = getelementptr i8, i8* %s.1, i64 %tmp36 52*9880d681SAndroid Build Coastguard Worker %cmp241 = icmp ult i8* %s.3, %end 53*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %land.rhs243, label %while.end256] 54*9880d681SAndroid Build Coastguard Worker 55*9880d681SAndroid Build Coastguard Workerland.rhs243: ; preds = %while.cond238 56*9880d681SAndroid Build Coastguard Worker %indvar.next15 = add i64 %1, 1 57*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %while.end256, label %while.cond238] 58*9880d681SAndroid Build Coastguard Worker 59*9880d681SAndroid Build Coastguard Workerwhile.end256: ; preds = %land.rhs243, %while.cond238 60*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %PREMATURE] 61*9880d681SAndroid Build Coastguard Worker 62*9880d681SAndroid Build Coastguard Workerif.else: ; preds = %lor.lhs.false227 63*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %if.then297, label %if.else386] 64*9880d681SAndroid Build Coastguard Worker 65*9880d681SAndroid Build Coastguard Workerif.then297: ; preds = %if.else 66*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %PREMATURE, label %if.end307] 67*9880d681SAndroid Build Coastguard Worker 68*9880d681SAndroid Build Coastguard Workerif.end307: ; preds = %if.then297 69*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %if.end314, label %FAIL] 70*9880d681SAndroid Build Coastguard Worker 71*9880d681SAndroid Build Coastguard Workerif.end314: ; preds = %if.end307 72*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %if.end340] 73*9880d681SAndroid Build Coastguard Worker 74*9880d681SAndroid Build Coastguard Workerif.end340: ; preds = %while.end334 75*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %PREMATURE, label %if.end348] 76*9880d681SAndroid Build Coastguard Worker 77*9880d681SAndroid Build Coastguard Workerif.end348: ; preds = %if.end340 78*9880d681SAndroid Build Coastguard Worker %incdec.ptr356 = getelementptr inbounds i8, i8* undef, i64 2 79*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %while.cond179] 80*9880d681SAndroid Build Coastguard Worker 81*9880d681SAndroid Build Coastguard Workerif.else386: ; preds = %if.else 82*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %while.end453, label %if.end434] 83*9880d681SAndroid Build Coastguard Worker 84*9880d681SAndroid Build Coastguard Workerif.end434: ; preds = %if.then428, %if.end421 85*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %while.cond179] 86*9880d681SAndroid Build Coastguard Worker 87*9880d681SAndroid Build Coastguard Workerwhile.end453: ; preds = %if.else386, %land.rhs184, %while.cond179 88*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %PREMATURE, label %if.end459] 89*9880d681SAndroid Build Coastguard Worker 90*9880d681SAndroid Build Coastguard Workerif.end459: ; preds = %while.end453 91*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %if.then465, label %FAIL] 92*9880d681SAndroid Build Coastguard Worker 93*9880d681SAndroid Build Coastguard Workerif.then465: ; preds = %if.end459 94*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %return, label %if.then479] 95*9880d681SAndroid Build Coastguard Worker 96*9880d681SAndroid Build Coastguard Workerif.then479: ; preds = %if.then465 97*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %return] 98*9880d681SAndroid Build Coastguard Worker 99*9880d681SAndroid Build Coastguard WorkerFAIL: ; preds = %if.end459, %if.end307, %land.lhs.true142, %land.lhs.true131, %while.end 100*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %DECL_FAIL] 101*9880d681SAndroid Build Coastguard Worker 102*9880d681SAndroid Build Coastguard WorkerPREMATURE: ; preds = %while.end453, %while.end415, %if.end340, %while.end334, %if.then297, %while.end256, %while.end215 103*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %return, label %if.then495] 104*9880d681SAndroid Build Coastguard Worker 105*9880d681SAndroid Build Coastguard Workerif.then495: ; preds = %PREMATURE 106*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %return] 107*9880d681SAndroid Build Coastguard Worker 108*9880d681SAndroid Build Coastguard WorkerDECL_FAIL: ; preds = %if.then488, %FAIL, %land.lhs.true99, %lor.lhs.false, %if.end83, %if.then39, %if.end 109*9880d681SAndroid Build Coastguard Worker indirectbr i8* undef, [label %return] 110*9880d681SAndroid Build Coastguard Worker 111*9880d681SAndroid Build Coastguard Workerreturn: ; preds = %if.then512, %if.end504, %DECL_FAIL, %if.then495, %PREMATURE, %if.then479, %if.then465, %if.then69, %if.end52, %if.end19, %if.then 112*9880d681SAndroid Build Coastguard Worker ret void 113*9880d681SAndroid Build Coastguard Worker} 114