[PATCH] D35609: [LICM] Make sinkRegion and hoistRegion non-recursive
Daniel Berlin via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 19 10:33:25 PDT 2017
On Wed, Jul 19, 2017 at 10:23 AM, David Majnemer via Phabricator via
llvm-commits <llvm-commits at lists.llvm.org> wrote:
> majnemer added inline comments.
>
>
> ================
> Comment at: lib/Transforms/Scalar/LICM.cpp:348
> + SmallVector<BasicBlock *, 16> Worklist;
> + DT->getDescendants(N->getBlock(), Worklist);
>
> ----------------
> sanjoy wrote:
> > majnemer wrote:
> > > sanjoy wrote:
> > > > `getDescendants` seems to be doing a BFS. Given that (and that DT
> is a tree), can you iterate `Worklist` in reverse to get a post order? If
> you do this, we'd have to spec `getDescendants` as doing a BFS though (and
> not just have it be an implementation detail).
> > > >
> > > > OTOH if you write the BFS by hand (instead of relying on
> `getDescendents`), you can add an early exit for `CurLoop->contains(BB)`.
> > > Do you mean BFS or DFS?
> > I meant BFS; since DT is a tree you can do a (slightly) cheaper in-place
> BFS as:
> >
> > ```
> > Order.push_back(N);
> > for (int i = 0; i < Order.size(); i++)
> > Order.push_back(N->children());
> > ```
> >
> 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.
>
> https://reviews.llvm.org/D35609
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170719/9df8d088/attachment.html>
More information about the llvm-commits
mailing list