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