[llvm-commits] [llvm] r51082 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Owen Anderson
resistor at mac.com
Tue May 13 16:18:30 PDT 2008
Author: resistor
Date: Tue May 13 18:18:30 2008
New Revision: 51082
URL: http://llvm.org/viewvc/llvm-project?rev=51082&view=rev
Log:
Fix Analysis/BasicAA/pure-const-dce.ll. This turned out to be a correctness
bug as well as a missed optimization. We weren't properly checking for local
dependencies before moving on to non-local ones when doing non-local read-only
call CSE.
Modified:
llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=51082&r1=51081&r2=51082&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Tue May 13 18:18:30 2008
@@ -441,6 +441,43 @@
return nextValueNumber++;
}
+ Instruction* local_dep = MD->getDependency(C);
+
+ if (local_dep == MemoryDependenceAnalysis::None) {
+ valueNumbering.insert(std::make_pair(V, nextValueNumber));
+ return nextValueNumber++;
+ } else if (local_dep != MemoryDependenceAnalysis::NonLocal) {
+ if (!isa<CallInst>(local_dep)) {
+ valueNumbering.insert(std::make_pair(V, nextValueNumber));
+ return nextValueNumber++;
+ }
+
+ CallInst* local_cdep = cast<CallInst>(local_dep);
+
+ if (local_cdep->getCalledFunction() != C->getCalledFunction() ||
+ local_cdep->getNumOperands() != C->getNumOperands()) {
+ valueNumbering.insert(std::make_pair(V, nextValueNumber));
+ return nextValueNumber++;
+ } else if (!C->getCalledFunction()) {
+ valueNumbering.insert(std::make_pair(V, nextValueNumber));
+ return nextValueNumber++;
+ } else {
+ for (unsigned i = 1; i < C->getNumOperands(); ++i) {
+ uint32_t c_vn = lookup_or_add(C->getOperand(i));
+ uint32_t cd_vn = lookup_or_add(local_cdep->getOperand(i));
+ if (c_vn != cd_vn) {
+ valueNumbering.insert(std::make_pair(V, nextValueNumber));
+ return nextValueNumber++;
+ }
+ }
+
+ uint32_t v = lookup_or_add(local_cdep);
+ valueNumbering.insert(std::make_pair(V, v));
+ return v;
+ }
+ }
+
+
DenseMap<BasicBlock*, Value*> deps;
MD->getNonLocalDependency(C, deps);
CallInst* cdep = 0;
@@ -488,7 +525,7 @@
}
}
- uint32_t v = valueNumbering[cdep];
+ uint32_t v = lookup_or_add(cdep);
valueNumbering.insert(std::make_pair(V, v));
return v;
}
More information about the llvm-commits
mailing list