CodeGenPrep: turn lookup tables into switches for some targets.
authorHans Wennborg <hans@hanshq.net>
Wed, 19 Sep 2012 07:48:16 +0000 (07:48 +0000)
committerHans Wennborg <hans@hanshq.net>
Wed, 19 Sep 2012 07:48:16 +0000 (07:48 +0000)
commit93ba133906da4b12a7c732b897e64541cc570120
treecd97e0faeeb7ea03ea49307714e841716d478883
parent8a312fb3aaec90537d434a5cc41edf566ff80dca
CodeGenPrep: turn lookup tables into switches for some targets.

This is a follow-up from r163302, which added a transformation to
SimplifyCFG that turns some switches into loads from lookup tables.

It was pointed out that some targets, such as GPUs and deeply embedded
targets, might not find this appropriate, but SimplifyCFG doesn't have
enough information about the target to decide this.

This patch adds the reverse transformation to CodeGenPrep: it turns
loads from lookup tables back into switches for targets where we do not
build jump tables (assuming these are also the targets where lookup
tables are inappropriate).

Hopefully we will eventually get to have target information in
SimplifyCFG, and then this CodeGenPrep transformation can be removed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164206 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/CodeGenPrepare.cpp
test/Transforms/CodeGenPrepare/load_to_switch.ll [new file with mode: 0644]