1; RUN: opt < %s -S -loop-unroll -simplifycfg | FileCheck %s 2; PR12513: Loop unrolling breaks with indirect branches. 3; If loop unrolling attempts to transform this loop, it replaces the 4; indirectbr successors. SimplifyCFG then considers them to be unreachable. 5declare void @subtract() nounwind uwtable 6 7; CHECK-NOT: unreachable 8define i32 @main(i32 %argc, i8** nocapture %argv) nounwind uwtable { 9entry: 10 %vals19 = alloca [5 x i32], align 16 11 %x20 = alloca i32, align 4 12 store i32 135, i32* %x20, align 4 13 br label %for.body 14 15for.body: ; preds = ; %call2_termjoin, %call3_termjoin 16 %indvars.iv = phi i64 [ 0, %entry ], [ %joinphi15.in.in, %call2_termjoin ] 17 %a6 = call coldcc i8* @funca(i8* blockaddress(@main, %for.body_code), i8* 18blockaddress(@main, %for.body_codeprime)) nounwind 19 indirectbr i8* %a6, [label %for.body_code, label %for.body_codeprime] 20 21for.body_code: ; preds = %for.body 22 call void @subtract() 23 br label %call2_termjoin 24 25call2_termjoin: ; preds = %for.body_codeprime, %for.body_code 26 %joinphi15.in.in = add i64 %indvars.iv, 1 27 %exitcond = icmp eq i64 %joinphi15.in.in, 5 28 br i1 %exitcond, label %for.end, label %for.body 29 30for.end: ; preds = %call2_termjoin 31 ret i32 0 32 33for.body_codeprime: ; preds = %for.body 34 call void @subtract_v2(i64 %indvars.iv) 35 br label %call2_termjoin 36} 37 38declare coldcc i8* @funca(i8*, i8*) readonly 39 40declare void @subtract_v2(i64) nounwind uwtable 41