From: Nikita Popov Date: Thu, 12 May 2016 19:57:19 +0000 (+0200) Subject: Fix phi placement for pi targets X-Git-Tag: php-7.1.0alpha1~148 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b5bdb40cb576fa5b4d769580376ae34881c93574;p=php Fix phi placement for pi targets If the pi target has multiple predecessors, we need to place a phi there. However it's not possible to express this in terms of dominance frontiers, so we need to explicitly add it to the phi set. This does not yet solve the problem of non-minimal SSA for the case where the target has multiple predecessors, but dominates all predecessors (apart from the one creating the pi) -- but that's an existing issue. --- diff --git a/ext/opcache/Optimizer/zend_ssa.c b/ext/opcache/Optimizer/zend_ssa.c index 3b5e45b315..a008e1029b 100644 --- a/ext/opcache/Optimizer/zend_ssa.c +++ b/ext/opcache/Optimizer/zend_ssa.c @@ -95,6 +95,13 @@ static zend_ssa_phi *add_pi( * If there is a back-edge to "to" this may result in non-minimal SSA form. */ DFG_SET(dfg->def, dfg->size, to, var); + /* If there are multiple predecessors in the target block, we need to place a phi there. + * However this can (generally) not be expressed in terms of dominance frontiers, so place it + * explicitly. dfg->use here really is dfg->phi, we're reusing the set. */ + if (ssa->cfg.blocks[to].predecessors_count > 1) { + DFG_SET(dfg->use, dfg->size, to, var); + } + return phi; } /* }}} */