[x86] Teach the vector combiner that picks a canonical shuffle from to
authorChandler Carruth <chandlerc@gmail.com>
Sun, 14 Sep 2014 22:41:37 +0000 (22:41 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sun, 14 Sep 2014 22:41:37 +0000 (22:41 +0000)
commit33957173a7ebbb15caab409204761eb671002388
treeccb07f0252330f14ec6daeb37684e2d3db3dc50e
parente1c77ca37a3c27064262bfdc22d0f3e62a4b789f
[x86] Teach the vector combiner that picks a canonical shuffle from to
support transforming the forms from the new vector shuffle lowering to
use 'movddup' when appropriate.

A bunch of the cases where we actually form 'movddup' don't actually
show up in the test results because something even later than DAG
legalization maps them back to 'unpcklpd'. If this shows back up as
a performance problem, I'll probably chase it down, but it is at least
an encoded size loss. =/

To make this work, also always do this canonicalizing step for floating
point vectors where the baseline shuffle instructions don't provide any
free copies of their inputs. This also causes us to canonicalize
unpck[hl]pd into mov{hl,lh}ps (resp.) which is a nice encoding space
win.

There is one test which is "regressed" by this: extractelement-load.
There, the test case where the optimization it is testing *fails*, the
exact instruction pattern which results is slightly different. This
should probably be fixed by having the appropriate extract formed
earlier in the DAG, but that would defeat the purpose of the test.... If
this test case is critically important for anyone, please let me know
and I'll try to work on it. The prior behavior was actually contrary to
the comment in the test case and seems likely to have been an accident.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217738 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/avx-splat.ll
test/CodeGen/X86/combine-vec-shuffle-4.ll
test/CodeGen/X86/extractelement-load.ll
test/CodeGen/X86/vec_extract.ll
test/CodeGen/X86/vec_shuffle-38.ll
test/CodeGen/X86/vec_splat.ll
test/CodeGen/X86/vector-shuffle-128-v2.ll
test/CodeGen/X86/vector-shuffle-256-v4.ll