Reapply [FastISel] Let the target decide first if it wants to materialize a constant...
authorJuergen Ributzka <juergen@apple.com>
Tue, 19 Aug 2014 19:05:24 +0000 (19:05 +0000)
committerJuergen Ributzka <juergen@apple.com>
Tue, 19 Aug 2014 19:05:24 +0000 (19:05 +0000)
commitf08cddcf560b1eb8401d405501e26cf3c3843fb4
tree4d5d552d1fd0c1ec81aa5ae23606e8a1a5afedb1
parentf2b844d0b1d1cf62ba172f97981840fa9ccdf693
Reapply [FastISel] Let the target decide first if it wants to materialize a constant (215588).

Note: This was originally reverted to track down a buildbot error. This commit
exposed a latent bug that was fixed in r215753. Therefore it is reapplied
without any modifications.

I run it through SPEC2k and SPEC2k6 for AArch64 and it didn't introduce any new
regeressions.

Original commit message:
This changes the order in which FastISel tries to materialize a constant.
Originally it would try to use a simple target-independent approach, which
can lead to the generation of inefficient code.

On X86 this would result in the use of movabsq to materialize any 64bit
integer constant - even for simple and small values such as 0 and 1. Also
some very funny floating-point materialization could be observed too.

On AArch64 it would materialize the constant 0 in a register even the
architecture has an actual "zero" register.

On ARM it would generate unnecessary mov instructions or not use mvn.

This change simply changes the order and always asks the target first if it
likes to materialize the constant. This doesn't fix all the issues
mentioned above, but it enables the targets to implement such
optimizations.

Related to <rdar://problem/17420988>.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216006 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/CodeGen/FastISel.h
lib/CodeGen/SelectionDAG/FastISel.cpp
test/CodeGen/ARM/fast-isel-call.ll
test/CodeGen/ARM/fast-isel-deadcode.ll
test/CodeGen/ARM/fast-isel-intrinsic.ll
test/CodeGen/ARM/fast-isel-mvn.ll
test/CodeGen/ARM/fast-isel-select.ll
test/CodeGen/ARM/fast-isel-vararg.ll
test/CodeGen/PowerPC/fast-isel-call.ll
test/CodeGen/X86/fast-isel-x86-64.ll