diff options
author | Philip Reames <listmail@philipreames.com> | 2019-01-28 23:24:49 +0000 |
---|---|---|
committer | Philip Reames <listmail@philipreames.com> | 2019-01-28 23:24:49 +0000 |
commit | 6c5341bc5a127d967944d1ae64c643efe44e96ff (patch) | |
tree | b1b26a536290c7f1680ac9c90caa51289131619b /llvm/lib/Transforms | |
parent | f0e676819fae4687f783e62b245a14ad8f9bb12a (diff) | |
download | bcm5719-llvm-6c5341bc5a127d967944d1ae64c643efe44e96ff.tar.gz bcm5719-llvm-6c5341bc5a127d967944d1ae64c643efe44e96ff.zip |
Demanded elements support for vector GEPs
GEPs can produce either scalar or vector results. If we're extracting only a subset of the vector lanes, simplifying the operands is helpful in eliminating redundant computation, and (eventually) allowing further optimizations
Differential Revision: https://reviews.llvm.org/D57177
llvm-svn: 352440
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp index ab25c1c171a..b2863b0c865 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp @@ -1183,6 +1183,18 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, switch (I->getOpcode()) { default: break; + case Instruction::GetElementPtr: { + // Conservatively track the demanded elements back through any vector + // operands we may have. We know there must be at least one, or we + // wouldn't have a vector result to get here. Note that we intentionally + // merge the undef bits here since gepping with either an undef base or + // index results in undef. + for (unsigned i = 0; i < I->getNumOperands(); i++) + if (I->getOperand(i)->getType()->isVectorTy()) + simplifyAndSetOp(I, i, DemandedElts, UndefElts); + + break; + } case Instruction::InsertElement: { // If this is a variable index, we don't know which element it overwrites. // demand exactly the same input as we produce. |