diff options
author | Jimmy Miller <jimmy.miller@shopify.com> | 2022-10-03 16:57:27 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-03 16:57:27 -0400 |
commit | efc77662440bd7d31381f7e62fbd813c38d6c64c (patch) | |
tree | f7da79db4a70579b7c0daeebd79238c8e7d02e50 /yjit | |
parent | cbd82f52502630e5298c8b82e8d52c59ee5454e1 (diff) | |
download | ruby-efc77662440bd7d31381f7e62fbd813c38d6c64c.tar.gz |
Split cmp operations that aren't 32/64 bit for arm (#6484)
Diffstat (limited to 'yjit')
-rw-r--r-- | yjit/src/backend/arm64/mod.rs | 15 | ||||
-rw-r--r-- | yjit/src/backend/tests.rs | 9 |
2 files changed, 24 insertions, 0 deletions
diff --git a/yjit/src/backend/arm64/mod.rs b/yjit/src/backend/arm64/mod.rs index 79dff530d1..692e4371e2 100644 --- a/yjit/src/backend/arm64/mod.rs +++ b/yjit/src/backend/arm64/mod.rs @@ -234,6 +234,20 @@ impl Assembler (opnd0, opnd1) } + fn split_less_than_32_cmp(asm: &mut Assembler, opnd0: Opnd) -> Opnd { + match opnd0 { + Opnd::Reg(_) | Opnd::InsnOut { .. } => { + match opnd0.rm_num_bits() { + 8 => asm.and(opnd0.with_num_bits(64).unwrap(), Opnd::UImm(0xff)), + 16 => asm.and(opnd0.with_num_bits(64).unwrap(), Opnd::UImm(0xffff)), + 32 | 64 => opnd0, + bits => unreachable!("Invalid number of bits. {}", bits) + } + } + _ => opnd0 + } + } + let mut asm_local = Assembler::new_with_label_names(std::mem::take(&mut self.label_names)); let asm = &mut asm_local; let mut iterator = self.into_draining_iter(); @@ -316,6 +330,7 @@ impl Assembler }, Insn::Cmp { left, right } => { let opnd0 = split_load_operand(asm, left); + let opnd0 = split_less_than_32_cmp(asm, opnd0); let opnd1 = split_shifted_immediate(asm, right); asm.cmp(opnd0, opnd1); }, diff --git a/yjit/src/backend/tests.rs b/yjit/src/backend/tests.rs index 16f9375ba4..440b66d69a 100644 --- a/yjit/src/backend/tests.rs +++ b/yjit/src/backend/tests.rs @@ -341,3 +341,12 @@ fn test_lookback_iterator() { } } } + +#[test] +fn test_cmp_8_bit() { + let (mut asm, mut cb) = setup_asm(); + let reg = Assembler::get_alloc_regs()[0]; + asm.cmp(Opnd::Reg(reg).with_num_bits(8).unwrap(), Opnd::UImm(RUBY_SYMBOL_FLAG as u64)); + + asm.compile_with_num_regs(&mut cb, 1); +} |