diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index c2f2772208b..f2bf8c2a9ac 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -16178,11 +16178,17 @@ static zend_regset zend_jit_get_scratch_regset(const zend_op *opline, const zend } } if ((op1_info & MAY_BE_LONG) && (op2_info & MAY_BE_DOUBLE)) { + if (opline->op1_type == IS_CONST) { + ZEND_REGSET_INCL(regset, ZREG_R0); + } if (ssa_op->result_def != current_var) { ZEND_REGSET_INCL(regset, ZREG_XMM0); } } if ((op1_info & MAY_BE_DOUBLE) && (op2_info & MAY_BE_LONG)) { + if (opline->op2_type == IS_CONST) { + ZEND_REGSET_INCL(regset, ZREG_R0); + } if (zend_is_commutative(opline->opcode)) { if (ssa_op->result_def != current_var) { ZEND_REGSET_INCL(regset, ZREG_XMM0); diff --git a/ext/opcache/tests/jit/gh10271.phpt b/ext/opcache/tests/jit/gh10271.phpt new file mode 100644 index 00000000000..77c43e3d50a --- /dev/null +++ b/ext/opcache/tests/jit/gh10271.phpt @@ -0,0 +1,47 @@ +--TEST-- +GH-10271: Incorrect arithmetic calculations when using JIT +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit_buffer_size=1M +opcache.jit_hot_loop=1 +--FILE-- +$x,'y'=>$y]; +} +?> +--EXPECT-- +0: In;-0.000516528926;-0.000912408759;968.000000000000;548.000000000000;Out;967.500000000004;547.500000000009 +1: In;-0.000516528926;-0.000912408759;968.000000000000;548.000000000000;Out;967.500000000004;547.500000000009 +2: In;-0.000516528926;-0.000912408759;968.000000000000;548.000000000000;Out;967.500000000004;547.500000000009