[PATCH] D31085: [InlineCost] Increase the cost of Switch

Jun Bum Lim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 29 11:35:43 PDT 2017


junbuml added a comment.

The below comment by Hans is copied from  https://reviews.llvm.org/D31080 :

> Before we get any further, I also would like to ask if you have done any measurements of compile-time with this set of patches. As I said before, I think this be quite an expensive hook to call for the inline cost analysis, and it would be nice to see some numbers. If it turns out that it is expensive, perhaps we could come up with some better inline cost heuristic, perhaps something based on the density of the switch.

I think there are three difference cost heuristics :

1. The cheapest yet inaccurate version is https://reviews.llvm.org/D29870 in which the number of case is simply used as number of cluster.
2. The most accurate yet expensive version is to use a hook from https://reviews.llvm.org/D31080.
3. I guess what Hans suggested in above comment (something based on the density of the switch) must be somewhere in between #1 and #2.

Both #1 and #2 consider forming a BTree, and don't require to update the cost heuristic for the changes in switch lowering. I'm not clear about #3 in terms of the accuracy, compile-time, and maintenance. Hans, can you give me little bit more detail?

For me, at least #1 is still better than the current heuristic which simply count the number of distinct successor blocks. If then, would it make sense to use #1 by default and add difference levels of cost heuristics with flags so that we can come up with the most reasonable heuristic and allow others  to do experiments ?


https://reviews.llvm.org/D31085





More information about the llvm-commits mailing list