}
if (opline->op1_type == IS_CONST) {
- if (Z_TYPE_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants)) == IS_NULL) {
+ zval *zv = CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants);
+
+ if (Z_TYPE_P(zv) == IS_NULL) {
if (tmp_has_range < 0) {
tmp_has_range = 1;
tmp_range.underflow = 0;
tmp_range.max = MAX(tmp_range.max, 0);
}
}
- } else if (Z_TYPE_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants)) == IS_FALSE) {
+ } else if (Z_TYPE_P(zv) == IS_FALSE) {
if (tmp_has_range < 0) {
tmp_has_range = 1;
tmp_range.underflow = 0;
tmp_range.max = MAX(tmp_range.max, 0);
}
}
- } else if (Z_TYPE_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants)) == IS_TRUE) {
+ } else if (Z_TYPE_P(zv) == IS_TRUE) {
if (tmp_has_range < 0) {
tmp_has_range = 1;
tmp_range.underflow = 0;
tmp_range.max = MAX(tmp_range.max, 1);
}
}
- } else if (Z_TYPE_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants)) == IS_LONG) {
+ } else if (Z_TYPE_P(zv) == IS_LONG) {
if (tmp_has_range < 0) {
tmp_has_range = 1;
tmp_range.underflow = 0;
- tmp_range.min = Z_LVAL_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants));
- tmp_range.max = Z_LVAL_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants));
+ tmp_range.min = Z_LVAL_P(zv);
+ tmp_range.max = Z_LVAL_P(zv);
tmp_range.overflow = 0;
} else if (tmp_has_range) {
if (!tmp_range.underflow) {
- tmp_range.min = MIN(tmp_range.min, Z_LVAL_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants)));
+ tmp_range.min = MIN(tmp_range.min, Z_LVAL_P(zv));
}
if (!tmp_range.overflow) {
- tmp_range.max = MAX(tmp_range.max, Z_LVAL_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants)));
+ tmp_range.max = MAX(tmp_range.max, Z_LVAL_P(zv));
}
}
} else {
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) /* {{{ */
{
zend_op *op = opline;
+ zval *zv;
+
while (op != op_array->opcodes) {
op--;
if (op->result_type != IS_TMP_VAR || op->result.var != var_num) {
return EX_VAR_TO_NUM(op->op1.var);
}
} else if (op->opcode == ZEND_ADD) {
- if (op->op1_type == IS_CV &&
- op->op2_type == IS_CONST &&
- Z_TYPE_P(CRT_CONSTANT(op->op2)) == IS_LONG &&
- Z_LVAL_P(CRT_CONSTANT(op->op2)) != ZEND_LONG_MIN) {
- *adjustment = -Z_LVAL_P(CRT_CONSTANT(op->op2));
- return EX_VAR_TO_NUM(op->op1.var);
- } else if (op->op2_type == IS_CV &&
- op->op1_type == IS_CONST &&
- Z_TYPE_P(CRT_CONSTANT(op->op1)) == IS_LONG &&
- Z_LVAL_P(CRT_CONSTANT(op->op1)) != ZEND_LONG_MIN) {
- *adjustment = -Z_LVAL_P(CRT_CONSTANT(op->op1));
- return EX_VAR_TO_NUM(op->op2.var);
+ if (op->op1_type == IS_CV && op->op2_type == IS_CONST) {
+ zv = CRT_CONSTANT(op->op2);
+ if (Z_TYPE_P(zv) == IS_LONG
+ && Z_LVAL_P(zv) != ZEND_LONG_MIN) {
+ *adjustment = -Z_LVAL_P(zv);
+ return EX_VAR_TO_NUM(op->op1.var);
+ }
+ } else if (op->op2_type == IS_CV && op->op1_type == IS_CONST) {
+ zv = CRT_CONSTANT(op->op2);
+ if (Z_TYPE_P(zv) == IS_LONG
+ && Z_LVAL_P(zv) != ZEND_LONG_MIN) {
+ *adjustment = -Z_LVAL_P(zv);
+ return EX_VAR_TO_NUM(op->op2.var);
+ }
}
} else if (op->opcode == ZEND_SUB) {
- if (op->op1_type == IS_CV &&
- op->op2_type == IS_CONST &&
- Z_TYPE_P(CRT_CONSTANT(op->op2)) == IS_LONG) {
- *adjustment = Z_LVAL_P(CRT_CONSTANT(op->op2));
- return EX_VAR_TO_NUM(op->op1.var);
+ if (op->op1_type == IS_CV && op->op2_type == IS_CONST) {
+ zv = CRT_CONSTANT(op->op2);
+ if (Z_TYPE_P(zv) == IS_LONG) {
+ *adjustment = Z_LVAL_P(zv);
+ return EX_VAR_TO_NUM(op->op1.var);
+ }
}
}
break;
}
} else if (var1 >= 0 && var2 < 0) {
zend_long add_val2 = 0;
- if ((opline-1)->op2_type == IS_CONST &&
- Z_TYPE_P(CRT_CONSTANT((opline-1)->op2)) == IS_LONG) {
- add_val2 = Z_LVAL_P(CRT_CONSTANT((opline-1)->op2));
- } else if ((opline-1)->op2_type == IS_CONST &&
- Z_TYPE_P(CRT_CONSTANT((opline-1)->op2)) == IS_FALSE) {
- add_val2 = 0;
- } else if ((opline-1)->op2_type == IS_CONST &&
- Z_TYPE_P(CRT_CONSTANT((opline-1)->op2)) == IS_TRUE) {
- add_val2 = 1;
+ if ((opline-1)->op2_type == IS_CONST) {
+ zval *zv = CRT_CONSTANT((opline-1)->op2);
+
+ if (Z_TYPE_P(zv) == IS_LONG) {
+ add_val2 = Z_LVAL_P(zv);
+ } else if (Z_TYPE_P(zv) == IS_FALSE) {
+ add_val2 = 0;
+ } else if (Z_TYPE_P(zv) == IS_TRUE) {
+ add_val2 = 1;
+ } else {
+ var1 = -1;
+ }
} else {
var1 = -1;
}
}
} else if (var1 < 0 && var2 >= 0) {
zend_long add_val1 = 0;
- if ((opline-1)->op1_type == IS_CONST &&
- Z_TYPE_P(CRT_CONSTANT((opline-1)->op1)) == IS_LONG) {
- add_val1 = Z_LVAL_P(CRT_CONSTANT((opline-1)->op1));
- } else if ((opline-1)->op1_type == IS_CONST &&
- Z_TYPE_P(CRT_CONSTANT((opline-1)->op1)) == IS_FALSE) {
- add_val1 = 0;
- } else if ((opline-1)->op1_type == IS_CONST &&
- Z_TYPE_P(CRT_CONSTANT((opline-1)->op1)) == IS_TRUE) {
- add_val1 = 1;
+ if ((opline-1)->op1_type == IS_CONST) {
+ zval *zv = CRT_CONSTANT((opline-1)->op1);
+ if (Z_TYPE_P(zv) == IS_LONG) {
+ add_val1 = Z_LVAL_P(CRT_CONSTANT((opline-1)->op1));
+ } else if (Z_TYPE_P(zv) == IS_FALSE) {
+ add_val1 = 0;
+ } else if (Z_TYPE_P(zv) == IS_TRUE) {
+ add_val1 = 1;
+ } else {
+ var2 = -1;
+ }
} else {
var2 = -1;
}