[llvm-branch-commits] [llvm-branch] r91831 - in /llvm/branches/Apple/Zoidberg: include/llvm/ADT/DenseMap.h lib/Transforms/Utils/SSAUpdater.cpp test/Transforms/LoopRotate/phi-duplicate.ll
Bill Wendling
isanbard at gmail.com
Mon Dec 21 11:04:39 PST 2009
Author: void
Date: Mon Dec 21 13:04:38 2009
New Revision: 91831
URL: http://llvm.org/viewvc/llvm-project?rev=91831&view=rev
Log:
$ svn merge -c 91819 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r91819 into '.':
U include/llvm/ADT/DenseMap.h
$ svn merge -c 91820 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r91820 into '.':
A test/Transforms/LoopRotate/phi-duplicate.ll
U lib/Transforms/Utils/SSAUpdater.cpp
Added:
llvm/branches/Apple/Zoidberg/test/Transforms/LoopRotate/phi-duplicate.ll
- copied unchanged from r91820, llvm/trunk/test/Transforms/LoopRotate/phi-duplicate.ll
Modified:
llvm/branches/Apple/Zoidberg/include/llvm/ADT/DenseMap.h
llvm/branches/Apple/Zoidberg/lib/Transforms/Utils/SSAUpdater.cpp
Modified: llvm/branches/Apple/Zoidberg/include/llvm/ADT/DenseMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/include/llvm/ADT/DenseMap.h?rev=91831&r1=91830&r2=91831&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/include/llvm/ADT/DenseMap.h (original)
+++ llvm/branches/Apple/Zoidberg/include/llvm/ADT/DenseMap.h Mon Dec 21 13:04:38 2009
@@ -46,7 +46,7 @@
typedef ValueT mapped_type;
typedef BucketT value_type;
- DenseMap(const DenseMap& other) {
+ DenseMap(const DenseMap &other) {
NumBuckets = 0;
CopyFrom(other);
}
@@ -55,6 +55,12 @@
init(NumInitBuckets);
}
+ template<typename InputIt>
+ DenseMap(const InputIt &I, const InputIt &E) {
+ init(64);
+ insert(I, E);
+ }
+
~DenseMap() {
const KeyT EmptyKey = getEmptyKey(), TombstoneKey = getTombstoneKey();
for (BucketT *P = Buckets, *E = Buckets+NumBuckets; P != E; ++P) {
Modified: llvm/branches/Apple/Zoidberg/lib/Transforms/Utils/SSAUpdater.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Transforms/Utils/SSAUpdater.cpp?rev=91831&r1=91830&r2=91831&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Transforms/Utils/SSAUpdater.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Transforms/Utils/SSAUpdater.cpp Mon Dec 21 13:04:38 2009
@@ -149,7 +149,29 @@
if (SingularValue != 0)
return SingularValue;
- // Otherwise, we do need a PHI: insert one now.
+ // Otherwise, we do need a PHI: check to see if we already have one available
+ // in this block that produces the right value.
+ if (isa<PHINode>(BB->begin())) {
+ DenseMap<BasicBlock*, Value*> ValueMapping(PredValues.begin(),
+ PredValues.end());
+ PHINode *SomePHI;
+ for (BasicBlock::iterator It = BB->begin();
+ (SomePHI = dyn_cast<PHINode>(It)); ++It) {
+ // Scan this phi to see if it is what we need.
+ bool Equal = true;
+ for (unsigned i = 0, e = SomePHI->getNumIncomingValues(); i != e; ++i)
+ if (ValueMapping[SomePHI->getIncomingBlock(i)] !=
+ SomePHI->getIncomingValue(i)) {
+ Equal = false;
+ break;
+ }
+
+ if (Equal)
+ return SomePHI;
+ }
+ }
+
+ // Ok, we have no way out, insert a new one now.
PHINode *InsertedPHI = PHINode::Create(PrototypeValue->getType(),
PrototypeValue->getName(),
&BB->front());
More information about the llvm-branch-commits
mailing list