[llvm] r328822 - [NFC][LICM] Rearrange checks to have the cheap bail out first

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 29 13:32:16 PDT 2018


Author: reames
Date: Thu Mar 29 13:32:15 2018
New Revision: 328822

URL: http://llvm.org/viewvc/llvm-project?rev=328822&view=rev
Log:
[NFC][LICM] Rearrange checks to have the cheap bail out first


Modified:
    llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=328822&r1=328821&r2=328822&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Thu Mar 29 13:32:15 2018
@@ -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;




More information about the llvm-commits mailing list