aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-03-29 04:52:12 +0000
committerChris Lattner <sabre@nondot.org>2008-03-29 04:52:12 +0000
commitd22fe2b51f553f7eca200cd22b9e2247f9aea2ff (patch)
tree8b6c1e3959844b439a7515fa6b7ae6159fc7917f /lib
parentf83e13ae0a4eba4a1fc8b5d25a37c427e67b7f0c (diff)
downloadexternal_llvm-d22fe2b51f553f7eca200cd22b9e2247f9aea2ff.zip
external_llvm-d22fe2b51f553f7eca200cd22b9e2247f9aea2ff.tar.gz
external_llvm-d22fe2b51f553f7eca200cd22b9e2247f9aea2ff.tar.bz2
make the common case of a single store (which clearly shouldn't be turned
into a memset!) faster by avoiding an allocation of an std::list node. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48939 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/GVN.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index 636590d..42418f0 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -1182,7 +1182,7 @@ public:
typedef std::list<MemsetRange>::const_iterator const_iterator;
const_iterator begin() const { return Ranges.begin(); }
const_iterator end() const { return Ranges.end(); }
-
+ bool empty() const { return Ranges.empty(); }
void addStore(int64_t OffsetFromFirst, StoreInst *SI);
};
@@ -1281,8 +1281,6 @@ bool GVN::processStore(StoreInst *SI, SmallVectorImpl<Instruction*> &toErase) {
// are stored.
MemsetRanges Ranges(TD);
- // Add our first pointer.
- Ranges.addStore(0, SI);
Value *StartPtr = SI->getPointerOperand();
BasicBlock::iterator BI = SI;
@@ -1319,6 +1317,17 @@ bool GVN::processStore(StoreInst *SI, SmallVectorImpl<Instruction*> &toErase) {
Ranges.addStore(Offset, NextStore);
}
+
+ // If we have no ranges, then we just had a single store with nothing that
+ // could be merged in. This is a very common case of course.
+ if (Ranges.empty())
+ return false;
+
+ // If we had at least one store that could be merged in, add the starting
+ // store as well. We try to avoid this unless there is at least something
+ // interesting as a small compile-time optimization.
+ Ranges.addStore(0, SI);
+
Function *MemSetF = 0;