aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-06-29 17:52:08 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-06-29 17:52:08 +0000
commit97b808bf70010c8784aa303870e8a0281cf624e6 (patch)
treeb91d5d0dc2176ec93ed3077d054dc0d8be3c114a /lib
parent3298179fc15eebfeafdb65aab7512926135b7b39 (diff)
downloadexternal_llvm-97b808bf70010c8784aa303870e8a0281cf624e6.zip
external_llvm-97b808bf70010c8784aa303870e8a0281cf624e6.tar.gz
external_llvm-97b808bf70010c8784aa303870e8a0281cf624e6.tar.bz2
LoopVectorizer: Pack MemAccessInfo pairs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185263 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Vectorize/LoopVectorize.cpp47
1 files changed, 22 insertions, 25 deletions
diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp
index 6c698df..f41bd28 100644
--- a/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2864,7 +2864,8 @@ namespace {
class AccessAnalysis {
public:
/// \brief Read or write access location.
- typedef std::pair<Value*, char> MemAccessInfo;
+ typedef PointerIntPair<Value *, 1, bool> MemAccessInfo;
+ typedef SmallPtrSet<MemAccessInfo, 8> MemAccessInfoSet;
/// \brief Set of potential dependent memory accesses.
typedef EquivalenceClasses<MemAccessInfo> DepCandidates;
@@ -2875,14 +2876,14 @@ public:
/// \brief Register a load and whether it is only read from.
void addLoad(Value *Ptr, bool IsReadOnly) {
- Accesses.insert(std::make_pair(Ptr, false));
+ Accesses.insert(MemAccessInfo(Ptr, false));
if (IsReadOnly)
ReadOnlyPtr.insert(Ptr);
}
/// \brief Register a store.
void addStore(Value *Ptr) {
- Accesses.insert(std::make_pair(Ptr, true));
+ Accesses.insert(MemAccessInfo(Ptr, true));
}
/// \brief Check whether we can check the pointers at runtime for
@@ -2904,7 +2905,7 @@ public:
bool isDependencyCheckNeeded() { return !CheckDeps.empty(); }
- DenseSet<MemAccessInfo> &getDependenciesToCheck() { return CheckDeps; }
+ MemAccessInfoSet &getDependenciesToCheck() { return CheckDeps; }
private:
typedef SetVector<MemAccessInfo> PtrAccessSet;
@@ -2925,7 +2926,7 @@ private:
UnderlyingObjToAccessMap ObjToLastAccess;
/// Set of accesses that need a further dependence check.
- DenseSet<MemAccessInfo> CheckDeps;
+ MemAccessInfoSet CheckDeps;
/// Set of pointers that are read only.
SmallPtrSet<Value*, 16> ReadOnlyPtr;
@@ -2976,11 +2977,11 @@ bool AccessAnalysis::canCheckPtrAtRT(
for (PtrAccessSet::iterator AI = Accesses.begin(), AE = Accesses.end();
AI != AE; ++AI) {
const MemAccessInfo &Access = *AI;
- Value *Ptr = Access.first;
- bool IsWrite = Access.second;
+ Value *Ptr = Access.getPointer();
+ bool IsWrite = Access.getInt();
// Just add write checks if we have both.
- if (!IsWrite && Accesses.count(std::make_pair(Ptr, true)))
+ if (!IsWrite && Accesses.count(MemAccessInfo(Ptr, true)))
continue;
if (IsWrite)
@@ -2993,7 +2994,7 @@ bool AccessAnalysis::canCheckPtrAtRT(
unsigned DepId;
if (IsDepCheckNeeded) {
- Value *Leader = DepCands.getLeaderValue(Access).first;
+ Value *Leader = DepCands.getLeaderValue(Access).getPointer();
unsigned &LeaderId = DepSetId[Leader];
if (!LeaderId)
LeaderId = RunningDepId++;
@@ -3030,8 +3031,8 @@ void AccessAnalysis::processMemAccesses(bool UseDeferred) {
PtrAccessSet &S = UseDeferred ? DeferredAccesses : Accesses;
for (PtrAccessSet::iterator AI = S.begin(), AE = S.end(); AI != AE; ++AI) {
const MemAccessInfo &Access = *AI;
- Value *Ptr = Access.first;
- bool IsWrite = Access.second;
+ Value *Ptr = Access.getPointer();
+ bool IsWrite = Access.getInt();
DepCands.insert(Access);
@@ -3140,7 +3141,8 @@ namespace {
///
class MemoryDepChecker {
public:
- typedef std::pair<Value*, char> MemAccessInfo;
+ typedef PointerIntPair<Value *, 1, bool> MemAccessInfo;
+ typedef SmallPtrSet<MemAccessInfo, 8> MemAccessInfoSet;
MemoryDepChecker(ScalarEvolution *Se, DataLayout *Dl, const Loop *L) :
SE(Se), DL(Dl), InnermostLoop(L), AccessIdx(0) {}
@@ -3149,7 +3151,7 @@ public:
/// of a write access.
void addAccess(StoreInst *SI) {
Value *Ptr = SI->getPointerOperand();
- Accesses[std::make_pair(Ptr, true)].push_back(AccessIdx);
+ Accesses[MemAccessInfo(Ptr, true)].push_back(AccessIdx);
InstMap.push_back(SI);
++AccessIdx;
}
@@ -3158,7 +3160,7 @@ public:
/// of a write access.
void addAccess(LoadInst *LI) {
Value *Ptr = LI->getPointerOperand();
- Accesses[std::make_pair(Ptr, false)].push_back(AccessIdx);
+ Accesses[MemAccessInfo(Ptr, false)].push_back(AccessIdx);
InstMap.push_back(LI);
++AccessIdx;
}
@@ -3167,7 +3169,7 @@ public:
///
/// Only checks sets with elements in \p CheckDeps.
bool areDepsSafe(AccessAnalysis::DepCandidates &AccessSets,
- DenseSet<MemAccessInfo> &CheckDeps);
+ MemAccessInfoSet &CheckDeps);
/// \brief The maximum number of bytes of a vector register we can vectorize
/// the accesses safely with.
@@ -3331,10 +3333,10 @@ bool MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
const MemAccessInfo &B, unsigned BIdx) {
assert (AIdx < BIdx && "Must pass arguments in program order");
- Value *APtr = A.first;
- Value *BPtr = B.first;
- bool AIsWrite = A.second;
- bool BIsWrite = B.second;
+ Value *APtr = A.getPointer();
+ Value *BPtr = B.getPointer();
+ bool AIsWrite = A.getInt();
+ bool BIsWrite = B.getInt();
// Two reads are independent.
if (!AIsWrite && !BIsWrite)
@@ -3450,7 +3452,7 @@ bool MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
bool
MemoryDepChecker::areDepsSafe(AccessAnalysis::DepCandidates &AccessSets,
- DenseSet<MemAccessInfo> &CheckDeps) {
+ MemAccessInfoSet &CheckDeps) {
MaxSafeDepDistBytes = -1U;
while (!CheckDeps.empty()) {
@@ -3492,11 +3494,6 @@ bool LoopVectorizationLegality::canVectorizeMemory() {
typedef SmallVector<Value*, 16> ValueVector;
typedef SmallPtrSet<Value*, 16> ValueSet;
- // Stores a pair of memory access location and whether the access is a store
- // (true) or a load (false).
- typedef std::pair<Value*, char> MemAccessInfo;
- typedef DenseSet<MemAccessInfo> PtrAccessSet;
-
// Holds the Load and Store *instructions*.
ValueVector Loads;
ValueVector Stores;