Porting r50563 from Tak to mainline.
authorBill Wendling <isanbard@gmail.com>
Fri, 2 May 2008 00:43:20 +0000 (00:43 +0000)
committerBill Wendling <isanbard@gmail.com>
Fri, 2 May 2008 00:43:20 +0000 (00:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50564 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopIndexSplit.cpp

index da6f076a9a65775d1c4f71d411a30c824b01479d..a6bd9ff20a9ae965ea31d325ae45f39580d88955 100644 (file)
@@ -1124,6 +1124,11 @@ bool LoopIndexSplit::safeSplitCondition(SplitInfo &SD) {
   BasicBlock *Succ0 = SplitTerminator->getSuccessor(0);
   BasicBlock *Succ1 = SplitTerminator->getSuccessor(1);
 
+  // If split block does not dominate the latch then this is not a diamond.
+  // Such loop may not benefit from index split.
+  if (!DT->dominates(SplitCondBlock, Latch))
+    return false;
+
   // Finally this split condition is safe only if merge point for
   // split condition branch is loop latch. This check along with previous
   // check, to ensure that exit condition is in either loop latch or header,