ruby-changes:73228
From: Maxime <ko1@a...>
Date: Tue, 30 Aug 2022 01:03:17 +0900 (JST)
Subject: [ruby-changes:73228] 2d9b98f9bc (master): Fix a bug in the x86 backend wrt large integer values, enable more tests
https://git.ruby-lang.org/ruby.git/commit/?id=2d9b98f9bc From 2d9b98f9bc918b1161d308c5d202fcb3be01de07 Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...> Date: Mon, 25 Jul 2022 15:22:25 -0400 Subject: Fix a bug in the x86 backend wrt large integer values, enable more tests --- yjit/src/backend/x86_64/mod.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/yjit/src/backend/x86_64/mod.rs b/yjit/src/backend/x86_64/mod.rs index 5bae5c7f29..c1bcdca3e7 100644 --- a/yjit/src/backend/x86_64/mod.rs +++ b/yjit/src/backend/x86_64/mod.rs @@ -2,7 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/x86_64/mod.rs#L2 #![allow(unused_variables)] #![allow(unused_imports)] -use crate::asm::{uimm_num_bits, CodeBlock}; +use crate::asm::*; use crate::asm::x86_64::*; use crate::codegen::{JITState}; use crate::cruby::*; @@ -119,7 +119,15 @@ impl Assembler https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/x86_64/mod.rs#L119 (asm.load(opnds[0]), asm.load(opnds[1])) }, (Opnd::Mem(_), Opnd::UImm(value)) => { - if uimm_num_bits(value) > 32 { + // 32-bit values will be sign-extended + if imm_num_bits(value as i64) > 32 { + (asm.load(opnds[0]), asm.load(opnds[1])) + } else { + (asm.load(opnds[0]), opnds[1]) + } + }, + (Opnd::Mem(_), Opnd::Imm(value)) => { + if imm_num_bits(value) > 32 { (asm.load(opnds[0]), asm.load(opnds[1])) } else { (asm.load(opnds[0]), opnds[1]) @@ -161,7 +169,16 @@ impl Assembler https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/x86_64/mod.rs#L169 asm.mov(opnds[0], opnd1); }, (Opnd::Mem(_), Opnd::UImm(value)) => { - if uimm_num_bits(value) > 32 { + // 32-bit values will be sign-extended + if imm_num_bits(value as i64) > 32 { + let opnd1 = asm.load(opnds[1]); + asm.mov(opnds[0], opnd1); + } else { + asm.mov(opnds[0], opnds[1]); + } + }, + (Opnd::Mem(_), Opnd::Imm(value)) => { + if imm_num_bits(value) > 32 { let opnd1 = asm.load(opnds[1]); asm.mov(opnds[0], opnd1); } else { -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/