SimplifyCFG: Make the switch-to-lookup table transformation store the
authorHans Wennborg <hans@hanshq.net>
Wed, 26 Sep 2012 09:44:49 +0000 (09:44 +0000)
committerHans Wennborg <hans@hanshq.net>
Wed, 26 Sep 2012 09:44:49 +0000 (09:44 +0000)
commitd72271cd84ab2a0d3855a95719341b036980d5ac
treed0b46da054a39a0d8c78587855a833009ce48e8b
parentdb5dbf013cc16aeb2d05ac9223e84a9412c3e278
SimplifyCFG: Make the switch-to-lookup table transformation store the
tables in bitmaps when they fit in a target-legal register.

This saves some space, and it also allows for building tables that would
otherwise be deemed too sparse.

One interesting case that this hits is example 7 from
http://blog.regehr.org/archives/320. We currently generate good code
for this when lowering the switch to the selection DAG: we build a
bitmask to decide whether to jump to one block or the other. My patch
will result in the same bitmask, but it removes the need for the jump,
as the return value can just be retrieved from the mask.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164684 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/SimplifyCFG.cpp
test/Transforms/SimplifyCFG/switch_to_lookup_table.ll