[PATCH] D30638: [SLP] Fixed non-determenistic behavior in Loop Vectorizer.
Amjad Aboud via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 6 03:37:08 PST 2017
aaboud created this revision.
Herald added a subscriber: mzolotukhin.
We should not iterate on Set container.
Added a SmallVector "CheckDepsList", which is used to keep the order when iterating over "CheckDeps" Set.
https://reviews.llvm.org/D30638
Files:
include/llvm/Analysis/LoopAccessAnalysis.h
lib/Analysis/LoopAccessAnalysis.cpp
Index: lib/Analysis/LoopAccessAnalysis.cpp
===================================================================
--- lib/Analysis/LoopAccessAnalysis.cpp
+++ lib/Analysis/LoopAccessAnalysis.cpp
@@ -499,6 +499,7 @@
/// \brief Read or write access location.
typedef PointerIntPair<Value *, 1, bool> MemAccessInfo;
typedef SmallPtrSet<MemAccessInfo, 8> MemAccessInfoSet;
+ typedef SmallVector<MemAccessInfo, 8> MemAccessInfoList;
AccessAnalysis(const DataLayout &Dl, AliasAnalysis *AA, LoopInfo *LI,
MemoryDepChecker::DepCandidates &DA,
@@ -547,10 +548,12 @@
/// We decided that no dependence analysis would be used. Reset the state.
void resetDepChecks(MemoryDepChecker &DepChecker) {
CheckDeps.clear();
+ CheckDepsList.clear();
DepChecker.clearDependences();
}
MemAccessInfoSet &getDependenciesToCheck() { return CheckDeps; }
+ MemAccessInfoList &getDependenciesListToCheck() { return CheckDepsList; }
private:
typedef SetVector<MemAccessInfo> PtrAccessSet;
@@ -566,6 +569,7 @@
/// Set of accesses that need a further dependence check.
MemAccessInfoSet CheckDeps;
+ MemAccessInfoList CheckDepsList;
/// Set of pointers that are read only.
SmallPtrSet<Value*, 16> ReadOnlyPtr;
@@ -823,6 +827,7 @@
// catch "a[i] = a[i] + " without having to do a dependence check).
if ((IsWrite || IsReadOnlyPtr) && SetHasWrite) {
CheckDeps.insert(Access);
+ CheckDepsList.push_back(Access);
IsRTCheckAnalysisNeeded = true;
}
@@ -1547,11 +1552,13 @@
bool MemoryDepChecker::areDepsSafe(DepCandidates &AccessSets,
MemAccessInfoSet &CheckDeps,
+ MemAccessInfoList &CheckDepsList,
const ValueToValueMap &Strides) {
MaxSafeDepDistBytes = -1;
- while (!CheckDeps.empty()) {
- MemAccessInfo CurAccess = *CheckDeps.begin();
+ for (MemAccessInfo CurAccess : CheckDepsList) {
+ if (!CheckDeps.count(CurAccess))
+ continue;
// Get the relevant memory access set.
EquivalenceClasses<MemAccessInfo>::iterator I =
@@ -1873,7 +1880,8 @@
if (Accesses.isDependencyCheckNeeded()) {
DEBUG(dbgs() << "LAA: Checking memory dependencies\n");
CanVecMem = DepChecker->areDepsSafe(
- DependentAccesses, Accesses.getDependenciesToCheck(), SymbolicStrides);
+ DependentAccesses, Accesses.getDependenciesToCheck(),
+ Accesses.getDependenciesListToCheck(), SymbolicStrides);
MaxSafeDepDistBytes = DepChecker->getMaxSafeDepDistBytes();
if (!CanVecMem && DepChecker->shouldRetryWithRuntimeCheck()) {
Index: include/llvm/Analysis/LoopAccessAnalysis.h
===================================================================
--- include/llvm/Analysis/LoopAccessAnalysis.h
+++ include/llvm/Analysis/LoopAccessAnalysis.h
@@ -94,6 +94,7 @@
public:
typedef PointerIntPair<Value *, 1, bool> MemAccessInfo;
typedef SmallPtrSet<MemAccessInfo, 8> MemAccessInfoSet;
+ typedef SmallVector<MemAccessInfo, 8> MemAccessInfoList;
/// \brief Set of potential dependent memory accesses.
typedef EquivalenceClasses<MemAccessInfo> DepCandidates;
@@ -189,6 +190,7 @@
///
/// Only checks sets with elements in \p CheckDeps.
bool areDepsSafe(DepCandidates &AccessSets, MemAccessInfoSet &CheckDeps,
+ MemAccessInfoList &CheckDepsList,
const ValueToValueMap &Strides);
/// \brief No memory dependence was encountered that would inhibit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30638.90668.patch
Type: text/x-patch
Size: 3634 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170306/027aaa94/attachment.bin>
More information about the llvm-commits
mailing list