SimplifyCFG: Turn switches into sub+icmp+branch if possible.
authorBenjamin Kramer <benny.kra@googlemail.com>
Wed, 2 Feb 2011 15:56:22 +0000 (15:56 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Wed, 2 Feb 2011 15:56:22 +0000 (15:56 +0000)
commit56442dfdcf7b07c04b585de5205b9427b1739895
tree93e69afd94be2799ef289cd14f0f02e73e5fb05b
parentff0c5014b2127b16815121d9e723dc85bd164a79
SimplifyCFG: Turn switches into sub+icmp+branch if possible.

This makes the job of the later optzn passes easier, allowing the vast amount of
icmp transforms to chew on it.

We transform 840 switches in gcc.c, leading to a 16k byte shrink of the resulting
binary on i386-linux.

The testcase from README.txt now compiles into
  decl  %edi
  cmpl  $3, %edi
  sbbl  %eax, %eax
  andl  $1, %eax
  ret

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124724 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/README.txt
lib/Transforms/Utils/SimplifyCFG.cpp
test/Transforms/SimplifyCFG/switch_create.ll
test/Transforms/SimplifyCFG/switch_formation.dbg.ll