Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions compiler/rustc_codegen_ssa/src/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use rustc_abi::{
};
use rustc_ast as ast;
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_data_structures::packed::Pu128;
use rustc_hir::attrs::AttributeKind;
use rustc_hir::attrs::lang_items::LangItem;
use rustc_lint_defs::builtin::TAIL_CALL_TRACK_CALLER;
Expand Down Expand Up @@ -454,39 +453,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
let cmp = bx.icmp(IntPredicate::IntEQ, discr_value, llval);
bx.cond_br_with_expect(cmp, lltarget, llotherwise, expect);
}
} else if target_iter.len() == 2
&& self.mir[targets.otherwise()].is_empty_unreachable()
&& targets.all_values().contains(&Pu128(0))
&& targets.all_values().contains(&Pu128(1))
{
// This is the really common case for `bool`, `Option`, etc.
// By using `trunc nuw` we communicate that other values are
// impossible without needing `switch` or `assume`s.
let true_bb = targets.target_for_value(1);
let false_bb = targets.target_for_value(0);
let true_ll = helper.llbb_with_cleanup(self, true_bb);
let false_ll = helper.llbb_with_cleanup(self, false_bb);

let expected_cond_value = if self.cx.sess().opts.optimize == OptLevel::No {
None
} else {
match (self.cold_blocks[true_bb], self.cold_blocks[false_bb]) {
// Same coldness, no expectation
(true, true) | (false, false) => None,
// Different coldness, expect the non-cold one
(true, false) => Some(false),
(false, true) => Some(true),
}
};

let bool_ty = bx.tcx().types.bool;
let cond = if switch_ty == bool_ty {
discr_value
} else {
let bool_llty = bx.immediate_backend_type(bx.layout_of(bool_ty));
bx.unchecked_utrunc(discr_value, bool_llty)
};
bx.cond_br_with_expect(cond, true_ll, false_ll, expected_cond_value);
} else if self.cx.sess().opts.optimize == OptLevel::No
&& target_iter.len() == 2
&& self.mir[targets.otherwise()].is_empty_unreachable()
Expand Down
130 changes: 0 additions & 130 deletions tests/codegen-llvm/enum/enum-two-variants-match.rs

This file was deleted.

Loading
Loading