Fix a performance problem with the new SSAUpdater. This showed up in the
[oota-llvm.git] / lib / Transforms / Utils / SSAUpdater.cpp
index d491cbb91556b187428bd682d815a37ce8bcf252..25d50dbf2a8ba75dd190be8fa890f0a96d509329 100644 (file)
@@ -529,9 +529,15 @@ void SSAUpdater::FindAvailableVals(BlockListTy *BlockList) {
          E = BlockList->rend(); I != E; ++I) {
     BBInfo *Info = *I;
 
-    // Check if this block contains a newly added PHI.
-    if (Info->DefBB != Info)
+    if (Info->DefBB != Info) {
+      // Record the available value at join nodes to speed up subsequent
+      // uses of this SSAUpdater for the same value.
+      if (Info->NumPreds > 1)
+        AvailableVals[Info->BB] = Info->DefBB->AvailableVal;
       continue;
+    }
+
+    // Check if this block contains a newly added PHI.
     PHINode *PHI = dyn_cast<PHINode>(Info->AvailableVal);
     if (!PHI || PHI->getNumIncomingValues() == Info->NumPreds)
       continue;