140 lines · plain
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 %t2; RUN: FileCheck -check-prefixes=RESULT-FALSE,CHECK %s < %t3 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 %t5; RUN: FileCheck -check-prefixes=RESULT-TRUE,CHECK %s < %t6 7; Check that simplify-conditionals-true/false do not attempt block8; simplification in cases that happened to already use a constant9; true/false branch. We should not get the side effect of running10; 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 %exit16; RESULT-TRUE: br label %will_be_unreachable17define i1 @br_false(i64 %int) {18entry:19 %i2p = inttoptr i64 %int to ptr20 br i1 false, label %will_be_unreachable, label %exit21 22will_be_unreachable:23 %load = load ptr, ptr %i2p, align 824 br label %for.body25 26for.body:27 br label %for.body28 29exit:30 ret i1 false31}32 33; CHECK-LABEL: @br_false_keep_in_unreachable(34; CHECK: entry35; INTERESTING: [[I2P:%.+]] = inttoptr i64 %int to ptr36; INTERESTING: load ptr, ptr [[I2P]]37 38; RESULT-FALSE: br i1 false, label %will_be_unreachable, label %exit39; RESULT-TRUE: br label %will_be_unreachable40define i1 @br_false_keep_in_unreachable(i64 %int) {41entry:42 br i1 false, label %will_be_unreachable, label %exit43 44will_be_unreachable:45 %i2p = inttoptr i64 %int to ptr46 %load = load ptr, ptr %i2p, align 847 br label %for.body48 49for.body:50 br label %for.body51 52exit:53 ret i1 false54}55 56; CHECK-LABEL: @br_true(57 58; RESULT-FALSE: br label %will_be_unreachable59; RESULT-TRUE: br i1 true, label %exit, label %will_be_unreachable60define i1 @br_true(i64 %int) {61entry:62 %i2p = inttoptr i64 %int to ptr63 br i1 true, label %exit, label %will_be_unreachable64 65will_be_unreachable:66 %load = load ptr, ptr %i2p, align 867 br label %for.body68 69for.body:70 br label %for.body71 72exit:73 ret i1 false74}75 76; CHECK-LABEL: @br_true_keep_in_unreachable(77; CHECK: entry:78; INTERESTING: [[I2P:%.+]] = inttoptr i64 %int to ptr79; INTERESTING: load ptr, ptr [[I2P]]80 81; RESULT-FALSE: br label %will_be_unreachable82; RESULT-TRUE: br i1 true, label %exit, label %will_be_unreachable83define i1 @br_true_keep_in_unreachable(i64 %int) {84entry:85 %i2p = inttoptr i64 %int to ptr86 br i1 true, label %exit, label %will_be_unreachable87 88will_be_unreachable:89 %load = load ptr, ptr %i2p, align 890 br label %for.body91 92for.body:93 br label %for.body94 95exit:96 ret i1 false97}98 99; CHECK-LABEL: @br_poison(100; RESULT-FALSE: br label %will_be_unreachable101; RESULT-TRUE: br label %exit102define i1 @br_poison(i64 %int) {103entry:104 %i2p = inttoptr i64 %int to ptr105 br i1 poison, label %exit, label %will_be_unreachable106 107will_be_unreachable:108 %load = load ptr, ptr %i2p, align 8109 br label %for.body110 111for.body:112 br label %for.body113 114exit:115 ret i1 false116}117 118; CHECK-LABEL: @br_poison_keep_in_unreachable(119; CHECK: entry:120; INTERESTING: [[I2P:%.+]] = inttoptr i64 %int to ptr121; INTERESTING: load ptr, ptr [[I2P]]122 123; RESULT-FALSE: br label %will_be_unreachable124; RESULT-TRUE: br label %exit125define i1 @br_poison_keep_in_unreachable(i64 %int) {126entry:127 %i2p = inttoptr i64 %int to ptr128 br i1 poison, label %exit, label %will_be_unreachable129 130will_be_unreachable:131 %load = load ptr, ptr %i2p, align 8132 br label %for.body133 134for.body:135 br label %for.body136 137exit:138 ret i1 false139}140