[PATCH] D25212: Add support to tune jump tables

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 10 01:59:16 PDT 2016


hans added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:8550
+             ((MoreJumpTables && Tables > NumTables[i]) ||
+              (!MoreJumpTables && Tables < NumTables[i])))) {
           MinPartitions[i] = NumPartitions;
----------------
evandro wrote:
> hans wrote:
> > I really don't like this. The purpose of this algorithm is to find jump tables. If you don't want to find jump tables, don't run it. If you think it's generating too large or sparse jump tables, tweak those parameters.
> I'd like to have the option to choose more of fewer jump tables when the number of partitions is the same.  It's not clear to me why only one possibility was cast in the code originally, but it doesn't seem to me to be always the best choice.
>  It's not clear to me why only one possibility was cast in the code originally, but it doesn't seem to me to be always the best choice.

It's because the whole purpose of the code is to find jump tables.

Consider the @optimal_jump_table2 test in test/CodeGen/X86/switch.ll. The cases in the switch can be partitioned as {0,1,2,9},{14,15} or {0,1,2},{9,14,15}. The code ensures that the partitioning with the jump table is chosen.

If you think that's the wrong lowering for your target, maybe increasing the minimum jump table entries is what you want.


Repository:
  rL LLVM

https://reviews.llvm.org/D25212





More information about the llvm-commits mailing list