diff --git a/cranelift/codegen/src/peepmatic.rs b/cranelift/codegen/src/peepmatic.rs index 1e22019407..2c6c2d1e01 100644 --- a/cranelift/codegen/src/peepmatic.rs +++ b/cranelift/codegen/src/peepmatic.rs @@ -237,6 +237,7 @@ impl Opcode { BandImm, Bconst, Bint, + Bnot, Bor, BorImm, Brnz, @@ -549,6 +550,11 @@ unsafe impl<'a, 'b> InstructionSet<'b> for &'a dyn TargetIsa { let val = pos.ins().bint(ty, a); pos.func.dfg.value_def(val).unwrap_inst().into() } + Operator::Bnot => { + let a = part_to_value(pos, root, a).unwrap(); + let val = pos.ins().bnot(a); + pos.func.dfg.value_def(val).unwrap_inst().into() + } Operator::Brnz => { let a = part_to_value(pos, root, a).unwrap(); diff --git a/cranelift/codegen/src/preopt.peepmatic b/cranelift/codegen/src/preopt.peepmatic index cd988ff7d9..8f2651fc21 100644 --- a/cranelift/codegen/src/preopt.peepmatic +++ b/cranelift/codegen/src/preopt.peepmatic @@ -112,6 +112,7 @@ ;; Replace with negative 1. (=> (bor_imm -1 $x) -1) +(=> (bxor_imm -1 $x) (bnot $x)) ;; Transform `[(x << N) >> N]` into a (un)signed-extending move. ;; diff --git a/cranelift/codegen/src/preopt.serialized b/cranelift/codegen/src/preopt.serialized index 1bb11b24ad..896c3ac8d7 100644 Binary files a/cranelift/codegen/src/preopt.serialized and b/cranelift/codegen/src/preopt.serialized differ diff --git a/cranelift/peepmatic/crates/runtime/src/operator.rs b/cranelift/peepmatic/crates/runtime/src/operator.rs index 2915f36290..8e03e8b8ec 100644 --- a/cranelift/peepmatic/crates/runtime/src/operator.rs +++ b/cranelift/peepmatic/crates/runtime/src/operator.rs @@ -45,6 +45,10 @@ pub enum Operator { #[peepmatic(params(bNN), result(iNN))] Bint, + /// `bnot` + #[peepmatic(params(iNN), result(iNN))] + Bnot, + /// `bor` #[peepmatic(params(iNN, iNN), result(iNN))] Bor,