1; RUN: opt -loop-unroll -S %s | FileCheck %s
2
3; Check that the loop body exists.
4; CHECK: for.body
5; CHECK: if.then
6; CHECK: asm.fallthrough
7; CHECK: l_yes
8; CHECK: for.inc
9
10; Check that the loop body does not get unrolled.  We could modify this test in
11; the future to support loop unrolling callbr's IFF we checked that the callbr
12; operands were unrolled/updated correctly, as today they are not.
13; CHECK-NOT: if.then.1
14; CHECK-NOT: asm.fallthrough.1
15; CHECK-NOT: l_yes.1
16; CHECK-NOT: for.inc.1
17; CHECK-NOT: if.then.2
18; CHECK-NOT: asm.fallthrough.2
19; CHECK-NOT: l_yes.2
20; CHECK-NOT: for.inc.2
21
22define dso_local void @d() {
23entry:
24  br label %for.body
25
26for.cond.cleanup:                                 ; preds = %for.inc
27  ret void
28
29for.body:                                         ; preds = %for.inc, %entry
30  %e.04 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
31  %tobool = icmp eq i32 %e.04, 0
32  br i1 %tobool, label %for.inc, label %if.then
33
34if.then:                                          ; preds = %for.body
35  callbr void asm sideeffect "1: nop\0A\09.quad b, ${0:l}, $$5\0A\09", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@d, %l_yes))
36          to label %asm.fallthrough [label %l_yes]
37
38asm.fallthrough:                                  ; preds = %if.then
39  br label %l_yes
40
41l_yes:                                            ; preds = %asm.fallthrough, %if.then
42  %call = tail call i32 (...) @g()
43  br label %for.inc
44
45for.inc:                                          ; preds = %for.body, %l_yes
46  %inc = add nuw nsw i32 %e.04, 1
47  %exitcond = icmp eq i32 %inc, 3
48  br i1 %exitcond, label %for.cond.cleanup, label %for.body
49}
50
51declare dso_local i32 @g(...) local_unnamed_addr
52