[PATCH] D35609: [LICM] Make sinkRegion and hoistRegion non-recursive

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 19 10:53:20 PDT 2017


Hi,

On Wed, Jul 19, 2017 at 10:33 AM, Daniel Berlin <dberlin at dberlin.org> wrote:
>> I don't believe reverse iterating a BFS gives you a post-order.
>
> Is your goal just to visit children first or an actual postorder postorder?
>
>
> Reverse BFS on a tree will give a you a "children first" visitation order.
> By definition, in fact.
> BFS is all parents before all children.
> reversing the order must give you all children before all parents.
>
> Examples:
>
>  1    2
> 3 4  5 6
>
> BFS = 1 2 3 4 5 6
>
> 6 5 4 3 2 1 = children before parents.
>
>
>     1
>  2    3 4
> 5 6  7 8
>
> BFS = 1 2 3 4 5 6 7 8
> reverse of that is still children before parents.
>
>
> It is not a valid postorder in that the order of siblings is not related to
> the order of their children.

Yes, both of you're right.  Reverse BFS won't give a post order, but
if we're interested in only the children-before-parent *property* of
the post order then that may be enough.

Thanks!
-- Sanjoy


More information about the llvm-commits mailing list