Fix a bug in the loop in JumpThreading::ProcessThreadableEdges() where it could false...
authorFrits van Bommel <fvbommel@gmail.com>
Thu, 16 Dec 2010 12:16:00 +0000 (12:16 +0000)
committerFrits van Bommel <fvbommel@gmail.com>
Thu, 16 Dec 2010 12:16:00 +0000 (12:16 +0000)
This wasn't a correctness problem, but it broke the fast path for single-predecessor blocks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121966 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/JumpThreading.cpp

index e59ae31e134604505d6b48c9fce8d7f09ac33cf3..3d218a6585a5219292d631f72fc11d902eef9eba 100644 (file)
@@ -984,7 +984,7 @@ FindMostPopularDest(BasicBlock *BB,
     }
   }
 
-  // Okay, now we know the most popular destination.  If there is more than
+  // Okay, now we know the most popular destination.  If there is more than one
   // destination, we need to determine one.  This is arbitrary, but we need
   // to make a deterministic decision.  Pick the first one that appears in the
   // successor list.
@@ -1064,7 +1064,7 @@ bool JumpThreading::ProcessThreadableEdges(Value *Cond, BasicBlock *BB,
     }
 
     // If we have exactly one destination, remember it for efficiency below.
-    if (i == 0)
+    if (PredToDestList.empty())
       OnlyDest = DestBB;
     else if (OnlyDest != DestBB)
       OnlyDest = MultipleDestSentinel;