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

Hans Wennborg hans at chromium.org
Wed Apr 15 08:17:11 PDT 2015


In http://reviews.llvm.org/D8649#156414, @hans wrote:

> Sorry for the lack of updates. I'll try to get this patch moving again.
>
> In http://reviews.llvm.org/D8649#151108, @djasper wrote:
>
> > Is it possible to get some idea of which bit tests LLVM is not finding with your bit tests? From your comments and IRC discussion, it feels like it should be finding more bit tests.
>
>
> I have a theory. The previous code has a "number of cmps" concepts, where a single case counts as 1, and a range counts as 2, and this metric affects whether we build bit tests.
>
> Since we can compare both single cases and ranges with a single comparison (though the range also requires a subtraction), my patch just uses the number of clusters. I'll try to confirm if that's the reason for the difference.


Yeah, that was it. If I use the "NumCmps" metric instead, I get 5785 bit tests with my patch in a bootstrap vs. 5603 without my patch, so that's the explanation.

Here's an example:

case 1: case3: // Something.
case 4: case 5: case 32: // Something else.

Without my patch, we use bit tests (NumCmps = 5), but with my patch we don't (NumClusters = 4). I think counting the number of clusters makes more sense, because a range still only requires one branch, but I'll change this back for now to reduce the number of changes introduced by my patch.


http://reviews.llvm.org/D8649

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






More information about the llvm-commits mailing list