diff options
author | Dorit Nuzman <dorit.nuzman@intel.com> | 2018-10-31 09:57:56 +0000 |
---|---|---|
committer | Dorit Nuzman <dorit.nuzman@intel.com> | 2018-10-31 09:57:56 +0000 |
commit | 34da6dd696439e195e7b650d97a95913101a88d9 (patch) | |
tree | a718d6a89ceb39ada3675f96f8de45c051e8ce7f /llvm/lib/Analysis/VectorUtils.cpp | |
parent | 889356eb719ded45c708514fb03777f705eb5934 (diff) | |
download | bcm5719-llvm-34da6dd696439e195e7b650d97a95913101a88d9.tar.gz bcm5719-llvm-34da6dd696439e195e7b650d97a95913101a88d9.zip |
[LV] Support vectorization of interleave-groups that require an epilog under
optsize using masked wide loads
Under Opt for Size, the vectorizer does not vectorize interleave-groups that
have gaps at the end of the group (such as a loop that reads only the even
elements: a[2*i]) because that implies that we'll require a scalar epilogue
(which is not allowed under Opt for Size). This patch extends the support for
masked-interleave-groups (introduced by D53011 for conditional accesses) to
also cover the case of gaps in a group of loads; Targets that enable the
masked-interleave-group feature don't have to invalidate interleave-groups of
loads with gaps; they could now use masked wide-loads and shuffles (if that's
what the cost model selects).
Reviewers: Ayal, hsaito, dcaballe, fhahn
Reviewed By: Ayal
Differential Revision: https://reviews.llvm.org/D53668
llvm-svn: 345705
Diffstat (limited to 'llvm/lib/Analysis/VectorUtils.cpp')
-rw-r--r-- | llvm/lib/Analysis/VectorUtils.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp index 8b6702c8544..38dca50e82a 100644 --- a/llvm/lib/Analysis/VectorUtils.cpp +++ b/llvm/lib/Analysis/VectorUtils.cpp @@ -504,6 +504,25 @@ Instruction *llvm::propagateMetadata(Instruction *Inst, ArrayRef<Value *> VL) { return Inst; } +Constant *llvm::createBitMaskForGaps(IRBuilder<> &Builder, unsigned VF, + const InterleaveGroup &Group) { + // All 1's means mask is not needed. + if (Group.getNumMembers() == Group.getFactor()) + return nullptr; + + // TODO: support reversed access. + assert(!Group.isReverse() && "Reversed group not supported."); + + SmallVector<Constant *, 16> Mask; + for (unsigned i = 0; i < VF; i++) + for (unsigned j = 0; j < Group.getFactor(); ++j) { + unsigned HasMember = Group.getMember(j) ? 1 : 0; + Mask.push_back(Builder.getInt1(HasMember)); + } + + return ConstantVector::get(Mask); +} + Constant *llvm::createReplicatedMask(IRBuilder<> &Builder, unsigned ReplicationFactor, unsigned VF) { SmallVector<Constant *, 16> MaskVec; @@ -935,9 +954,10 @@ void InterleavedAccessInfo::invalidateGroupsRequiringScalarEpilogue() { } for (auto *Ptr : DelSet) { LLVM_DEBUG( - dbgs() + dbgs() << "LV: Invalidate candidate interleaved group due to gaps that " - "require a scalar epilogue.\n"); + "require a scalar epilogue (not allowed under optsize) and cannot " + "be masked (not enabled). \n"); releaseGroup(Ptr); } |