Skip to content

Commit d5e80c1

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Handle pi nodes in replace_predecessor
2 parents bec1d2f + 038bc27 commit d5e80c1

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

Zend/Optimizer/dfa_pass.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -586,11 +586,19 @@ static void replace_predecessor(zend_ssa *ssa, int block_id, int old_pred, int n
586586

587587
/* Also remove the corresponding phi node entries */
588588
for (phi = ssa->blocks[block_id].phis; phi; phi = phi->next) {
589-
memmove(
590-
phi->sources + old_pred_idx,
591-
phi->sources + old_pred_idx + 1,
592-
sizeof(int) * (block->predecessors_count - old_pred_idx - 1)
593-
);
589+
if (phi->pi >= 0) {
590+
if (phi->pi == old_pred) {
591+
zend_ssa_rename_var_uses(
592+
ssa, phi->ssa_var, phi->sources[0], /* update_types */ 0);
593+
zend_ssa_remove_phi(ssa, phi);
594+
}
595+
} else {
596+
memmove(
597+
phi->sources + old_pred_idx,
598+
phi->sources + old_pred_idx + 1,
599+
sizeof(int) * (block->predecessors_count - old_pred_idx - 1)
600+
);
601+
}
594602
}
595603

596604
block->predecessors_count--;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Handling of pi nodes when replacing a predecessor
3+
--FILE--
4+
<?php
5+
function test(bool $a, bool $b) {
6+
$byte = '';
7+
if ($a && $byte > 0 && $b) {}
8+
unknown($byte);
9+
}
10+
?>
11+
===DONE===
12+
--EXPECT--
13+
===DONE===

0 commit comments

Comments
 (0)