|
| 1 | +; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=simplify-conditionals-false --test FileCheck --test-arg --check-prefixes=INTERESTING --test-arg %s --test-arg --input-file %s -o %t |
| 2 | +; RUN: FileCheck -check-prefixes=RESULT-FALSE,CHECK %s < %t |
| 3 | + |
| 4 | +; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=simplify-conditionals-true --test FileCheck --test-arg --check-prefixes=INTERESTING --test-arg %s --test-arg --input-file %s -o %t |
| 5 | +; RUN: FileCheck -check-prefixes=RESULT-TRUE,CHECK %s < %t |
| 6 | + |
| 7 | +; Check that simplify-conditionals-true/false do not attempt block |
| 8 | +; simplification in cases that happened to already use a constant |
| 9 | +; true/false branch. We should not get the side effect of running |
| 10 | +; simplifycfg on blocks where we did not change the terminator value, |
| 11 | +; and not introduce unreachable code. |
| 12 | + |
| 13 | + |
| 14 | +; CHECK-LABEL: @br_false( |
| 15 | +; RESULT-FALSE: br i1 false, label %will_be_unreachable, label %exit |
| 16 | +; RESULT-TRUE: br label %will_be_unreachable |
| 17 | +define i1 @br_false(i64 %int) { |
| 18 | +entry: |
| 19 | + %i2p = inttoptr i64 %int to ptr |
| 20 | + br i1 false, label %will_be_unreachable, label %exit |
| 21 | + |
| 22 | +will_be_unreachable: |
| 23 | + %load = load ptr, ptr %i2p, align 8 |
| 24 | + br label %for.body |
| 25 | + |
| 26 | +for.body: |
| 27 | + br label %for.body |
| 28 | + |
| 29 | +exit: |
| 30 | + ret i1 false |
| 31 | +} |
| 32 | + |
| 33 | +; CHECK-LABEL: @br_false_keep_in_unreachable( |
| 34 | +; CHECK: entry |
| 35 | +; INTERESTING: [[I2P:%.+]] = inttoptr i64 %int to ptr |
| 36 | +; INTERESTING: load ptr, ptr [[I2P]] |
| 37 | + |
| 38 | +; RESULT-FALSE: br i1 false, label %will_be_unreachable, label %exit |
| 39 | +; RESULT-TRUE: br label %will_be_unreachable |
| 40 | +define i1 @br_false_keep_in_unreachable(i64 %int) { |
| 41 | +entry: |
| 42 | + br i1 false, label %will_be_unreachable, label %exit |
| 43 | + |
| 44 | +will_be_unreachable: |
| 45 | + %i2p = inttoptr i64 %int to ptr |
| 46 | + %load = load ptr, ptr %i2p, align 8 |
| 47 | + br label %for.body |
| 48 | + |
| 49 | +for.body: |
| 50 | + br label %for.body |
| 51 | + |
| 52 | +exit: |
| 53 | + ret i1 false |
| 54 | +} |
| 55 | + |
| 56 | +; CHECK-LABEL: @br_true( |
| 57 | + |
| 58 | +; RESULT-FALSE: br label %will_be_unreachable |
| 59 | +; RESULT-TRUE: br i1 true, label %exit, label %will_be_unreachable |
| 60 | +define i1 @br_true(i64 %int) { |
| 61 | +entry: |
| 62 | + %i2p = inttoptr i64 %int to ptr |
| 63 | + br i1 true, label %exit, label %will_be_unreachable |
| 64 | + |
| 65 | +will_be_unreachable: |
| 66 | + %load = load ptr, ptr %i2p, align 8 |
| 67 | + br label %for.body |
| 68 | + |
| 69 | +for.body: |
| 70 | + br label %for.body |
| 71 | + |
| 72 | +exit: |
| 73 | + ret i1 false |
| 74 | +} |
| 75 | + |
| 76 | +; CHECK-LABEL: @br_true_keep_in_unreachable( |
| 77 | +; CHECK: entry: |
| 78 | +; INTERESTING: [[I2P:%.+]] = inttoptr i64 %int to ptr |
| 79 | +; INTERESTING: load ptr, ptr [[I2P]] |
| 80 | + |
| 81 | +; RESULT-FALSE: br label %will_be_unreachable |
| 82 | +; RESULT-TRUE: br i1 true, label %exit, label %will_be_unreachable |
| 83 | +define i1 @br_true_keep_in_unreachable(i64 %int) { |
| 84 | +entry: |
| 85 | + %i2p = inttoptr i64 %int to ptr |
| 86 | + br i1 true, label %exit, label %will_be_unreachable |
| 87 | + |
| 88 | +will_be_unreachable: |
| 89 | + %load = load ptr, ptr %i2p, align 8 |
| 90 | + br label %for.body |
| 91 | + |
| 92 | +for.body: |
| 93 | + br label %for.body |
| 94 | + |
| 95 | +exit: |
| 96 | + ret i1 false |
| 97 | +} |
| 98 | + |
| 99 | +; CHECK-LABEL: @br_poison( |
| 100 | +; RESULT-FALSE: br label %will_be_unreachable |
| 101 | +; RESULT-TRUE: br label %exit |
| 102 | +define i1 @br_poison(i64 %int) { |
| 103 | +entry: |
| 104 | + %i2p = inttoptr i64 %int to ptr |
| 105 | + br i1 poison, label %exit, label %will_be_unreachable |
| 106 | + |
| 107 | +will_be_unreachable: |
| 108 | + %load = load ptr, ptr %i2p, align 8 |
| 109 | + br label %for.body |
| 110 | + |
| 111 | +for.body: |
| 112 | + br label %for.body |
| 113 | + |
| 114 | +exit: |
| 115 | + ret i1 false |
| 116 | +} |
| 117 | + |
| 118 | +; CHECK-LABEL: @br_poison_keep_in_unreachable( |
| 119 | +; CHECK: entry: |
| 120 | +; INTERESTING: [[I2P:%.+]] = inttoptr i64 %int to ptr |
| 121 | +; INTERESTING: load ptr, ptr [[I2P]] |
| 122 | + |
| 123 | +; RESULT-FALSE: br label %will_be_unreachable |
| 124 | +; RESULT-TRUE: br label %exit |
| 125 | +define i1 @br_poison_keep_in_unreachable(i64 %int) { |
| 126 | +entry: |
| 127 | + %i2p = inttoptr i64 %int to ptr |
| 128 | + br i1 poison, label %exit, label %will_be_unreachable |
| 129 | + |
| 130 | +will_be_unreachable: |
| 131 | + %load = load ptr, ptr %i2p, align 8 |
| 132 | + br label %for.body |
| 133 | + |
| 134 | +for.body: |
| 135 | + br label %for.body |
| 136 | + |
| 137 | +exit: |
| 138 | + ret i1 false |
| 139 | +} |
0 commit comments