From d6da54081cee3610de28ee2660747aaba2e9319f Mon Sep 17 00:00:00 2001 From: Robin Freyler Date: Fri, 24 Nov 2023 19:07:10 +0100 Subject: [PATCH] add tests --- .../src/engine/regmach/tests/op/cmp_br.rs | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/crates/wasmi/src/engine/regmach/tests/op/cmp_br.rs b/crates/wasmi/src/engine/regmach/tests/op/cmp_br.rs index 5c5f4255fa..32bd3d429d 100644 --- a/crates/wasmi/src/engine/regmach/tests/op/cmp_br.rs +++ b/crates/wasmi/src/engine/regmach/tests/op/cmp_br.rs @@ -522,3 +522,53 @@ fn if_i32_eqz_fuse() { test_for("or", Instruction::branch_i32_or); test_for("xor", Instruction::branch_i32_xor); } + +#[test] +#[cfg_attr(miri, ignore)] +fn block_i64_eqz_fuse() { + let wasm = wat2wasm(&format!( + r" + (module + (func (param i64) + (block + (i64.eqz (local.get 0)) + (br_if 0) + ) + ) + )", + )); + TranslationTest::new(wasm) + .expect_func_instrs([ + Instruction::branch_i64_eqz( + Register::from_i16(0), + BranchOffset::from(1), + ), + Instruction::Return, + ]) + .run() +} + +#[test] +#[cfg_attr(miri, ignore)] +fn if_i64_eqz_fuse() { + let wasm = wat2wasm(&format!( + r" + (module + (func (param i64) + (if + (i64.eqz (local.get 0)) + (then) + ) + ) + )", + )); + TranslationTest::new(wasm) + .expect_func_instrs([ + Instruction::branch_i64_nez( + Register::from_i16(0), + BranchOffset::from(1), + ), + Instruction::Return, + ]) + .run() +}