[DAGCombiner] (REAPPLIED) Add vector demanded elements support to computeKnownBits
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 29 Oct 2016 11:29:39 +0000 (11:29 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 29 Oct 2016 11:29:39 +0000 (11:29 +0000)
commit75a697a17ea3084fadb83737227f36c142a3c7bb
tree839260a25f3b9a9eccd047e896534907b25c905a
parent25eb42023355f0f575f496391715a69a441a8346
[DAGCombiner] (REAPPLIED) 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.

This looked like this had caused compile time regressions on some buildbots (and was reverted in rL285381), but appears to have just been a harmless bystander!

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

llvm-svn: 285494
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