[SLP] Distinguish "demanded and shrinkable" from "demanded and not shrinkable" values...
authorHaicheng Wu <haicheng@codeaurora.org>
Tue, 3 Apr 2018 00:05:10 +0000 (00:05 +0000)
committerHaicheng Wu <haicheng@codeaurora.org>
Tue, 3 Apr 2018 00:05:10 +0000 (00:05 +0000)
commit7f0daaeb865c4be417bc5810d8d5f2963bb20c44
treede2c3e3663b379658d417a50228e67999671e106
parent7d6131a898690f4b4bd6de64ef863125f50973ec
[SLP] Distinguish "demanded and shrinkable" from "demanded and not shrinkable" values when determining the minimum bitwidth

We use two approaches for determining the minimum bitwidth.

   * Demanded bits
   * Value tracking

If demanded bits doesn't result in a narrower type, we then try value tracking.
We need this if we want to root SLP trees with the indices of getelementptr
instructions since all the bits of the indices are demanded.

But there is a missing piece though. We need to be able to distinguish "demanded
and shrinkable" from "demanded and not shrinkable". For example, the bits of %i
in

%i = sext i32 %e1 to i64
%gep = getelementptr inbounds i64, i64* %p, i64 %i

are demanded, but we can shrink %i's type to i32 because it won't change the
result of the getelementptr. On the other hand, in

%tmp15 = sext i32 %tmp14 to i64
%tmp16 = insertvalue { i64, i64 } undef, i64 %tmp15, 0

it doesn't make sense to shrink %tmp15 and we can skip the value tracking.

Ideas are from Matthew Simpson!

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

llvm-svn: 329035
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/AArch64/ext-trunc.ll
llvm/test/Transforms/SLPVectorizer/X86/partail.ll