[DAGCombiner] Convert constant AND masks to shuffle clear masks down to the byte...
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 1 Aug 2015 10:01:46 +0000 (10:01 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 1 Aug 2015 10:01:46 +0000 (10:01 +0000)
commit503a2594c3443729dc49ccfb3a5e07c6722ce0a3
treed764c5707b733143ac0704c709c3cfbece17c11f
parent45e7944bcfbcb8ef9739f6ef42fb50693f96ef22
[DAGCombiner] Convert constant AND masks to shuffle clear masks down to the byte level

The XformToShuffleWithZero method currently checks AND masks at the per-lane level for all-one and all-zero constants and attempts to convert them to legal shuffle clear masks.

This patch generalises XformToShuffleWithZero, splitting and checking the sub-lanes of the constants down to the byte level to see if any legal shuffle clear masks are possible. This allows a lot of masks (often from legalization or truncation) to be folded into existing shuffle patterns and removes a lot of constant mask loading.

There are a few examples of poor shuffle lowering that are exposed by this patch that will be cleaned up in future patches (e.g. merging shuffles that are separated by bitcasts, x86 legalized v8i8 zero extension uses PMOVZX+AND+AND instead of AND+PMOVZX, etc.)

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

llvm-svn: 243831
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/X86/avx2-conversions.ll
llvm/test/CodeGen/X86/masked_memop.ll
llvm/test/CodeGen/X86/sse2-vector-shifts.ll
llvm/test/CodeGen/X86/sse3.ll
llvm/test/CodeGen/X86/vec_cast2.ll
llvm/test/CodeGen/X86/vec_int_to_fp.ll
llvm/test/CodeGen/X86/vector-zext.ll
llvm/test/CodeGen/X86/vselect-avx.ll
llvm/test/CodeGen/X86/widen_load-2.ll