Skip to content

Commit 297117b

Browse files
committed
Disable type narrowing optimization when we contruct SSA for JIT
This also revets incorrect fix introduced in f9518c3
1 parent 81513e6 commit 297117b

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3918,7 +3918,7 @@ static zend_bool can_convert_to_double(
39183918
for (phi = var->phi_use_chain; phi; phi = zend_ssa_next_use_phi(ssa, var_num, phi)) {
39193919
/* Check that narrowing can actually be useful */
39203920
type = ssa->var_info[phi->ssa_var].type;
3921-
if (type & ((MAY_BE_ANY|MAY_BE_UNDEF) - (MAY_BE_LONG|MAY_BE_DOUBLE))) {
3921+
if ((type & MAY_BE_ANY) & ~(MAY_BE_LONG|MAY_BE_DOUBLE)) {
39223922
return 0;
39233923
}
39243924

@@ -4240,8 +4240,10 @@ static int zend_infer_types(const zend_op_array *op_array, const zend_script *sc
42404240
return FAILURE;
42414241
}
42424242

4243-
/* Narrowing integer initialization to doubles */
4244-
zend_type_narrowing(op_array, script, ssa, optimization_level);
4243+
if (optimization_level & ZEND_OPTIMIZER_NARROW_TO_DOUBLE) {
4244+
/* Narrowing integer initialization to doubles */
4245+
zend_type_narrowing(op_array, script, ssa, optimization_level);
4246+
}
42454247

42464248
if (ZEND_FUNC_INFO(op_array)) {
42474249
zend_func_return_info(op_array, script, 1, 0, &ZEND_FUNC_INFO(op_array)->return_info);

ext/opcache/Optimizer/zend_optimizer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444

4545
#define ZEND_OPTIMIZER_IGNORE_OVERLOADING (1<<16) /* (unsafe) Ignore possibility of operator overloading */
4646

47+
#define ZEND_OPTIMIZER_NARROW_TO_DOUBLE (1<<17) /* try to narrow long constant assignments to double */
48+
4749
#define ZEND_OPTIMIZER_ALL_PASSES 0x7FFFFFFF
4850

4951
#define DEFAULT_OPTIMIZATION_LEVEL "0x7FFEBFFF"

ext/opcache/jit/zend_jit.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,8 @@ static int zend_jit_op_array_analyze2(const zend_op_array *op_array, zend_script
773773
&& op_array->last_try_catch == 0
774774
&& !(op_array->fn_flags & ZEND_ACC_GENERATOR)
775775
&& !(ssa->cfg.flags & ZEND_FUNC_INDIRECT_VAR_ACCESS)) {
776-
if (zend_ssa_inference(&CG(arena), op_array, script, ssa, optimization_level) != SUCCESS) {
776+
if (zend_ssa_inference(&CG(arena), op_array, script, ssa,
777+
optimization_level & ~ZEND_OPTIMIZER_NARROW_TO_DOUBLE) != SUCCESS) {
777778
return FAILURE;
778779
}
779780
}

0 commit comments

Comments
 (0)