Skip to content

Commit 6d9d2eb

Browse files
authored
Optimize JMP[N]Z_EX to BOOL instead of QM_ASSIGN (#10108)
&& and || should always evaluate to a boolean instead of the lhs/rhs. This optimization never gets triggered for any of our tests. Additionally, even if triggered this instruction gets optimized away because the else branch of the JMP instruction will overwrite the tmp value.
1 parent 027add9 commit 6d9d2eb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Zend/Optimizer/dfa_pass.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ static int zend_dfa_optimize_jmps(zend_op_array *op_array, zend_ssa *ssa)
847847
goto optimize_jmpz;
848848
} else if (opline->op1_type == IS_CONST) {
849849
if (zend_is_true(CT_CONSTANT_EX(op_array, opline->op1.constant))) {
850-
opline->opcode = ZEND_QM_ASSIGN;
850+
opline->opcode = ZEND_BOOL;
851851
take_successor_1(ssa, block_num, block);
852852
}
853853
}
@@ -861,7 +861,7 @@ static int zend_dfa_optimize_jmps(zend_op_array *op_array, zend_ssa *ssa)
861861
goto optimize_jmpnz;
862862
} else if (opline->op1_type == IS_CONST) {
863863
if (!zend_is_true(CT_CONSTANT_EX(op_array, opline->op1.constant))) {
864-
opline->opcode = ZEND_QM_ASSIGN;
864+
opline->opcode = ZEND_BOOL;
865865
take_successor_1(ssa, block_num, block);
866866
}
867867
}

0 commit comments

Comments
 (0)