YJIT: Avoid doubly splitting Opnd::Value on CSel (#9617)

YJIT: Avoid doubly splitting Opnd::Value
This commit is contained in:
Takashi Kokubun 2024-01-19 11:51:35 -08:00 committed by GitHub
parent 740f0b52e0
commit e0f7cee8c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -271,7 +271,11 @@ impl Assembler
*truthy = asm.load(*truthy);
}
},
Opnd::UImm(_) | Opnd::Imm(_) | Opnd::Value(_) => {
Opnd::UImm(_) | Opnd::Imm(_) => {
*truthy = asm.load(*truthy);
},
// Opnd::Value could have already been split
Opnd::Value(_) if !matches!(truthy, Opnd::InsnOut { .. }) => {
*truthy = asm.load(*truthy);
},
_ => {}
@ -1270,4 +1274,22 @@ mod tests {
0xe: mov qword ptr [rbx], rax
"});
}
#[test]
fn test_csel_split() {
let (mut asm, mut cb) = setup_asm();
let stack_top = Opnd::mem(64, SP, 0);
let elem_opnd = asm.csel_ne(VALUE(0x7f22c88d1930).into(), Qnil.into());
asm.mov(stack_top, elem_opnd);
asm.compile_with_num_regs(&mut cb, 3);
assert_disasm!(cb, "48b830198dc8227f0000b904000000480f44c1488903", {"
0x0: movabs rax, 0x7f22c88d1930
0xa: mov ecx, 4
0xf: cmove rax, rcx
0x13: mov qword ptr [rbx], rax
"});
}
}