diff --git a/test/ruby/test_zjit.rb b/test/ruby/test_zjit.rb index 905ee2f125..9ee1cde35d 100644 --- a/test/ruby/test_zjit.rb +++ b/test/ruby/test_zjit.rb @@ -226,6 +226,13 @@ class TestZJIT < Test::Unit::TestCase RUBY end + def test_opt_or + assert_compiles('[11, [3, 2, 1]]', <<~RUBY, insns: [:opt_or]) + def test(x, y) = x | y + return test(0b1000, 3), test([3, 2, 1], [1, 2, 3]) + RUBY + end + def test_opt_ge assert_compiles '[false, true, true]', %q{ def test(a, b) = a >= b diff --git a/zjit/src/hir.rs b/zjit/src/hir.rs index 2c32c83aa6..d6d7cd7a12 100644 --- a/zjit/src/hir.rs +++ b/zjit/src/hir.rs @@ -2378,6 +2378,7 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result { YARVINSN_opt_empty_p | YARVINSN_opt_succ | YARVINSN_opt_and | + YARVINSN_opt_or | YARVINSN_opt_send_without_block => { let cd: *const rb_call_data = get_arg(pc, 0).as_ptr(); let call_info = unsafe { rb_get_call_data_ci(cd) }; @@ -3851,6 +3852,19 @@ mod tests { Return v5 "#]]); } + + #[test] + fn opt_or() { + eval(" + def test(x, y) = x | y + "); + assert_method_hir_with_opcode("test", YARVINSN_opt_or, expect![[r#" + fn test: + bb0(v0:BasicObject, v1:BasicObject, v2:BasicObject): + v5:BasicObject = SendWithoutBlock v1, :|, v2 + Return v5 + "#]]); + } #[test] fn test_branchnil() { eval("