aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar/EarlyCSE.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-01-03 03:46:34 +0000
committerChris Lattner <sabre@nondot.org>2011-01-03 03:46:34 +0000
commitef87fc2e0a19c3da55c596244e71e2ad03ae4b43 (patch)
tree0e8aaaede98f8e1e91fab26666912bd140899ae2 /lib/Transforms/Scalar/EarlyCSE.cpp
parent85db61066a370f5d6e2d3c667eb5fa02493593c7 (diff)
downloadexternal_llvm-ef87fc2e0a19c3da55c596244e71e2ad03ae4b43.zip
external_llvm-ef87fc2e0a19c3da55c596244e71e2ad03ae4b43.tar.gz
external_llvm-ef87fc2e0a19c3da55c596244e71e2ad03ae4b43.tar.bz2
now that loads are in their own table, we can implement
store->load forwarding. This allows EarlyCSE to zap 600 more loads from 176.gcc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122732 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/EarlyCSE.cpp')
-rw-r--r--lib/Transforms/Scalar/EarlyCSE.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/EarlyCSE.cpp b/lib/Transforms/Scalar/EarlyCSE.cpp
index a899640..06c1b91 100644
--- a/lib/Transforms/Scalar/EarlyCSE.cpp
+++ b/lib/Transforms/Scalar/EarlyCSE.cpp
@@ -380,8 +380,19 @@ bool EarlyCSE::processNode(DomTreeNode *Node) {
// Okay, this isn't something we can CSE at all. Check to see if it is
// something that could modify memory. If so, our available memory values
// cannot be used so bump the generation count.
- if (Inst->mayWriteToMemory())
+ if (Inst->mayWriteToMemory()) {
++CurrentGeneration;
+
+ // Okay, we just invalidated anything we knew about loaded values. Try to
+ // salvage *something* by remembering that the stored value is a live
+ // version of the pointer. It is safe to forward from volatile stores to
+ // non-volatile loads, so we don't have to check for volatility of the
+ // store.
+ if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) {
+ AvailableLoads->insert(SI->getPointerOperand(),
+ std::pair<Value*, unsigned>(SI->getValueOperand(), CurrentGeneration));
+ }
+ }
}
unsigned LiveOutGeneration = CurrentGeneration;