[LV] Teach vectorizer about variant value store into uniform address
Summary:
Teach vectorizer about vectorizing variant value stores to uniform
address. Similar to rL343028, we do not allow vectorization if we have
multiple stores to the same uniform address.
Cost model already has the change for considering the extract
instruction cost for a variant value store. See added test cases for how
vectorization is done.
The patch also contains changes to the ORE messages.
Reviewers: Ayal, mkuper, anemet, hsaito
Subscribers: rkruppe, llvm-commits
Differential Revision: https://reviews.llvm.org/D52656
llvm-svn: 344613
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index b43e290..4b8e8af 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1869,13 +1869,9 @@
for (StoreInst *ST : Stores) {
Value *Ptr = ST->getPointerOperand();
- if (isUniform(Ptr)) {
- // Consider multiple stores to the same uniform address as a store of a
- // variant value.
- bool MultipleStoresToUniformPtr = !UniformStores.insert(Ptr).second;
- HasVariantStoreToLoopInvariantAddress |=
- (!isUniform(ST->getValueOperand()) || MultipleStoresToUniformPtr);
- }
+ if (isUniform(Ptr))
+ HasMultipleStoresToLoopInvariantAddress |=
+ !UniformStores.insert(Ptr).second;
// If we did *not* see this pointer before, insert it to the read-write
// list. At this phase it is only a 'write' list.
@@ -2276,7 +2272,7 @@
PtrRtChecking(llvm::make_unique<RuntimePointerChecking>(SE)),
DepChecker(llvm::make_unique<MemoryDepChecker>(*PSE, L)), TheLoop(L),
NumLoads(0), NumStores(0), MaxSafeDepDistBytes(-1), CanVecMem(false),
- HasVariantStoreToLoopInvariantAddress(false) {
+ HasMultipleStoresToLoopInvariantAddress(false) {
if (canAnalyzeLoop())
analyzeLoop(AA, LI, TLI, DT);
}
@@ -2308,8 +2304,8 @@
PtrRtChecking->print(OS, Depth);
OS << "\n";
- OS.indent(Depth) << "Variant Store to invariant address was "
- << (HasVariantStoreToLoopInvariantAddress ? "" : "not ")
+ OS.indent(Depth) << "Multiple stores to invariant address were "
+ << (HasMultipleStoresToLoopInvariantAddress ? "" : "not ")
<< "found in loop.\n";
OS.indent(Depth) << "SCEV assumptions:\n";