[PATCH] D31080: [DAG] Extract switch lowering as a spearate object NFC

Hans Wennborg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 17 14:09:03 PDT 2017


hans added a comment.

In https://reviews.llvm.org/D31080#704210, @chandlerc wrote:

> > I'm concerned that this hook might turn out to be very expensive though.
>
> What primarily concerns you about the cost?
>
> If it is the cost of actually computing the clustering, the thing the inliner wants could be a rough approximation. Put differently, we don't need to actually *form* the clustering, just have an estimate of how many branches will end up being used (as opposed to jump tables).


Yeah, it's the cost of computing the clustering. I thought most hooks were supposed to be roughly O(1), but this code is actually doing work -- O(n^2) in the worst case, alebeit with low overhead.

It might be possible to come up with some rough estimate though.

Another thought is that at some point it might be worth thinking about moving switch lowering to the IR level, to avoid the whole problem of computing the inlining cost, but that's a big project.


https://reviews.llvm.org/D31080





More information about the llvm-commits mailing list