Enhance SRoA to promote allocas that are used by selects in some
authorChris Lattner <sabre@nondot.org>
Sun, 23 Jan 2011 22:04:55 +0000 (22:04 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 23 Jan 2011 22:04:55 +0000 (22:04 +0000)
commitc87c50a39c1bc27437352feee0f6aba2d50fa1b5
tree6703aad0252af11e7c6e9f92c99267bcdf99c431
parent3928af6ac47f9abef7dff32823a5fd41743c8fbc
Enhance SRoA to promote allocas that are used by selects in some
common cases.  This triggers a surprising number of times in SPEC2K6
because min/max idioms end up doing this.  For example, code from the
STL ends up looking like this to SRoA:

  %202 = load i64* %__old_size, align 8, !tbaa !3
  %203 = load i64* %__old_size, align 8, !tbaa !3
  %204 = load i64* %__n, align 8, !tbaa !3
  %205 = icmp ult i64 %203, %204
  %storemerge.i = select i1 %205, i64* %__n, i64* %__old_size
  %206 = load i64* %storemerge.i, align 8, !tbaa !3

We can now promote both the __n and the __old_size allocas.

This addresses another chunk of rdar://7339113, poor codegen on
stringswitch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124088 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/ScalarReplAggregates.cpp
test/Transforms/ScalarRepl/phi-select.ll