1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -disable-output -print-mustexecute %s 2>&1 | FileCheck %s
4 define i1 @header_with_icf(i32* noalias %p, i32 %high) {
5 ; CHECK-LABEL: @header_with_icf(
7 ; CHECK: %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ] ; (mustexec in: loop)
8 ; CHECK: %v = load i32, i32* %p ; (mustexec in: loop)
9 ; CHECK: call void @maythrow_and_use(i32 %v) ; (mustexec in: loop)
16 %iv = phi i32 [0, %entry], [%iv.next, %loop]
17 %v = load i32, i32* %p
18 call void @maythrow_and_use(i32 %v)
19 %iv.next = add nsw nuw i32 %iv, 1
20 %exit.test = icmp slt i32 %iv, %high
21 br i1 %exit.test, label %exit, label %loop
27 define i1 @split_header(i32* noalias %p, i32 %high) {
28 ; CHECK-LABEL: @split_header(
30 ; CHECK: %iv = phi i32 [ 0, %entry ], [ %iv.next, %next ] ; (mustexec in: loop)
31 ; CHECK: %v = load i32, i32* %p ; (mustexec in: loop)
32 ; CHECK: br label %next ; (mustexec in: loop)
38 %iv = phi i32 [0, %entry], [%iv.next, %next]
39 %v = load i32, i32* %p
42 call void @maythrow_and_use(i32 %v)
43 %iv.next = add nsw nuw i32 %iv, 1
44 %exit.test = icmp slt i32 %iv, %high
45 br i1 %exit.test, label %exit, label %loop
51 ; FIXME: everything in inner loop header should be must execute
53 define i1 @nested(i32* noalias %p, i32 %high) {
54 ; CHECK-LABEL: @nested
55 ; CHECK-LABEL: loop: ; preds = %next
56 ; CHECK: %iv = phi i32 [ 0, %entry ], [ %iv.next, %next ] ; (mustexec in: loop)
57 ; CHECK: br label %inner_loop ; (mustexec in: loop)
58 ; CHECK-LABEL: inner_loop:
59 ; CHECK: %v = load i32, i32* %p ; (mustexec in: inner_loop)
60 ; CHECK: %inner.test = icmp eq i32 %v, 0 ; (mustexec in: inner_loop)
61 ; CHECK: br i1 %inner.test, label %inner_loop, label %next ; (mustexec in: inner_loop)
68 %iv = phi i32 [0, %entry], [%iv.next, %next]
72 %v = load i32, i32* %p
73 %inner.test = icmp eq i32 %v, 0
74 br i1 %inner.test, label %inner_loop, label %next
77 call void @maythrow_and_use(i32 %v)
78 %iv.next = add nsw nuw i32 %iv, 1
79 %exit.test = icmp slt i32 %iv, %high
80 br i1 %exit.test, label %exit, label %loop
86 define i1 @nested_no_throw(i32* noalias %p, i32 %high) {
87 ; CHECK-LABEL: @nested_no_throw
88 ; CHECK-LABEL: loop: ; preds = %next
89 ; CHECK: %iv = phi i32 [ 0, %entry ], [ %iv.next, %next ] ; (mustexec in: loop)
90 ; CHECK: br label %inner_loop ; (mustexec in: loop)
91 ; CHECK-LABEL: inner_loop:
92 ; CHECK: %v = load i32, i32* %p ; (mustexec in 2 loops: inner_loop, loop)
93 ; CHECK: %inner.test = icmp eq i32 %v, 0 ; (mustexec in 2 loops: inner_loop, loop)
94 ; CHECK: br i1 %inner.test, label %inner_loop, label %next ; (mustexec in 2 loops: inner_loop, loop)
96 ; CHECK: %iv.next = add nuw nsw i32 %iv, 1 ; (mustexec in: loop)
97 ; CHECK: %exit.test = icmp slt i32 %iv, %high ; (mustexec in: loop)
98 ; CHECK: br i1 %exit.test, label %exit, label %loop ; (mustexec in: loop)
104 %iv = phi i32 [0, %entry], [%iv.next, %next]
108 %v = load i32, i32* %p
109 %inner.test = icmp eq i32 %v, 0
110 br i1 %inner.test, label %inner_loop, label %next
113 %iv.next = add nsw nuw i32 %iv, 1
114 %exit.test = icmp slt i32 %iv, %high
115 br i1 %exit.test, label %exit, label %loop
121 ; Since all the instructions in the loop dominate the only exit
122 ; and there's no implicit control flow in the loop, all must execute
123 ; FIXME: handled by loop safety info, test it
124 define i1 @nothrow_loop(i32* noalias %p, i32 %high) {
125 ; CHECK-LABEL: @nothrow_loop(
127 ; CHECK: %iv = phi i32 [ 0, %entry ], [ %iv.next, %next ] ; (mustexec in: loop)
128 ; CHECK: br label %next ; (mustexec in: loop)
130 ; CHECK: %v = load i32, i32* %p ; (mustexec in: loop)
131 ; CHECK: %iv.next = add nuw nsw i32 %iv, 1 ; (mustexec in: loop)
132 ; CHECK: %exit.test = icmp slt i32 %iv, %high ; (mustexec in: loop)
133 ; CHECK: br i1 %exit.test, label %exit, label %loop ; (mustexec in: loop)
134 ; CHECK-NOT: mustexec
140 %iv = phi i32 [0, %entry], [%iv.next, %next]
143 %v = load i32, i32* %p
144 %iv.next = add nsw nuw i32 %iv, 1
145 %exit.test = icmp slt i32 %iv, %high
146 br i1 %exit.test, label %exit, label %loop
153 declare void @maythrow_and_use(i32)