OSDN Git Service

[x86] Teach the target shuffle mask extraction to recognize unary forms
authorChandler Carruth <chandlerc@gmail.com>
Sat, 2 Aug 2014 10:27:38 +0000 (10:27 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sat, 2 Aug 2014 10:27:38 +0000 (10:27 +0000)
commitfb1293fd4cba5fc4745191b8bdb9c5543d5b9578
treea9cf2f452ec37e0c21a3bdd7d0b597b19ef9dd93
parent8a64a46c97c8f89355d1d370aeef3dfef390995b
[x86] Teach the target shuffle mask extraction to recognize unary forms
of normally binary shuffle instructions like PUNPCKL and MOVLHPS.

This detects cases where a single register is used for both operands
making the shuffle behave in a unary way. We detect this and adjust the
mask to use the unary form which allows the existing DAG combine for
shuffle instructions to actually work at all.

As a consequence, this uncovered a number of obvious bugs in the
existing DAG combine which are fixed. It also now canonicalizes several
shuffles even with the existing lowering. These typically are trying to
match the shuffle to the domain of the input where before we only really
modeled them with the floating point variants. All of the cases which
change to an integer shuffle here have something in the integer domain, so
there are no more or fewer domain crosses here AFAICT. Technically, it
might be better to go from a GPR directly to the floating point domain,
but detecting floating point *outputs* despite integer inputs is a lot
more code and seems unlikely to be worthwhile in practice. If folks are
seeing domain-crossing regressions here though, let me know and I can
hack something up to fix it.

Also as a consequence, a bunch of missed opportunities to form pshufb
now can be formed. Notably, splats of i8s now form pshufb.
Interestingly, this improves the existing splat lowering too. We go from
3 instructions to 1. Yes, we may tie up a register, but it seems very
likely to be worth it, especially if splatting the 0th byte (the
common case) as then we can use a zeroed register as the mask.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214625 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/avx-basic.ll
test/CodeGen/X86/avx-splat.ll
test/CodeGen/X86/exedepsfix-broadcast.ll
test/CodeGen/X86/vec_splat-3.ll