summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/LoadValueNumbering.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-29 06:42:34 +0000
committerChris Lattner <sabre@nondot.org>2005-01-29 06:42:34 +0000
commitce0fa4c1090ea01b1d359043a99132f1e10fbef5 (patch)
tree87378463855ff9682a40f3f4e0d4e62983c3c75c /llvm/lib/Analysis/LoadValueNumbering.cpp
parenta19435702536f01a0b02ee03d9f968a155caaf53 (diff)
downloadbcm5719-llvm-ce0fa4c1090ea01b1d359043a99132f1e10fbef5.tar.gz
bcm5719-llvm-ce0fa4c1090ea01b1d359043a99132f1e10fbef5.zip
Properly handle volatile.
llvm-svn: 19912
Diffstat (limited to 'llvm/lib/Analysis/LoadValueNumbering.cpp')
-rw-r--r--llvm/lib/Analysis/LoadValueNumbering.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/llvm/lib/Analysis/LoadValueNumbering.cpp b/llvm/lib/Analysis/LoadValueNumbering.cpp
index 5e91be2a840..b33eb4a7f7b 100644
--- a/llvm/lib/Analysis/LoadValueNumbering.cpp
+++ b/llvm/lib/Analysis/LoadValueNumbering.cpp
@@ -299,12 +299,7 @@ void LoadVN::getEqualNumberNodes(Value *V,
bool LoadInvalidatedInBBBefore = false;
for (BasicBlock::iterator I = LI; I != LoadBB->begin(); ) {
--I;
- // If this instruction is a candidate load before LI, we know there are no
- // invalidating instructions between it and LI, so they have the same value
- // number.
- if (isa<LoadInst>(I) && cast<LoadInst>(I)->getOperand(0) == LoadPtr) {
- RetVals.push_back(I);
- } else if (I == LoadPtr) {
+ if (I == LoadPtr) {
// If we run into an allocation of the value being loaded, then the
// contents are not initialized.
if (isa<AllocationInst>(I))
@@ -314,14 +309,21 @@ void LoadVN::getEqualNumberNodes(Value *V,
// loaded value cannot occur before this block.
LoadInvalidatedInBBBefore = true;
break;
+ } else if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
+ // If this instruction is a candidate load before LI, we know there are no
+ // invalidating instructions between it and LI, so they have the same
+ // value number.
+ if (LI->getOperand(0) == LoadPtr && !LI->isVolatile())
+ RetVals.push_back(I);
}
-
+
if (AA.getModRefInfo(I, LoadPtr, LoadSize) & AliasAnalysis::Mod) {
// If the invalidating instruction is a store, and its in our candidate
// set, then we can do store-load forwarding: the load has the same value
// # as the stored value.
- if (isa<StoreInst>(I) && I->getOperand(1) == LoadPtr)
- RetVals.push_back(I->getOperand(0));
+ if (StoreInst *SI = dyn_cast<StoreInst>(I))
+ if (SI->getOperand(1) == LoadPtr)
+ RetVals.push_back(I->getOperand(0));
LoadInvalidatedInBBBefore = true;
break;
OpenPOWER on IntegriCloud