Skip to content

Commit fb2f7fe

Browse files
committed
Optimizer: Use true / false instead of 1 / 0 for bool parameters
Changes done with Coccinelle: @r1@ identifier F; identifier p; typedef bool; parameter list [n1] PL1; parameter list [n2] PL2; @@ F(PL1, bool p, PL2) { ... } @r2@ identifier r1.F; expression list [r1.n1] EL1; expression list [r1.n2] EL2; @@ F(EL1, ( - 1 + true | - 0 + false ) , EL2)
1 parent 827c24b commit fb2f7fe

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Zend/Optimizer/zend_inference.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,7 +1862,7 @@ static void zend_infer_ranges(const zend_op_array *op_array, zend_ssa *ssa) /* {
18621862
} else if (zend_inference_calc_range(op_array, ssa, j, 0, 1, &tmp)) {
18631863
zend_inference_init_range(op_array, ssa, j, tmp.underflow, tmp.min, tmp.max, tmp.overflow);
18641864
} else {
1865-
zend_inference_init_range(op_array, ssa, j, 1, ZEND_LONG_MIN, ZEND_LONG_MAX, 1);
1865+
zend_inference_init_range(op_array, ssa, j, true, ZEND_LONG_MIN, ZEND_LONG_MAX, true);
18661866
}
18671867
} else {
18681868
/* Find SCC entry points */
@@ -1897,7 +1897,8 @@ static void zend_infer_ranges(const zend_op_array *op_array, zend_ssa *ssa) /* {
18971897
for (j = scc_var[scc]; j >= 0; j = next_scc_var[j]) {
18981898
if (!ssa->var_info[j].has_range
18991899
&& !(ssa->var_info[j].type & MAY_BE_REF)) {
1900-
zend_inference_init_range(op_array, ssa, j, 1, ZEND_LONG_MIN, ZEND_LONG_MAX, 1);
1900+
zend_inference_init_range(op_array, ssa, j, true, ZEND_LONG_MIN, ZEND_LONG_MAX,
1901+
true);
19011902
FOR_EACH_VAR_USAGE(j, ADD_SCC_VAR);
19021903
}
19031904
}
@@ -4124,7 +4125,8 @@ ZEND_API zend_result zend_update_type_info(
41244125
const zend_op **ssa_opcodes,
41254126
zend_long optimization_level)
41264127
{
4127-
return _zend_update_type_info(op_array, ssa, script, NULL, opline, ssa_op, ssa_opcodes, optimization_level, 0);
4128+
return _zend_update_type_info(op_array, ssa, script, NULL, opline, ssa_op, ssa_opcodes, optimization_level,
4129+
false);
41284130
}
41294131

41304132
static uint32_t get_class_entry_rank(zend_class_entry *ce) {
@@ -4260,7 +4262,7 @@ static zend_result zend_infer_types_ex(const zend_op_array *op_array, const zend
42604262
}
42614263
} else if (ssa_vars[j].definition >= 0) {
42624264
i = ssa_vars[j].definition;
4263-
if (_zend_update_type_info(op_array, ssa, script, worklist, op_array->opcodes + i, ssa->ops + i, NULL, optimization_level, 1) == FAILURE) {
4265+
if (_zend_update_type_info(op_array, ssa, script, worklist, op_array->opcodes + i, ssa->ops + i, NULL, optimization_level, true) == FAILURE) {
42644266
return FAILURE;
42654267
}
42664268
}
@@ -4547,7 +4549,7 @@ ZEND_API void zend_init_func_return_info(
45474549
zend_ssa_range tmp_range = {0, 0, 0, 0};
45484550
bool is_instanceof = false;
45494551
ret->type = zend_get_return_info_from_signature_only(
4550-
(zend_function *) op_array, script, &ret->ce, &is_instanceof, /* use_tentative_return_info */ 1);
4552+
(zend_function *) op_array, script, &ret->ce, &is_instanceof, /* use_tentative_return_info */ true);
45514553
ret->is_instanceof = is_instanceof;
45524554
ret->range = tmp_range;
45534555
ret->has_range = 0;

Zend/Optimizer/zend_ssa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@ void zend_ssa_remove_predecessor(zend_ssa *ssa, int from, int to) /* {{{ */
15401540
for (phi = next_ssa_block->phis; phi; phi = phi->next) {
15411541
if (phi->pi >= 0) {
15421542
if (phi->pi == from) {
1543-
zend_ssa_rename_var_uses(ssa, phi->ssa_var, phi->sources[0], /* update_types */ 0);
1543+
zend_ssa_rename_var_uses(ssa, phi->ssa_var, phi->sources[0], /* update_types */ false);
15441544
zend_ssa_remove_phi(ssa, phi);
15451545
}
15461546
} else {

0 commit comments

Comments
 (0)