Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 23 additions & 1 deletion yjit/src/backend/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
_ => {}
Expand Down Expand Up @@ -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
"});
}
}