Philip Reames | ce998ad | 2018-03-20 18:43:44 +0000 | [diff] [blame] | 1 | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | ; RUN: opt -disable-output -print-mustexecute %s 2>&1 | FileCheck %s |
Philip Reames | 89f2241 | 2018-03-20 17:09:21 +0000 | [diff] [blame] | 3 | |
Philip Reames | 89f2241 | 2018-03-20 17:09:21 +0000 | [diff] [blame] | 4 | define i1 @header_with_icf(i32* noalias %p, i32 %high) { |
Philip Reames | ce998ad | 2018-03-20 18:43:44 +0000 | [diff] [blame] | 5 | ; CHECK-LABEL: @header_with_icf( |
| 6 | ; CHECK-LABEL: loop: |
| 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) |
| 10 | ; CHECK-NOT: mustexec |
| 11 | |
Philip Reames | 89f2241 | 2018-03-20 17:09:21 +0000 | [diff] [blame] | 12 | entry: |
| 13 | br label %loop |
| 14 | |
| 15 | 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 |
| 22 | |
| 23 | exit: |
| 24 | ret i1 false |
| 25 | } |
| 26 | |
Philip Reames | ce998ad | 2018-03-20 18:43:44 +0000 | [diff] [blame] | 27 | define i1 @split_header(i32* noalias %p, i32 %high) { |
| 28 | ; CHECK-LABEL: @split_header( |
| 29 | ; CHECK-LABEL: loop: |
| 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) |
| 33 | ; CHECK-NOT: mustexec |
Philip Reames | 89f2241 | 2018-03-20 17:09:21 +0000 | [diff] [blame] | 34 | entry: |
| 35 | br label %loop |
| 36 | |
| 37 | loop: |
| 38 | %iv = phi i32 [0, %entry], [%iv.next, %next] |
| 39 | %v = load i32, i32* %p |
| 40 | br label %next |
| 41 | next: |
| 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 |
| 46 | |
| 47 | exit: |
| 48 | ret i1 false |
| 49 | } |
| 50 | |
Philip Reames | ce998ad | 2018-03-20 18:43:44 +0000 | [diff] [blame] | 51 | ; FIXME: everything in inner loop header should be must execute |
| 52 | ; for outer as well |
Philip Reames | 89f2241 | 2018-03-20 17:09:21 +0000 | [diff] [blame] | 53 | define i1 @nested(i32* noalias %p, i32 %high) { |
Philip Reames | ce998ad | 2018-03-20 18:43:44 +0000 | [diff] [blame] | 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) |
| 62 | ; CHECK-NOT: mustexec |
| 63 | |
Philip Reames | 89f2241 | 2018-03-20 17:09:21 +0000 | [diff] [blame] | 64 | entry: |
| 65 | br label %loop |
| 66 | |
| 67 | loop: |
| 68 | %iv = phi i32 [0, %entry], [%iv.next, %next] |
| 69 | br label %inner_loop |
| 70 | |
| 71 | inner_loop: |
| 72 | %v = load i32, i32* %p |
| 73 | %inner.test = icmp eq i32 %v, 0 |
| 74 | br i1 %inner.test, label %inner_loop, label %next |
| 75 | |
| 76 | 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 |
| 81 | |
| 82 | exit: |
| 83 | ret i1 false |
| 84 | } |
| 85 | |
Max Kazantsev | 7b78d39 | 2018-08-17 06:19:17 +0000 | [diff] [blame] | 86 | ; FIXME: everything in inner loop header should be must execute |
| 87 | ; for outer as well |
| 88 | define i1 @nested_no_throw(i32* noalias %p, i32 %high) { |
| 89 | ; CHECK-LABEL: @nested_no_throw |
| 90 | ; CHECK-LABEL: loop: ; preds = %next |
| 91 | ; CHECK: %iv = phi i32 [ 0, %entry ], [ %iv.next, %next ] ; (mustexec in: loop) |
| 92 | ; CHECK: br label %inner_loop ; (mustexec in: loop) |
| 93 | ; CHECK-LABEL: inner_loop: |
| 94 | ; CHECK: %v = load i32, i32* %p ; (mustexec in: inner_loop) |
| 95 | ; CHECK: %inner.test = icmp eq i32 %v, 0 ; (mustexec in: inner_loop) |
| 96 | ; CHECK: br i1 %inner.test, label %inner_loop, label %next ; (mustexec in: inner_loop) |
| 97 | ; CHECK-LABEL: next: |
| 98 | ; CHECK: %iv.next = add nuw nsw i32 %iv, 1 ; (mustexec in: loop) |
| 99 | ; CHECK: %exit.test = icmp slt i32 %iv, %high ; (mustexec in: loop) |
| 100 | ; CHECK: br i1 %exit.test, label %exit, label %loop ; (mustexec in: loop) |
| 101 | |
| 102 | entry: |
| 103 | br label %loop |
| 104 | |
| 105 | loop: |
| 106 | %iv = phi i32 [0, %entry], [%iv.next, %next] |
| 107 | br label %inner_loop |
| 108 | |
| 109 | inner_loop: |
| 110 | %v = load i32, i32* %p |
| 111 | %inner.test = icmp eq i32 %v, 0 |
| 112 | br i1 %inner.test, label %inner_loop, label %next |
| 113 | |
| 114 | next: |
| 115 | %iv.next = add nsw nuw i32 %iv, 1 |
| 116 | %exit.test = icmp slt i32 %iv, %high |
| 117 | br i1 %exit.test, label %exit, label %loop |
| 118 | |
| 119 | exit: |
| 120 | ret i1 false |
| 121 | } |
| 122 | |
Philip Reames | 164b1b4 | 2018-03-20 22:55:20 +0000 | [diff] [blame] | 123 | ; Since all the instructions in the loop dominate the only exit |
| 124 | ; and there's no implicit control flow in the loop, all must execute |
| 125 | ; FIXME: handled by loop safety info, test it |
| 126 | define i1 @nothrow_loop(i32* noalias %p, i32 %high) { |
| 127 | ; CHECK-LABEL: @nothrow_loop( |
Philip Reames | 37a1a29 | 2018-03-20 23:00:54 +0000 | [diff] [blame] | 128 | ; CHECK-LABEL: loop: |
Philip Reames | 164b1b4 | 2018-03-20 22:55:20 +0000 | [diff] [blame] | 129 | ; CHECK: %iv = phi i32 [ 0, %entry ], [ %iv.next, %next ] ; (mustexec in: loop) |
| 130 | ; CHECK: br label %next ; (mustexec in: loop) |
Philip Reames | 37a1a29 | 2018-03-20 23:00:54 +0000 | [diff] [blame] | 131 | ; CHECK-LABEL: next: |
| 132 | ; CHECK: %v = load i32, i32* %p ; (mustexec in: loop) |
| 133 | ; CHECK: %iv.next = add nuw nsw i32 %iv, 1 ; (mustexec in: loop) |
| 134 | ; CHECK: %exit.test = icmp slt i32 %iv, %high ; (mustexec in: loop) |
| 135 | ; CHECK: br i1 %exit.test, label %exit, label %loop ; (mustexec in: loop) |
Philip Reames | 164b1b4 | 2018-03-20 22:55:20 +0000 | [diff] [blame] | 136 | ; CHECK-NOT: mustexec |
| 137 | |
| 138 | entry: |
| 139 | br label %loop |
| 140 | |
| 141 | loop: |
| 142 | %iv = phi i32 [0, %entry], [%iv.next, %next] |
| 143 | br label %next |
| 144 | next: |
| 145 | %v = load i32, i32* %p |
| 146 | %iv.next = add nsw nuw i32 %iv, 1 |
| 147 | %exit.test = icmp slt i32 %iv, %high |
| 148 | br i1 %exit.test, label %exit, label %loop |
| 149 | |
| 150 | exit: |
| 151 | ret i1 false |
| 152 | } |
| 153 | |
Philip Reames | 89f2241 | 2018-03-20 17:09:21 +0000 | [diff] [blame] | 154 | |
| 155 | declare void @maythrow_and_use(i32) |