Skip to content

Commit 0569cd2

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Mark ASSIGN result as UNUSED in SCCP
2 parents 6446eaf + fa3d603 commit 0569cd2

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Zend/Optimizer/sccp.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,12 +2188,13 @@ static int try_remove_definition(sccp_ctx *ctx, int var_num, zend_ssa_var *var,
21882188
zend_op *opline = &op_array->opcodes[var->definition];
21892189
zend_ssa_op *ssa_op = &ssa->ops[var->definition];
21902190

2191-
if (opline->opcode == ZEND_ASSIGN) {
2192-
/* Leave assigns to DCE (due to dtor effects) */
2193-
return 0;
2194-
}
2195-
21962191
if (ssa_op->result_def == var_num) {
2192+
if (opline->opcode == ZEND_ASSIGN) {
2193+
/* We can't drop the ASSIGN, but we can remove the result. */
2194+
opline->result_type = IS_UNUSED;
2195+
zend_ssa_remove_result_def(ssa, ssa_op);
2196+
return 0;
2197+
}
21972198
if (ssa_op->op1_def >= 0
21982199
|| ssa_op->op2_def >= 0) {
21992200
/* we cannot remove instruction that defines other variables */
@@ -2257,6 +2258,11 @@ static int try_remove_definition(sccp_ctx *ctx, int var_num, zend_ssa_var *var,
22572258
}
22582259
}
22592260
} else if (ssa_op->op1_def == var_num) {
2261+
if (opline->opcode == ZEND_ASSIGN) {
2262+
/* Leave assigns to DCE (due to dtor effects) */
2263+
return 0;
2264+
}
2265+
22602266
/* Compound assign or incdec -> convert to direct ASSIGN */
22612267

22622268
if (!value) {

0 commit comments

Comments
 (0)