[PATCH] D41029: [JumpTables][PowerPC] Let targets decide which switch instructions are suitable for jump tables

Nemanja Ivanovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 21 21:06:22 PST 2018


nemanjai added a comment.

I've finally gotten around to benchmarking this. I'll try to attach the full summary (warning: it is a large PDF file) and here is a somewhat concise summary of what I've done to benchmark this:

1. Varied the following parameters
  - Number of cases
  - Density of each cluster (this is just the relationship between the range of values and the number of cases - i.e. 20 cases with density 10% will have values ranging from 0-200 with cases 0, 10, 20, 30, etc.)
  - Number of clusters (how many dense sections the number of cases is split into)
  - Complexity (this is just a measure of what percentage of cases are "complex" vs. "simple" - a simple case is just a return of an integer whereas a complex case is function calls)
  - The "Combination" field is composed of these parameters in order (i.e. 30.10.2.100 is 30 cases, density 10%, broken up into 2 clusters with 100% complexity)
2. For complex cases, only direct and indirect calls were used. It might be interesting to also perform this exercise with "complex" cases being loops (perhaps CTR-eligible loops).
3. Ran each binary built 3 times on a Power9 system and collected the number of cycles with the value being switched on being modulo the number of cases. Each run was bound to the same physical CPU that the kernel threads generally don't run on in order to reduce noise. The number of cycles was then averaged and compared to produce a "winner" (i.e. the binary that runs for fewer cycles).
4. Everything was dumped into a CSV file

Findings
Jump tables tend to win for very specific cases whereas turning them off is a win in general.

- Switch statements with a very low complexity tend to work better with jump tables
- Small switch statements generally work better without jump tables
- When jump tables win, the gap tends to be small except when the switch statement has a very low complexity

Note:
Understandably, some combinations of the parameters don't make a lot of sense. For example, with a very low number of cases, the rest of the parameters don't make much difference.F5777079: JumpTablesBenchmark.pdf <https://reviews.llvm.org/F5777079>


Repository:
  rL LLVM

https://reviews.llvm.org/D41029





More information about the llvm-commits mailing list