Optimize vector fabs of bitcasted constant integer values.
authorSanjay Patel <spatel@rotateright.com>
Tue, 5 Aug 2014 17:35:22 +0000 (17:35 +0000)
committerSanjay Patel <spatel@rotateright.com>
Tue, 5 Aug 2014 17:35:22 +0000 (17:35 +0000)
commit8e5beb6edbb54350249e9f79affea9aac6f3b57f
tree96ef91bc2b719c93ffb36545fcbe59012621670e
parent5bf7baa938b316047b897d5652d41227776dbc33
Optimize vector fabs of bitcasted constant integer values.

Allow vector fabs operations on bitcasted constant integer values to be optimized
in the same way that we already optimize scalar fabs.

So for code like this:
%bitcast = bitcast i64 18446744069414584320 to <2 x float> ; 0xFFFF_FFFF_0000_0000
%fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %bitcast)
%ret = bitcast <2 x float> %fabs to i64

Instead of generating something like this:

movabsq (constant pool loadi of mask for sign bits)
vmovq   (move from integer register to vector/fp register)
vandps  (mask off sign bits)
vmovq   (move vector/fp register back to integer return register)

We should generate:

mov     (put constant value in return register)

I have also removed a redundant clause in the first 'if' statement:
N0.getOperand(0).getValueType().isInteger()

is the same thing as:
IntVT.isInteger()

Testcases for x86 and ARM added to existing files that deal with vector fabs.
One existing testcase for x86 removed because it is no longer ideal.

For more background, please see:
http://reviews.llvm.org/D4770

And:
http://llvm.org/bugs/show_bug.cgi?id=20354

Differential Revision: http://reviews.llvm.org/D4785

llvm-svn: 214892
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/ARM/fabs-neon.ll
llvm/test/CodeGen/X86/vec_fabs.ll