[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)
commitfa2c240c15a78c8f571442a68a57c0536cee5aec
tree3ca0ea896d5251fdd31b71c4bc1d3f21c8a8e2c0
parentb80eede6419ce4fa011bd1b27aae1c76ce2a2f3f
[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243831 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/X86/avx2-conversions.ll
test/CodeGen/X86/masked_memop.ll
test/CodeGen/X86/sse2-vector-shifts.ll
test/CodeGen/X86/sse3.ll
test/CodeGen/X86/vec_cast2.ll
test/CodeGen/X86/vec_int_to_fp.ll
test/CodeGen/X86/vector-zext.ll
test/CodeGen/X86/vselect-avx.ll
test/CodeGen/X86/widen_load-2.ll