From b943d9d497175ce44cca7b7bb14b83a86dba7d76 Mon Sep 17 00:00:00 2001 From: Nadav Rotem Date: Thu, 18 Oct 2012 18:34:50 +0000 Subject: 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 --- lib/Transforms/Vectorize/LoopVectorize.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'lib') 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 BasePointers; + SmallPtrSet 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(Val)) return true; -- cgit v1.2.3