[PATCH] Switch lowering: extract jump tables and bit tests before building binary tree (PR22262)

Hans Wennborg hans at chromium.org
Thu Apr 16 07:50:10 PDT 2015


In http://reviews.llvm.org/D8649#156487, @djasper wrote:

> I think you should re-run the numbers you gathered under "Some numbers from a Clang bootstrap at r233105.", but other than that this seems fine to go in. Anything else we should try to experiment with in smaller subsequent patches.


Sounds good. I re-ran the numbers for the self-host. I'm leaving out the tree balance metrics, as they haven't changed. The binary size difference is also still 20 kB.

Without my patch:
4781 jump tables, 5593 bit tests

With my patch:
4781 jump tables, 5775 bit tests

Again, the main benefit is that with my patch, the trees are always balanced.

This confirms that we fixed the bit test discrepancy by going back to NumCmps.  The interesting thing is that we're now not finding any new jump tables. It seems previously we'd generate jump tables for some of the bit tests we didn't use due to the different metric.

This also shows that the new jump table finding algorithm doesn't have any effect on a clang bootstrap. That's a little disappointing, but I guess the cases where the current algorithm fails are not that common.

We talked a bit about compile-time issues at Euro-LLVM. For my 10,000 case switch example in "big.c" above, the slow-down doesn't seem that significant, and switches like that should be rare. If it turns out that the jump table or bit-test algorithms have speed issues in practice, we could try simpler algorithms, or reducing their search space somehow.


http://reviews.llvm.org/D8649

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list