summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2024-01-19 11:51:35 -0800
committerGitHub <[email protected]>2024-01-19 11:51:35 -0800
commite0f7cee8c54691127277d32b4560e44b8394cdc7 (patch)
tree185b129cba597fca76117555626d45a1c5fa6760
parent740f0b52e051d6fd022bf4b9eeab078c841b49a2 (diff)
YJIT: Avoid doubly splitting Opnd::Value on CSel (#9617)
YJIT: Avoid doubly splitting Opnd::Value
-rw-r--r--yjit/src/backend/x86_64/mod.rs24
1 files changed, 23 insertions, 1 deletions
diff --git a/yjit/src/backend/x86_64/mod.rs b/yjit/src/backend/x86_64/mod.rs
index 25c92642d3..1569af93cb 100644
--- a/yjit/src/backend/x86_64/mod.rs
+++ b/yjit/src/backend/x86_64/mod.rs
@@ -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
+ "});
+ }
}