summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2012-10-18 18:34:50 +0000
committerNadav Rotem <nrotem@apple.com>2012-10-18 18:34:50 +0000
commitb943d9d497175ce44cca7b7bb14b83a86dba7d76 (patch)
tree43444362525d8d06c74aacbaf3e6495d79a2d45a
parente700f060540b6898424e3d1ea1b78dbfbad97737 (diff)
Avoid reconstructing the pointer set when searching for duplicated read/write pointers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166205 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Vectorize/LoopVectorize.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp
index cb671633e0d..9bbd9ab60b7 100644
--- a/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -166,7 +166,7 @@ private:
// Check if a pointer value is known to be disjoint.
// Example: Alloca, Global, NoAlias.
- bool isKnownDisjoint(Value* Val);
+ bool isidentifiedSafeObject(Value* Val);
/// The loop that we evaluate.
Loop *TheLoop;
@@ -818,34 +818,31 @@ bool LoopVectorizationLegality::canVectorizeBlock(BasicBlock &BB) {
// disjoint memory locations, or that they are no-alias arguments.
ValueVector::iterator r, re, w, we;
for (r = Reads.begin(), re = Reads.end(); r != re; ++r) {
- if (!isKnownDisjoint(*r)) {
+ if (!isidentifiedSafeObject(*r)) {
DEBUG(dbgs() << "LV: Found a bad read Ptr: "<< **r << "\n");
return false;
}
}
for (w = Writes.begin(), we = Writes.end(); w != we; ++w) {
- if (!isKnownDisjoint(*w)) {
+ if (!isidentifiedSafeObject(*w)) {
DEBUG(dbgs() << "LV: Found a bad write Ptr: "<< **w << "\n");
return false;
}
}
// Check that there are no multiple write locations to the same pointer.
- SmallPtrSet<Value*, 8> BasePointers;
+ SmallPtrSet<Value*, 8> WritePointerSet;
for (w = Writes.begin(), we = Writes.end(); w != we; ++w) {
- if (BasePointers.count(*w)) {
+ if (!WritePointerSet.insert(*w)) {
DEBUG(dbgs() << "LV: Multiple writes to the same index :"<< **w << "\n");
return false;
}
- BasePointers.insert(*w);
}
- // Sort the writes vector so that we can use a binary search.
- std::sort(Writes.begin(), Writes.end());
// Check that the reads and the writes are disjoint.
for (r = Reads.begin(), re = Reads.end(); r != re; ++r) {
- if (std::binary_search(Writes.begin(), Writes.end(), *r)) {
+ if (WritePointerSet.count(*r)) {
DEBUG(dbgs() << "Vectorizer: Found a read/write ptr:"<< **r << "\n");
return false;
}
@@ -857,7 +854,7 @@ bool LoopVectorizationLegality::canVectorizeBlock(BasicBlock &BB) {
/// Checks if the value is a Global variable or if it is an Arguments
/// marked with the NoAlias attribute.
-bool LoopVectorizationLegality::isKnownDisjoint(Value* Val) {
+bool LoopVectorizationLegality::isidentifiedSafeObject(Value* Val) {
assert(Val && "Invalid value");
if (dyn_cast<GlobalValue>(Val))
return true;