Skip to content

Commit 06f6eb0

Browse files
committed
Use zend_ssa_is_no_val_use() instead of zend_has_improper_op1_use()
1 parent 4b64dbb commit 06f6eb0

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

ext/opcache/Optimizer/dce.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ static inline void add_operands_to_worklists(context *ctx, zend_op *opline, zend
228228
if (ssa_op->result_use >= 0) {
229229
add_to_worklists(ctx, ssa_op->result_use);
230230
}
231-
if (ssa_op->op1_use >= 0 && !zend_has_improper_op1_use(opline)) {
231+
if (ssa_op->op1_use >= 0 && !zend_ssa_is_no_val_use(opline, ssa_op, ssa_op->op1_use)) {
232232
add_to_worklists(ctx, ssa_op->op1_use);
233233
}
234-
if (ssa_op->op2_use >= 0) {
234+
if (ssa_op->op2_use >= 0 && !zend_ssa_is_no_val_use(opline, ssa_op, ssa_op->op2_use)) {
235235
add_to_worklists(ctx, ssa_op->op2_use);
236236
}
237237
}
@@ -501,10 +501,12 @@ int dce_optimize_op_array(zend_op_array *op_array, zend_ssa *ssa, zend_bool reor
501501
/* Improper uses don't count as "uses" for the purpose of instruction elimination,
502502
* but we have to retain phis defining them. Push those phis to the worklist. */
503503
FOREACH_INSTR_NUM(i) {
504-
if (zend_has_improper_op1_use(&op_array->opcodes[i])) {
505-
ZEND_ASSERT(ssa->ops[i].op1_use >= 0);
504+
if (ssa->ops[i].op1_use >= 0 && zend_ssa_is_no_val_use(&op_array->opcodes[i], &ssa->ops[i], ssa->ops[i].op1_use)) {
506505
add_to_phi_worklist_only(&ctx, ssa->ops[i].op1_use);
507506
}
507+
if (ssa->ops[i].op2_use >= 0 && zend_ssa_is_no_val_use(&op_array->opcodes[i], &ssa->ops[i], ssa->ops[i].op2_use)) {
508+
add_to_phi_worklist_only(&ctx, ssa->ops[i].op2_use);
509+
}
508510
} FOREACH_INSTR_NUM_END();
509511

510512
/* Propagate this information backwards, marking any phi with an improperly used

ext/opcache/Optimizer/zend_optimizer_internal.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,4 @@ zend_uchar zend_compound_assign_to_binary_op(zend_uchar opcode);
115115
int sccp_optimize_op_array(zend_optimizer_ctx *ctx, zend_op_array *op_arrya, zend_ssa *ssa, zend_call_info **call_map);
116116
int dce_optimize_op_array(zend_op_array *op_array, zend_ssa *ssa, zend_bool reorder_dtor_effects);
117117

118-
static inline zend_bool zend_has_improper_op1_use(zend_op *opline) {
119-
return opline->opcode == ZEND_ASSIGN
120-
|| (opline->opcode == ZEND_UNSET_VAR && opline->extended_value & ZEND_QUICK_SET);
121-
}
122-
123118
#endif

0 commit comments

Comments
 (0)