[PATCH] D11997: [LoopUnswitch] Check OptimizeForSize before traversing over all basic blocks in current loop

Chen Li via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 12 16:04:25 PDT 2015


chenli created this revision.
chenli added a reviewer: reames.
chenli added a subscriber: llvm-commits.

This patch moves the check of OptimizeForSize before traversing over all basic blocks in current loop. If OptimizeForSize is set to true, no non-trivial unswitch is ever allowed. Therefore, the early exit will help reduce compilation time. This patch should be NFC. 

http://reviews.llvm.org/D11997

Files:
  lib/Transforms/Scalar/LoopUnswitch.cpp

Index: lib/Transforms/Scalar/LoopUnswitch.cpp
===================================================================
--- lib/Transforms/Scalar/LoopUnswitch.cpp
+++ lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -463,6 +463,11 @@
     return true;
   }
 
+  // Do not do non-trivial unswitch while optimizing for size.
+  // FIXME: Use Function::optForSize().
+  if (OptimizeForSize || F->hasFnAttribute(Attribute::OptimizeForSize))
+    return false;
+
   // Loop over all of the basic blocks in the loop.  If we find an interior
   // block that is branching on a loop-invariant condition, we can unswitch this
   // loop.
@@ -598,11 +603,6 @@
     return false;
   }
 
-  // Do not do non-trivial unswitch while optimizing for size.
-  // FIXME: Use Function::optForSize().
-  if (OptimizeForSize || F->hasFnAttribute(Attribute::OptimizeForSize))
-    return false;
-
   UnswitchNontrivialCondition(LoopCond, Val, currentLoop, TI);
   return true;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11997.31996.patch
Type: text/x-patch
Size: 945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150812/42fabfb7/attachment-0001.bin>


More information about the llvm-commits mailing list