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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
; 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
; RUN: FileCheck --check-prefixes=RESULT-TRUE,RESULT,CHECK %s < %t
; 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
; RUN: FileCheck --check-prefixes=RESULT-FALSE,RESULT,CHECK %s < %t
; Make sure there is no unreachable code introduced by the reduction
; CHECK-LABEL: @func_simplifies_true(
; CHECK-INTERESTINGNESS: store i32 1,
; RESULT-TRUE: bb0:
; RESULT-TRUE: store i32 0, ptr null, align 4
; RESULT-TRUE-NEXT: store i32 1, ptr null, align 4
; RESULT-TRUE-NEXT: br label %bb2
; RESULT-TRUE-NOT: bb1
; RESULT-FALSE: bb0:
; RESULT-FALSE-NEXT: store i32 0, ptr null, align 4
; RESULT-FALSE-NEXT: br i1 %cond0, label %bb1, label %bb2
; RESULT-FALSE: bb1: ; preds = %bb0
; RESULT-FALSE-NEXT: store i32 1, ptr null, align 4
; RESULT-FALSE-NEXT: br label %bb3
; RESULT-FALSE: bb2: ; preds = %bb0
; RESULT-FALSE-NEXT: store i32 2, ptr null, align 4
; RESULT-FALSE-NEXT: br label %bb3
; RESULT-FALSE: bb3: ; preds = %bb1, %bb2
; RESULT-FALSE-NEXT: ret void
define void @func_simplifies_true(i1 %cond0, i1 %cond1) {
bb0:
store i32 0, ptr null
br i1 %cond0, label %bb1, label %bb2
bb1:
store i32 1, ptr null
br i1 %cond1, label %bb2, label %bb3
bb2:
store i32 2, ptr null
br label %bb3
bb3:
ret void
}
; CHECK-LABEL: @func_simplifies_false(
; CHECK-INTERESTINGNESS: store i32 0,
; RESULT-TRUE: bb0:
; RESULT-TRUE: store i32 0, ptr null, align 4
; RESULT-TRUE-NEXT: store i32 1, ptr null, align 4
; RESULT-TRUE-NEXT: br label %bb2
; RESULT-TRUE-NOT: bb1
; RESULT-FALSE: bb0:
; RESULT-FALSE: store i32 0, ptr null, align 4
; RESULT-FALSE-NEXT: br label %bb2
; RESULT-FALSE: bb2: ; preds = %bb0
; RESULT-FALSE-NEXT: store i32 2, ptr null, align 4
; RESULT-FALSE-NEXT: br label %bb3
; RESULT-FALSE: bb3: ; preds = %bb2
; RESULT-FALSE-NEXT: ret void
define void @func_simplifies_false(i1 %cond0, i1 %cond1) {
bb0:
store i32 0, ptr null
br i1 %cond0, label %bb1, label %bb2
bb1:
store i32 1, ptr null
br i1 %cond1, label %bb2, label %bb3
bb2:
store i32 2, ptr null
br label %bb3
bb3:
ret void
}
; Make sure we don't break the reduction in the other functions by
; having something interesting in unrelated unreachable code.
; CHECK-LABEL: @func_simplifies_true_with_interesting_unreachable_code(
; CHECK-INTERESTINGNESS: store i32 0,
; CHECK-INTERESTINGNESS: store i32 %arg,
; RESULT: bb0:
; RESULT-NEXT: store i32 0
; RESULT-NEXT: br i1 %cond0, label %bb1, label %bb2
; RESULT: bb1:
; RESULT-NEXT: store i32 1
; RESULT-NEXT: br i1 %cond1, label %bb2, label %bb3
; RESULT: bb2:
; RESULT-NEXT: store i32 2
; RESULT-NEXT: br label %bb3
; RESULT: dead_code: ; preds = %dead_code
; RESULT-NEXT: store i32 %arg,
; RESULT-NEXT: br label %dead_code
define void @func_simplifies_true_with_interesting_unreachable_code(i1 %cond0, i1 %cond1, i32 %arg) {
bb0:
store i32 0, ptr null
br i1 %cond0, label %bb1, label %bb2
bb1:
store i32 1, ptr null
br i1 %cond1, label %bb2, label %bb3
bb2:
store i32 2, ptr null
br label %bb3
bb3:
ret void
dead_code:
store i32 %arg, ptr null
br label %dead_code
}
@block_address_user = constant [1 x ptr] [ptr blockaddress(@will_be_unreachable_blockaddress_use, %will_be_unreachable)]
; CHECK-LABEL: @will_be_unreachable_blockaddress_use(
; CHECK-INTERESTINGNESS: inttoptr
; RESULT-FALSE: entry:
; RESULT-FALSE-NEXT: %i2p = inttoptr i64 %int to ptr
; RESULT-FALSE-NEXT: br label %exit
; RESULT-FALSE: exit: ; preds = %entry
; RESULT-FALSE-NEXT: ret i1 false
define i1 @will_be_unreachable_blockaddress_use(i1 %cond, i64 %int) {
entry:
%i2p = inttoptr i64 %int to ptr
br i1 %cond, 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
}
|