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