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.
5 declare void @subtract() nounwind uwtable
7 ; CHECK-NOT: unreachable
8 define i32 @main(i32 %argc, i8** nocapture %argv) nounwind uwtable {
10 %vals19 = alloca [5 x i32], align 16
11 %x20 = alloca i32, align 4
12 store i32 135, i32* %x20, align 4
15 for.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*
18 blockaddress(@main, %for.body_codeprime)) nounwind
19 indirectbr i8* %a6, [label %for.body_code, label %for.body_codeprime]
21 for.body_code: ; preds = %for.body
23 br label %call2_termjoin
25 call2_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
30 for.end: ; preds = %call2_termjoin
33 for.body_codeprime: ; preds = %for.body
34 call void @subtract_v2(i64 %indvars.iv)
35 br label %call2_termjoin
38 declare coldcc i8* @funca(i8*, i8*) readonly
40 declare void @subtract_v2(i64) nounwind uwtable