[PATCH] Allow blocks to be merged when one has an undef input to a phi.

Duncan Sands duncan.sands at gmail.com
Tue Jun 18 05:58:04 PDT 2013


Hi Mark,

On 17/06/13 19:41, Mark Lacey wrote:
> Hi All,
>
> This is a relatively small patch I re-submitted last week which seems to have gotten lost in the shuffle.
>
> Can someone take a look and commit if everything looks good?

sorry for forgetting about this.  My only remaining concern is that the
algorithm seems to be quadratic in the number of phi node operands.  It
is possible (though rare) to have phi nodes with hundreds of operands.
Maybe it is better to exploit a container type, eg use a map from basic
block to new value.  Then you can eg just whiz down the existing phi nodes,
chucking their (bb, value) pairs into the map whenever "value" is not undef,
then construct the new phi node by, for each predecessor bb, adding (bb, value)
if bb -> value in the map, and adding (bb, undef) if bb is not in the map.  Or
something like that.

Ciao, Duncan.

>
> Thanks,
>
> Mark
>
>
> TryToSimplifyUncondBranchFromEmptyBlock was checking that any common
> predecessors of the two blocks it is attempting to merge supply the
> same incoming values to any phi in the successor block. This change
> allows merging in the case where there is one or more incoming values
> that are undef. The undef values are rewritten to match the non-undef
> value that flows from the other edge.
>
> Merged the tests from
> - test/Transforms/SimplifyCFG/2008-05-16-PHIBlockMerge.ll
> into
> - test/Transforms/SimplifyCFG/EqualPHIEdgeBlockMerge.ll
> and also added tests to this file for the situation addressed by this
> patch.
>
> <rdar://problem/12801861>
> ---
> lib/Transforms/Utils/Local.cpp                     |  76 ++++++-
> .../SimplifyCFG/2008-05-16-PHIBlockMerge.ll        | 131 -----------
> .../SimplifyCFG/EqualPHIEdgeBlockMerge.ll          | 240 ++++++++++++++++++++-
> 3 files changed, 307 insertions(+), 140 deletions(-)
> delete mode 100644 test/Transforms/SimplifyCFG/2008-05-16-PHIBlockMerge.ll
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list