1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=loop-unroll -S %s | FileCheck %s
4 ; Check that the loop body containing callbr is correctly unrolled.
5 define dso_local void @d() {
8 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
10 ; CHECK-NEXT: br i1 true, label [[FOR_INC:%.*]], label [[IF_THEN:%.*]]
12 ; CHECK-NEXT: callbr void asm sideeffect "1: nop\0A\09.quad b, ${0:l}, $$5\0A\09", "!i,~{dirflag},~{fpsr},~{flags}"()
13 ; CHECK-NEXT: to label [[ASM_FALLTHROUGH:%.*]] [label %l_yes]
14 ; CHECK: asm.fallthrough:
15 ; CHECK-NEXT: br label [[L_YES:%.*]]
17 ; CHECK-NEXT: [[CALL:%.*]] = tail call i32 (...) @g()
18 ; CHECK-NEXT: br label [[FOR_INC]]
20 ; CHECK-NEXT: br i1 false, label [[FOR_INC_1:%.*]], label [[IF_THEN_1:%.*]]
22 ; CHECK-NEXT: callbr void asm sideeffect "1: nop\0A\09.quad b, ${0:l}, $$5\0A\09", "!i,~{dirflag},~{fpsr},~{flags}"()
23 ; CHECK-NEXT: to label [[ASM_FALLTHROUGH_1:%.*]] [label %l_yes.1]
24 ; CHECK: asm.fallthrough.1:
25 ; CHECK-NEXT: br label [[L_YES_1:%.*]]
27 ; CHECK-NEXT: [[CALL_1:%.*]] = tail call i32 (...) @g()
28 ; CHECK-NEXT: br label [[FOR_INC_1]]
30 ; CHECK-NEXT: br i1 false, label [[FOR_INC_2:%.*]], label [[IF_THEN_2:%.*]]
32 ; CHECK-NEXT: callbr void asm sideeffect "1: nop\0A\09.quad b, ${0:l}, $$5\0A\09", "!i,~{dirflag},~{fpsr},~{flags}"()
33 ; CHECK-NEXT: to label [[ASM_FALLTHROUGH_2:%.*]] [label %l_yes.2]
34 ; CHECK: asm.fallthrough.2:
35 ; CHECK-NEXT: br label [[L_YES_2:%.*]]
37 ; CHECK-NEXT: [[CALL_2:%.*]] = tail call i32 (...) @g()
38 ; CHECK-NEXT: br label [[FOR_INC_2]]
40 ; CHECK-NEXT: ret void
45 for.cond.cleanup: ; preds = %for.inc
48 for.body: ; preds = %for.inc, %entry
49 %e.04 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
50 %tobool = icmp eq i32 %e.04, 0
51 br i1 %tobool, label %for.inc, label %if.then
53 if.then: ; preds = %for.body
54 callbr void asm sideeffect "1: nop\0A\09.quad b, ${0:l}, $$5\0A\09", "!i,~{dirflag},~{fpsr},~{flags}"()
55 to label %asm.fallthrough [label %l_yes]
57 asm.fallthrough: ; preds = %if.then
60 l_yes: ; preds = %asm.fallthrough, %if.then
61 %call = tail call i32 (...) @g()
64 for.inc: ; preds = %for.body, %l_yes
65 %inc = add nuw nsw i32 %e.04, 1
66 %exitcond = icmp eq i32 %inc, 3
67 br i1 %exitcond, label %for.cond.cleanup, label %for.body
70 declare dso_local i32 @g(...) local_unnamed_addr