[NFC][LICM] Rearrange checks to have the cheap bail out first
authorPhilip Reames <listmail@philipreames.com>
Thu, 29 Mar 2018 20:32:15 +0000 (20:32 +0000)
committerPhilip Reames <listmail@philipreames.com>
Thu, 29 Mar 2018 20:32:15 +0000 (20:32 +0000)
llvm-svn: 328822

llvm/lib/Transforms/Scalar/LoopUnswitch.cpp

index ec1f4a7..91a3008 100644 (file)
@@ -635,6 +635,12 @@ bool LoopUnswitch::processCurrentLoop() {
     return true;
   }
 
+  // Do not do non-trivial unswitch while optimizing for size.
+  // FIXME: Use Function::optForSize().
+  if (OptimizeForSize ||
+      loopHeader->getParent()->hasFnAttribute(Attribute::OptimizeForSize))
+    return false;
+
   // Run through the instructions in the loop, keeping track of three things:
   //
   //  - That we do not unswitch loops containing convergent operations, as we
@@ -666,12 +672,6 @@ bool LoopUnswitch::processCurrentLoop() {
     }
   }
 
-  // Do not do non-trivial unswitch while optimizing for size.
-  // FIXME: Use Function::optForSize().
-  if (OptimizeForSize ||
-      loopHeader->getParent()->hasFnAttribute(Attribute::OptimizeForSize))
-    return false;
-
   for (IntrinsicInst *Guard : Guards) {
     Value *LoopCond =
         FindLIVLoopCondition(Guard->getOperand(0), currentLoop, Changed).first;