[DAGCombiner] Add vector demanded elements support to computeKnownBits
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 27 Oct 2016 14:29:28 +0000 (14:29 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 27 Oct 2016 14:29:28 +0000 (14:29 +0000)
commit01e755eab11e45e3356f767b9fee66c1f986261c
tree3ef4ddb37fd72a426ec2b9f94698e6e4450a098c
parente0bde7554ce04ef7af99c69d526882a56f54a928
[DAGCombiner] Add vector demanded elements support to computeKnownBits

Currently computeKnownBits returns the common known zero/one bits for all elements of vector data, when we may only be interested in one/some of the elements.

This patch adds a DemandedElts argument that allows us to specify the elements we actually care about. The original computeKnownBits implementation calls with a DemandedElts demanding all elements to match current behaviour. Scalar types set this to 1.

The approach was found to be easier than trying to add a per-element known bits solution, for a similar usefulness given the combines where computeKnownBits is typically used.

I've only added support for a few opcodes so far (the ones that have proven straightforward to test), all others will default to demanding all elements but can be updated in due course.

DemandedElts support could similarly be added to computeKnownBitsForTargetNode in a future commit.

Differential Revision: https://reviews.llvm.org/D25691

llvm-svn: 285296
llvm/include/llvm/CodeGen/SelectionDAG.h
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/test/CodeGen/X86/avx-vperm2x128.ll
llvm/test/CodeGen/X86/known-bits-vector.ll