|
1 |
| -; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=simplify-conditionals-true --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t |
2 |
| -; RUN: FileCheck --check-prefixes=RESULT-TRUE %s < %t |
| 1 | +; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=simplify-conditionals-true --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS,CHECK --test-arg %s --test-arg --input-file %s -o %t |
| 2 | +; RUN: FileCheck --check-prefixes=RESULT-TRUE,RESULT,CHECK %s < %t |
3 | 3 |
|
4 |
| -; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=simplify-conditionals-false --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t |
5 |
| -; RUN: FileCheck --check-prefixes=RESULT-FALSE %s < %t |
| 4 | +; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=simplify-conditionals-false --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS,CHECK --test-arg %s --test-arg --input-file %s -o %t |
| 5 | +; RUN: FileCheck --check-prefixes=RESULT-FALSE,RESULT,CHECK %s < %t |
6 | 6 |
|
7 |
| -; CHECK-INTERESTINGNESS-LABEL: @func( |
| 7 | +; Make sure there is no unreachable code introduced by the reduction |
| 8 | + |
| 9 | +; CHECK-LABEL: @func_simplifies_true( |
8 | 10 | ; CHECK-INTERESTINGNESS: store i32 1,
|
9 | 11 |
|
10 | 12 | ; RESULT-TRUE: bb0:
|
|
13 | 15 | ; RESULT-TRUE-NEXT: br label %bb2
|
14 | 16 | ; RESULT-TRUE-NOT: bb1
|
15 | 17 |
|
| 18 | +; RESULT-FALSE: bb0: |
| 19 | +; RESULT-FALSE-NEXT: store i32 0, ptr null, align 4 |
| 20 | +; RESULT-FALSE-NEXT: br i1 %cond0, label %bb1, label %bb2 |
| 21 | + |
| 22 | +; RESULT-FALSE: bb1: ; preds = %bb0 |
| 23 | +; RESULT-FALSE-NEXT: store i32 1, ptr null, align 4 |
| 24 | +; RESULT-FALSE-NEXT: br label %bb3 |
| 25 | + |
| 26 | +; RESULT-FALSE: bb2: ; preds = %bb0 |
| 27 | +; RESULT-FALSE-NEXT: store i32 2, ptr null, align 4 |
| 28 | +; RESULT-FALSE-NEXT: br label %bb3 |
| 29 | + |
| 30 | +; RESULT-FALSE: bb3: ; preds = %bb1, %bb2 |
| 31 | +; RESULT-FALSE-NEXT: ret void |
| 32 | +define void @func_simplifies_true(i1 %cond0, i1 %cond1) { |
| 33 | +bb0: |
| 34 | + store i32 0, ptr null |
| 35 | + br i1 %cond0, label %bb1, label %bb2 |
| 36 | + |
| 37 | +bb1: |
| 38 | + store i32 1, ptr null |
| 39 | + br i1 %cond1, label %bb2, label %bb3 |
| 40 | + |
| 41 | +bb2: |
| 42 | + store i32 2, ptr null |
| 43 | + br label %bb3 |
| 44 | + |
| 45 | +bb3: |
| 46 | + ret void |
| 47 | +} |
| 48 | + |
| 49 | +; CHECK-LABEL: @func_simplifies_false( |
| 50 | +; CHECK-INTERESTINGNESS: store i32 0, |
| 51 | + |
| 52 | +; RESULT-TRUE: bb0: |
| 53 | +; RESULT-TRUE: store i32 0, ptr null, align 4 |
| 54 | +; RESULT-TRUE-NEXT: store i32 1, ptr null, align 4 |
| 55 | +; RESULT-TRUE-NEXT: br label %bb2 |
| 56 | +; RESULT-TRUE-NOT: bb1 |
| 57 | + |
16 | 58 |
|
17 | 59 | ; RESULT-FALSE: bb0:
|
18 | 60 | ; RESULT-FALSE: store i32 0, ptr null, align 4
|
19 | 61 | ; RESULT-FALSE-NEXT: br label %bb2
|
20 | 62 |
|
21 |
| -; RESULT-FALSE: bb1: ; No predecessors! |
22 |
| -; RESULT-FALSE-NEXT: store i32 1, ptr null, align 4 |
| 63 | +; RESULT-FALSE: bb2: ; preds = %bb0 |
| 64 | +; RESULT-FALSE-NEXT: store i32 2, ptr null, align 4 |
23 | 65 | ; RESULT-FALSE-NEXT: br label %bb3
|
24 |
| -define void @func(i1 %cond0, i1 %cond1) { |
| 66 | + |
| 67 | +; RESULT-FALSE: bb3: ; preds = %bb2 |
| 68 | +; RESULT-FALSE-NEXT: ret void |
| 69 | +define void @func_simplifies_false(i1 %cond0, i1 %cond1) { |
| 70 | +bb0: |
| 71 | + store i32 0, ptr null |
| 72 | + br i1 %cond0, label %bb1, label %bb2 |
| 73 | + |
| 74 | +bb1: |
| 75 | + store i32 1, ptr null |
| 76 | + br i1 %cond1, label %bb2, label %bb3 |
| 77 | + |
| 78 | +bb2: |
| 79 | + store i32 2, ptr null |
| 80 | + br label %bb3 |
| 81 | + |
| 82 | +bb3: |
| 83 | + ret void |
| 84 | +} |
| 85 | + |
| 86 | +; Make sure we don't break the reduction in the other functions by |
| 87 | +; having something interesting in unrelated unreachable code. |
| 88 | + |
| 89 | +; CHECK-LABEL: @func_simplifies_true_with_interesting_unreachable_code( |
| 90 | +; CHECK-INTERESTINGNESS: store i32 0, |
| 91 | +; CHECK-INTERESTINGNESS: store i32 %arg, |
| 92 | + |
| 93 | + |
| 94 | +; RESULT: bb0: |
| 95 | +; RESULT-NEXT: store i32 0 |
| 96 | +; RESULT-NEXT: br i1 %cond0, label %bb1, label %bb2 |
| 97 | + |
| 98 | +; RESULT: bb1: |
| 99 | +; RESULT-NEXT: store i32 1 |
| 100 | +; RESULT-NEXT: br i1 %cond1, label %bb2, label %bb3 |
| 101 | + |
| 102 | +; RESULT: bb2: |
| 103 | +; RESULT-NEXT: store i32 2 |
| 104 | +; RESULT-NEXT: br label %bb3 |
| 105 | + |
| 106 | +; RESULT: dead_code: ; preds = %dead_code |
| 107 | +; RESULT-NEXT: store i32 %arg, |
| 108 | +; RESULT-NEXT: br label %dead_code |
| 109 | +define void @func_simplifies_true_with_interesting_unreachable_code(i1 %cond0, i1 %cond1, i32 %arg) { |
25 | 110 | bb0:
|
26 | 111 | store i32 0, ptr null
|
27 | 112 | br i1 %cond0, label %bb1, label %bb2
|
|
36 | 121 |
|
37 | 122 | bb3:
|
38 | 123 | ret void
|
| 124 | + |
| 125 | +dead_code: |
| 126 | + store i32 %arg, ptr null |
| 127 | + br label %dead_code |
| 128 | +} |
| 129 | + |
| 130 | +@block_address_user = constant [1 x ptr] [ptr blockaddress(@will_be_unreachable_blockaddress_use, %will_be_unreachable)] |
| 131 | + |
| 132 | +; CHECK-LABEL: @will_be_unreachable_blockaddress_use( |
| 133 | +; CHECK-INTERESTINGNESS: inttoptr |
| 134 | + |
| 135 | +; RESULT-FALSE: entry: |
| 136 | +; RESULT-FALSE-NEXT: %i2p = inttoptr i64 %int to ptr |
| 137 | +; RESULT-FALSE-NEXT: br label %exit |
| 138 | + |
| 139 | +; RESULT-FALSE: exit: ; preds = %entry |
| 140 | +; RESULT-FALSE-NEXT: ret i1 false |
| 141 | +define i1 @will_be_unreachable_blockaddress_use(i1 %cond, i64 %int) { |
| 142 | +entry: |
| 143 | + %i2p = inttoptr i64 %int to ptr |
| 144 | + br i1 %cond, label %will_be_unreachable, label %exit |
| 145 | + |
| 146 | +will_be_unreachable: |
| 147 | + %load = load ptr, ptr %i2p, align 8 |
| 148 | + br label %for.body |
| 149 | + |
| 150 | +for.body: |
| 151 | + br label %for.body |
| 152 | + |
| 153 | +exit: |
| 154 | + ret i1 false |
39 | 155 | }
|
0 commit comments