[x86] Combine x86mmx/i64 to v2i64 conversion to use scalar_to_vector
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Fri, 23 Jan 2015 22:44:16 +0000 (22:44 +0000)
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Fri, 23 Jan 2015 22:44:16 +0000 (22:44 +0000)
commit807360ab087a0d2d9ef056f4d737fc93a3feaaf0
treeead0bcef9899855ba7348a412e9ba7e011e3a90c
parent4c61bbe673c58c4a973542cf7e911ec81ecaebb7
[x86] Combine x86mmx/i64 to v2i64 conversion to use scalar_to_vector

Handle the poor codegen for i64/x86xmm->v2i64 (%mm -> %xmm) moves. Instead of
using stack store/load pair to do the job, use scalar_to_vector directly, which
in the MMX case can use movq2dq. This was the current behavior prior to
improvements for vector legalization of extloads in r213897.

This commit fixes the regression and as a side-effect also remove some
unnecessary shuffles.

In the new attached testcase, we go from:

pshufw  $-18, (%rdi), %mm0
movq    %mm0, -8(%rsp)
movq    -8(%rsp), %xmm0
pshufd  $-44, %xmm0, %xmm0
movd    %xmm0, %eax
...

To:

pshufw  $-18, (%rdi), %mm0
movq2dq %mm0, %xmm0
movd    %xmm0, %eax
...

Differential Revision: http://reviews.llvm.org/D7126
rdar://problem/19413324

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226953 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/2012-01-18-vbitcast.ll
test/CodeGen/X86/lower-bitcast.ll
test/CodeGen/X86/mmx-movq2dq.ll [new file with mode: 0644]
test/CodeGen/X86/widen_load-2.ll