1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -disable-output -print-mustexecute %s 2>&1 | FileCheck %s
5 ; Make sure that the backedge is mustexec.
6 define void @test_no_exit_block(i1 %cond, i32 %a, i32 %b) {
7 ; CHECK-LABEL: @test_no_exit_block(
9 ; CHECK-NEXT: br label [[LOOP:%.*]]
11 ; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[BACKEDGE:%.*]] ] ; (mustexec in: loop)
12 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[MAYBE_TAKEN:%.*]], label [[BACKEDGE]] ; (mustexec in: loop)
15 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[A:%.*]], [[B:%.*]]
16 ; CHECK-NEXT: br label [[BACKEDGE]]
18 ; CHECK-NEXT: [[IV_NEXT]] = add i32 [[IV]], 1 ; (mustexec in: loop)
19 ; CHECK-NEXT: br label [[LOOP]] ; (mustexec in: loop)
25 %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]
26 br i1 %cond, label %maybe_taken, label %backedge
29 %div = sdiv i32 %a, %b
33 %iv.next = add i32 %iv, 1
37 ; Unlike the test before, we can say that backedge is mustexec, which is the
39 define void @test_impossible_exit_on_latch(i1 %cond, i32 %a, i32 %b) {
40 ; CHECK-LABEL: @test_impossible_exit_on_latch(
42 ; CHECK-NEXT: br label [[LOOP:%.*]]
44 ; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[BACKEDGE:%.*]] ] ; (mustexec in: loop)
45 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[MAYBE_TAKEN:%.*]], label [[BACKEDGE]] ; (mustexec in: loop)
47 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[A:%.*]], [[B:%.*]]
48 ; CHECK-NEXT: br label [[BACKEDGE]]
50 ; CHECK-NEXT: [[IV_NEXT]] = add i32 [[IV]], 1 ; (mustexec in: loop)
51 ; CHECK-NEXT: br i1 true, label [[LOOP]], label [[EXIT:%.*]] ; (mustexec in: loop)
53 ; CHECK-NEXT: ret void
59 %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]
60 br i1 %cond, label %maybe_taken, label %backedge
63 %div = sdiv i32 %a, %b
67 %iv.next = add i32 %iv, 1
68 br i1 true, label %loop, label %exit
74 ; Make sure that sdiv is NOT marked as mustexec.
75 define void @test_impossible_exit_in_untaken_block(i1 %cond, i32 %a, i32 %b, i32* %p) {
76 ; CHECK-LABEL: @test_impossible_exit_in_untaken_block(
78 ; CHECK-NEXT: br label [[LOOP:%.*]]
80 ; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[BACKEDGE:%.*]] ] ; (mustexec in: loop)
81 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[MAYBE_TAKEN:%.*]], label [[BACKEDGE]] ; (mustexec in: loop)
84 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[A:%.*]], [[B:%.*]]
85 ; CHECK-NEXT: store i32 [[DIV]], i32* [[P:%.*]]
86 ; CHECK-NEXT: br i1 true, label [[BACKEDGE]], label [[EXIT:%.*]]
88 ; CHECK-NEXT: [[IV_NEXT]] = add i32 [[IV]], 1 ; (mustexec in: loop)
89 ; CHECK-NEXT: br label [[LOOP]] ; (mustexec in: loop)
91 ; CHECK-NEXT: ret void
97 %iv = phi i32 [ 0, %entry ], [ %iv.next, %backedge ]
98 br i1 %cond, label %maybe_taken, label %backedge
101 %div = sdiv i32 %a, %b
102 store i32 %div, i32* %p
103 br i1 true, label %backedge, label %exit
106 %iv.next = add i32 %iv, 1