summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/ruby/test_zjit.rb7
-rw-r--r--zjit/src/hir.rs14
2 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_zjit.rb b/test/ruby/test_zjit.rb
index 9ee1cde35d..b158052ad4 100644
--- a/test/ruby/test_zjit.rb
+++ b/test/ruby/test_zjit.rb
@@ -233,6 +233,13 @@ class TestZJIT < Test::Unit::TestCase
RUBY
end
+ def test_opt_not
+ assert_compiles('[true, true, false]', <<~RUBY, insns: [:opt_not])
+ def test(obj) = !obj
+ return test(nil), test(false), test(0)
+ 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 d6d7cd7a12..f988b629d9 100644
--- a/zjit/src/hir.rs
+++ b/zjit/src/hir.rs
@@ -2379,6 +2379,7 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
YARVINSN_opt_succ |
YARVINSN_opt_and |
YARVINSN_opt_or |
+ YARVINSN_opt_not |
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) };
@@ -3865,6 +3866,19 @@ mod tests {
Return v5
"#]]);
}
+
+ #[test]
+ fn opt_not() {
+ eval("
+ def test(x) = !x
+ ");
+ assert_method_hir_with_opcode("test", YARVINSN_opt_not, expect![[r#"
+ fn test:
+ bb0(v0:BasicObject, v1:BasicObject):
+ v4:BasicObject = SendWithoutBlock v1, :!
+ Return v4
+ "#]]);
+ }
#[test]
fn test_branchnil() {
eval("