[x86] eliminate unnecessary shuffling/moves with unary scalar math ops (PR21507)
authorSanjay Patel <spatel@rotateright.com>
Thu, 7 May 2015 15:48:53 +0000 (15:48 +0000)
committerSanjay Patel <spatel@rotateright.com>
Thu, 7 May 2015 15:48:53 +0000 (15:48 +0000)
commit39cf5554292b7a82552b704c3905ab9e7557a9db
treef2e762f1d8f74096c2be65bc8fcae808545b93e1
parentee25f1e872ae3073e8303b218e6c1253bda267c1
[x86] eliminate unnecessary shuffling/moves with unary scalar math ops (PR21507)

Finish the job that was abandoned in D6958 following the refactoring in
http://reviews.llvm.org/rL230221:

1. Uncomment the intrinsic def for the AVX r_Int instruction.
2. Add missing r_Int entries to the load folding tables; there are already
   tests that check these in "test/Codegen/X86/fold-load-unops.ll", so I
   haven't added any more in this patch.
3. Add patterns to solve PR21507 ( https://llvm.org/bugs/show_bug.cgi?id=21507 ).

So instead of this:

  movaps %xmm0, %xmm1
  rcpss %xmm1, %xmm1
  movss %xmm1, %xmm0

We should now get:

  rcpss %xmm0, %xmm0

And instead of this:

  vsqrtss %xmm0, %xmm0, %xmm1
  vblendps $1, %xmm1, %xmm0, %xmm0 ## xmm0 = xmm1[0],xmm0[1,2,3]

We should now get:

  vsqrtss %xmm0, %xmm0, %xmm0

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236740 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86InstrInfo.cpp
lib/Target/X86/X86InstrSSE.td
test/CodeGen/X86/sse-scalar-fp-arith-unary.ll [new file with mode: 0644]