[PATCH] D60982: [SimplifyCFG] Use lookup tables when they are more space efficient or a huge speed win.

Shawn Landden via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 22 14:57:58 PDT 2019


shawnl created this revision.
shawnl added reviewers: nikic, hans, spatel, jmolloy, lebedev.ri.
Herald added subscribers: llvm-commits, kristof.beyls, javed.absar.
Herald added a project: LLVM.

I am trying to move towards much more space-efficient switch statements, using popcnt, as described in PR39013. This is the second patch towards that goal, and a continuation of D60673 <https://reviews.llvm.org/D60673>.

There are quite a few cases where the lookup table was smaller and it was still not used. I hard-coded values for x86_64, but arm64 was similar. Also, there was no consideration of how large the cases were in the calculation. These numbers will change in a later patch, (when sparse maps make switch much more compact) so we shouldn't argue too much about this cut-off.

When only an i8 is being switched over, the table is not large, and using a lookup table is a huge speed gain. (as can be seen in the test)

Eliminate and and xor when doing a fully covered table.


Repository:
  rL LLVM

https://reviews.llvm.org/D60982

Files:
  lib/Transforms/Utils/SimplifyCFG.cpp
  test/Transforms/SimplifyCFG/switch-genfori8.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60982.196134.patch
Type: text/x-patch
Size: 10513 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190422/e6121f8e/attachment.bin>


More information about the llvm-commits mailing list