Don't unswitch really large loops even if they are mostly filled with empty
authorChris Lattner <sabre@nondot.org>
Wed, 28 Jun 2006 16:38:55 +0000 (16:38 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 28 Jun 2006 16:38:55 +0000 (16:38 +0000)
blocks.

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

lib/Transforms/Scalar/LoopUnswitch.cpp

index d33dcb7c0b0c4412100a932ed78fb67ef750838f..945803f0afc063226b2af4fe96ad5d7e1c6c5bbf 100644 (file)
@@ -333,6 +333,12 @@ unsigned LoopUnswitch::getLoopUnswitchCost(Loop *L, Value *LIC) {
   if (IsTrivialUnswitchCondition(L, LIC))
     return 0;
   
+  // If the loop is really large (over twice our threshold) don't even consider
+  // unswitching it.  This will produce a really large loop with lots of empty
+  // blocks.
+  if (L->getBlocks().size() > 2*Threshold)
+    return 2*Threshold;
+  
   unsigned Cost = 0;
   // FIXME: this is brain dead.  It should take into consideration code
   // shrinkage.