Filter loops where split condition's false branch is not empty. For example
authorDevang Patel <dpatel@apple.com>
Wed, 19 Sep 2007 00:15:16 +0000 (00:15 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 19 Sep 2007 00:15:16 +0000 (00:15 +0000)
for (int i = 0; i < N; ++i) {
  if (i == somevalue)
    dosomething();
   else
    dosomethingelse();
}

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

lib/Transforms/Scalar/LoopIndexSplit.cpp

index 92a6058b5a64b569b53372dea9de749a84f0e34c..cb5060a676540f82e425587acd83914552c660da 100644 (file)
@@ -528,6 +528,10 @@ bool LoopIndexSplit::processOneIterationLoop(SplitInfo &SD) {
   if (!safeExitingBlock(SD, ExitCondition->getParent())) 
     return false;
 
+  // Filter loops where split condition's false branch is not empty.
+  if (ExitCondition->getParent() != Header->getTerminator()->getSuccessor(1))
+    return false;
+
   // If split condition is not safe then do not process this loop.
   // For example,
   // for(int i = 0; i < N; i++) {