ARM: refactor optimizeThumb2JumpTables.
authorTim Northover <tnorthover@apple.com>
Wed, 13 May 2015 20:28:32 +0000 (20:28 +0000)
committerTim Northover <tnorthover@apple.com>
Wed, 13 May 2015 20:28:32 +0000 (20:28 +0000)
commitedd72727ad577d5cc6e06403f541251d161bee13
tree498626f631ace70aabd5e62a6065836bb7b575cd
parentac8a7cc8d20620debe201a7e1ca31e60446c082e
ARM: refactor optimizeThumb2JumpTables.

The previous logic mixed 2 separate questions:
  + Can we form a TBB/TBH instruction?
  + Can we remove the jump-table calculation before it?

It then performed a bunch of random tests on the instructions earlier in the
basic block, which were probably sufficient to answer 2 but only because of the
very limited ways in which a t2BR_JT can actually be created.

For example there's no reason to expect the LeaInst to define the same base
register as the following indexing calulation. In practice this means we might
have missed opportunities to form TBB/TBH, in theory you could end up
misidentifying a sequence and removing the wrong LEA:

     %R1 = t2LEApcrelJT ...
     %R2 = t2LEApcrelJT ...
     <... using and killing %R2 ...>
     %R2 = t2ADDr %R1, $Ridx

Before we would have looked for an LEA defining %R2 and found the wrong one. We
just got lucky that jump table setup was (almost?) always confined to a single
basic block and there was only one jump table per block.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237293 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/ARM/ARMConstantIslandPass.cpp