diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2021-08-06 16:26:56 +0200 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2021-08-06 16:26:56 +0200 |
| commit | 279f486960edc43246ea413970f587a82365cca7 (patch) | |
| tree | a15483e6de5d0c1c26b7a5d8839400f673f8b69a /compiler/rustc_codegen_cranelift/src/optimize | |
| parent | 1f94abcda6884893d4723304102089198caa0839 (diff) | |
| parent | 05677b6bd6c938ed760835d9b1f6514992654ae3 (diff) | |
| download | rust-279f486960edc43246ea413970f587a82365cca7.tar.gz rust-279f486960edc43246ea413970f587a82365cca7.zip | |
Merge commit '05677b6bd6c938ed760835d9b1f6514992654ae3' into sync_cg_clif-2021-08-06
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src/optimize')
| -rw-r--r-- | compiler/rustc_codegen_cranelift/src/optimize/peephole.rs | 41 |
1 files changed, 1 insertions, 40 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/optimize/peephole.rs b/compiler/rustc_codegen_cranelift/src/optimize/peephole.rs index b95e2d72877..d637b4d8929 100644 --- a/compiler/rustc_codegen_cranelift/src/optimize/peephole.rs +++ b/compiler/rustc_codegen_cranelift/src/optimize/peephole.rs @@ -1,8 +1,6 @@ //! Peephole optimizations that can be performed while creating clif ir. -use cranelift_codegen::ir::{ - condcodes::IntCC, types, InstBuilder, InstructionData, Opcode, Value, ValueDef, -}; +use cranelift_codegen::ir::{condcodes::IntCC, InstructionData, Opcode, Value, ValueDef}; use cranelift_frontend::FunctionBuilder; /// If the given value was produced by a `bint` instruction, return it's input, otherwise return the @@ -37,43 +35,6 @@ pub(crate) fn maybe_unwrap_bool_not(bcx: &mut FunctionBuilder<'_>, arg: Value) - } } -pub(crate) fn make_branchable_value(bcx: &mut FunctionBuilder<'_>, arg: Value) -> Value { - if bcx.func.dfg.value_type(arg).is_bool() { - return arg; - } - - (|| { - let arg_inst = if let ValueDef::Result(arg_inst, 0) = bcx.func.dfg.value_def(arg) { - arg_inst - } else { - return None; - }; - - match bcx.func.dfg[arg_inst] { - // This is the lowering of Rvalue::Not - InstructionData::Load { opcode: Opcode::Load, arg: ptr, flags, offset } => { - // Using `load.i8 + uextend.i32` would legalize to `uload8 + ireduce.i8 + - // uextend.i32`. Just `uload8` is much faster. - match bcx.func.dfg.ctrl_typevar(arg_inst) { - types::I8 => Some(bcx.ins().uload8(types::I32, flags, ptr, offset)), - types::I16 => Some(bcx.ins().uload16(types::I32, flags, ptr, offset)), - _ => None, - } - } - _ => None, - } - })() - .unwrap_or_else(|| { - match bcx.func.dfg.value_type(arg) { - types::I8 | types::I16 => { - // WORKAROUND for brz.i8 and brnz.i8 not yet being implemented - bcx.ins().uextend(types::I32, arg) - } - _ => arg, - } - }) -} - /// Returns whether the branch is statically known to be taken or `None` if it isn't statically known. pub(crate) fn maybe_known_branch_taken( bcx: &FunctionBuilder<'_>, |
