diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index 9941a815111..224f419c7e7 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -5413,7 +5413,7 @@ static int zend_jit_long_math_helper(zend_jit_ctx *jit, jit_SET_EX_OPLINE(jit, opline); ir_GUARD(IR_FALSE, jit_STUB_ADDR(jit, jit_stub_negative_shift)); if (Z_MODE(res_addr) == IS_REG) { - zend_jit_def_reg(jit, res_addr, ir_CONST_LONG(0)); // dead code + ref = ir_CONST_LONG(0); // dead code } } } else { @@ -5462,7 +5462,7 @@ static int zend_jit_long_math_helper(zend_jit_ctx *jit, jit_SET_EX_OPLINE(jit, opline); ir_GUARD(IR_FALSE, jit_STUB_ADDR(jit, jit_stub_negative_shift)); if (Z_MODE(res_addr) == IS_REG) { - zend_jit_def_reg(jit, res_addr, ir_CONST_LONG(0)); // dead code + ref = ir_CONST_LONG(0); // dead code } } } else { @@ -5503,7 +5503,7 @@ static int zend_jit_long_math_helper(zend_jit_ctx *jit, jit_SET_EX_OPLINE(jit, opline); ir_GUARD(IR_FALSE, jit_STUB_ADDR(jit, jit_stub_mod_by_zero)); if (Z_MODE(res_addr) == IS_REG) { - zend_jit_def_reg(jit, res_addr, ir_CONST_LONG(0)); // dead code + ref = ir_CONST_LONG(0); // dead code } } else if (zend_long_is_power_of_two(op2_lval) && op1_range && op1_range->min >= 0) { ref = ir_AND_L(jit_Z_LVAL(jit, op1_addr), ir_CONST_LONG(op2_lval - 1)); diff --git a/ext/opcache/tests/jit/mod_008.phpt b/ext/opcache/tests/jit/mod_008.phpt new file mode 100644 index 00000000000..a307870b161 --- /dev/null +++ b/ext/opcache/tests/jit/mod_008.phpt @@ -0,0 +1,21 @@ +--TEST-- +JIT MOD: 008 +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit_buffer_size=1M +opcache.protect_memory=1 +--FILE-- + +--EXPECTF-- +Fatal error: Uncaught DivisionByZeroError: Division by zero in %smod_008.php:3 +Stack trace: +#0 %smod_008.php(5): foo() +#1 {main} + thrown in %smod_008.php on line 3