Skip to content

Commit 871cd76

Browse files
committed
clanup
1 parent f5dbba0 commit 871cd76

File tree

2 files changed

+55
-43
lines changed

2 files changed

+55
-43
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3867,7 +3867,9 @@ void zend_func_return_info(const zend_op_array *op_array,
38673867
}
38683868

38693869
if (opline->op1_type == IS_CONST) {
3870-
if (Z_TYPE_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants)) == IS_NULL) {
3870+
zval *zv = CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants);
3871+
3872+
if (Z_TYPE_P(zv) == IS_NULL) {
38713873
if (tmp_has_range < 0) {
38723874
tmp_has_range = 1;
38733875
tmp_range.underflow = 0;
@@ -3882,7 +3884,7 @@ void zend_func_return_info(const zend_op_array *op_array,
38823884
tmp_range.max = MAX(tmp_range.max, 0);
38833885
}
38843886
}
3885-
} else if (Z_TYPE_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants)) == IS_FALSE) {
3887+
} else if (Z_TYPE_P(zv) == IS_FALSE) {
38863888
if (tmp_has_range < 0) {
38873889
tmp_has_range = 1;
38883890
tmp_range.underflow = 0;
@@ -3897,7 +3899,7 @@ void zend_func_return_info(const zend_op_array *op_array,
38973899
tmp_range.max = MAX(tmp_range.max, 0);
38983900
}
38993901
}
3900-
} else if (Z_TYPE_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants)) == IS_TRUE) {
3902+
} else if (Z_TYPE_P(zv) == IS_TRUE) {
39013903
if (tmp_has_range < 0) {
39023904
tmp_has_range = 1;
39033905
tmp_range.underflow = 0;
@@ -3912,19 +3914,19 @@ void zend_func_return_info(const zend_op_array *op_array,
39123914
tmp_range.max = MAX(tmp_range.max, 1);
39133915
}
39143916
}
3915-
} else if (Z_TYPE_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants)) == IS_LONG) {
3917+
} else if (Z_TYPE_P(zv) == IS_LONG) {
39163918
if (tmp_has_range < 0) {
39173919
tmp_has_range = 1;
39183920
tmp_range.underflow = 0;
3919-
tmp_range.min = Z_LVAL_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants));
3920-
tmp_range.max = Z_LVAL_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants));
3921+
tmp_range.min = Z_LVAL_P(zv);
3922+
tmp_range.max = Z_LVAL_P(zv);
39213923
tmp_range.overflow = 0;
39223924
} else if (tmp_has_range) {
39233925
if (!tmp_range.underflow) {
3924-
tmp_range.min = MIN(tmp_range.min, Z_LVAL_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants)));
3926+
tmp_range.min = MIN(tmp_range.min, Z_LVAL_P(zv));
39253927
}
39263928
if (!tmp_range.overflow) {
3927-
tmp_range.max = MAX(tmp_range.max, Z_LVAL_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants)));
3929+
tmp_range.max = MAX(tmp_range.max, Z_LVAL_P(zv));
39283930
}
39293931
}
39303932
} else {

ext/opcache/Optimizer/zend_ssa.c

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ static inline uint32_t mask_for_type_check(uint32_t type) {
165165
static int find_adjusted_tmp_var(const zend_op_array *op_array, uint32_t build_flags, zend_op *opline, uint32_t var_num, zend_long *adjustment) /* {{{ */
166166
{
167167
zend_op *op = opline;
168+
zval *zv;
169+
168170
while (op != op_array->opcodes) {
169171
op--;
170172
if (op->result_type != IS_TMP_VAR || op->result.var != var_num) {
@@ -182,25 +184,28 @@ static int find_adjusted_tmp_var(const zend_op_array *op_array, uint32_t build_f
182184
return EX_VAR_TO_NUM(op->op1.var);
183185
}
184186
} else if (op->opcode == ZEND_ADD) {
185-
if (op->op1_type == IS_CV &&
186-
op->op2_type == IS_CONST &&
187-
Z_TYPE_P(CRT_CONSTANT(op->op2)) == IS_LONG &&
188-
Z_LVAL_P(CRT_CONSTANT(op->op2)) != ZEND_LONG_MIN) {
189-
*adjustment = -Z_LVAL_P(CRT_CONSTANT(op->op2));
190-
return EX_VAR_TO_NUM(op->op1.var);
191-
} else if (op->op2_type == IS_CV &&
192-
op->op1_type == IS_CONST &&
193-
Z_TYPE_P(CRT_CONSTANT(op->op1)) == IS_LONG &&
194-
Z_LVAL_P(CRT_CONSTANT(op->op1)) != ZEND_LONG_MIN) {
195-
*adjustment = -Z_LVAL_P(CRT_CONSTANT(op->op1));
196-
return EX_VAR_TO_NUM(op->op2.var);
187+
if (op->op1_type == IS_CV && op->op2_type == IS_CONST) {
188+
zv = CRT_CONSTANT(op->op2);
189+
if (Z_TYPE_P(zv) == IS_LONG
190+
&& Z_LVAL_P(zv) != ZEND_LONG_MIN) {
191+
*adjustment = -Z_LVAL_P(zv);
192+
return EX_VAR_TO_NUM(op->op1.var);
193+
}
194+
} else if (op->op2_type == IS_CV && op->op1_type == IS_CONST) {
195+
zv = CRT_CONSTANT(op->op2);
196+
if (Z_TYPE_P(zv) == IS_LONG
197+
&& Z_LVAL_P(zv) != ZEND_LONG_MIN) {
198+
*adjustment = -Z_LVAL_P(zv);
199+
return EX_VAR_TO_NUM(op->op2.var);
200+
}
197201
}
198202
} else if (op->opcode == ZEND_SUB) {
199-
if (op->op1_type == IS_CV &&
200-
op->op2_type == IS_CONST &&
201-
Z_TYPE_P(CRT_CONSTANT(op->op2)) == IS_LONG) {
202-
*adjustment = Z_LVAL_P(CRT_CONSTANT(op->op2));
203-
return EX_VAR_TO_NUM(op->op1.var);
203+
if (op->op1_type == IS_CV && op->op2_type == IS_CONST) {
204+
zv = CRT_CONSTANT(op->op2);
205+
if (Z_TYPE_P(zv) == IS_LONG) {
206+
*adjustment = Z_LVAL_P(zv);
207+
return EX_VAR_TO_NUM(op->op1.var);
208+
}
204209
}
205210
}
206211
break;
@@ -289,15 +294,18 @@ static void place_essa_pis(
289294
}
290295
} else if (var1 >= 0 && var2 < 0) {
291296
zend_long add_val2 = 0;
292-
if ((opline-1)->op2_type == IS_CONST &&
293-
Z_TYPE_P(CRT_CONSTANT((opline-1)->op2)) == IS_LONG) {
294-
add_val2 = Z_LVAL_P(CRT_CONSTANT((opline-1)->op2));
295-
} else if ((opline-1)->op2_type == IS_CONST &&
296-
Z_TYPE_P(CRT_CONSTANT((opline-1)->op2)) == IS_FALSE) {
297-
add_val2 = 0;
298-
} else if ((opline-1)->op2_type == IS_CONST &&
299-
Z_TYPE_P(CRT_CONSTANT((opline-1)->op2)) == IS_TRUE) {
300-
add_val2 = 1;
297+
if ((opline-1)->op2_type == IS_CONST) {
298+
zval *zv = CRT_CONSTANT((opline-1)->op2);
299+
300+
if (Z_TYPE_P(zv) == IS_LONG) {
301+
add_val2 = Z_LVAL_P(zv);
302+
} else if (Z_TYPE_P(zv) == IS_FALSE) {
303+
add_val2 = 0;
304+
} else if (Z_TYPE_P(zv) == IS_TRUE) {
305+
add_val2 = 1;
306+
} else {
307+
var1 = -1;
308+
}
301309
} else {
302310
var1 = -1;
303311
}
@@ -308,15 +316,17 @@ static void place_essa_pis(
308316
}
309317
} else if (var1 < 0 && var2 >= 0) {
310318
zend_long add_val1 = 0;
311-
if ((opline-1)->op1_type == IS_CONST &&
312-
Z_TYPE_P(CRT_CONSTANT((opline-1)->op1)) == IS_LONG) {
313-
add_val1 = Z_LVAL_P(CRT_CONSTANT((opline-1)->op1));
314-
} else if ((opline-1)->op1_type == IS_CONST &&
315-
Z_TYPE_P(CRT_CONSTANT((opline-1)->op1)) == IS_FALSE) {
316-
add_val1 = 0;
317-
} else if ((opline-1)->op1_type == IS_CONST &&
318-
Z_TYPE_P(CRT_CONSTANT((opline-1)->op1)) == IS_TRUE) {
319-
add_val1 = 1;
319+
if ((opline-1)->op1_type == IS_CONST) {
320+
zval *zv = CRT_CONSTANT((opline-1)->op1);
321+
if (Z_TYPE_P(zv) == IS_LONG) {
322+
add_val1 = Z_LVAL_P(CRT_CONSTANT((opline-1)->op1));
323+
} else if (Z_TYPE_P(zv) == IS_FALSE) {
324+
add_val1 = 0;
325+
} else if (Z_TYPE_P(zv) == IS_TRUE) {
326+
add_val1 = 1;
327+
} else {
328+
var2 = -1;
329+
}
320330
} else {
321331
var2 = -1;
322332
}

0 commit comments

Comments
 (0)