[llvm-commits] [llvm] r55786 - /llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp

Devang Patel dpatel at apple.com
Thu Sep 4 11:55:13 PDT 2008


Author: dpatel
Date: Thu Sep  4 13:55:13 2008
New Revision: 55786

URL: http://llvm.org/viewvc/llvm-project?rev=55786&view=rev
Log:
Do not unswitch if the function notes say we're optimizing this function for size.


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=55786&r1=55785&r2=55786&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Thu Sep  4 13:55:13 2008
@@ -417,6 +417,13 @@
 /// LoopCond == Val to simplify the loop.  If we decide that this is profitable,
 /// unswitch the loop, reprocess the pieces, then return true.
 bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val){
+
+  Function *F = loopHeader->getParent();
+
+  // Do not unswitch if the function is optimized for size.
+  if (F->getNotes() & FN_NOTE_OptimizeForSize)
+    return false;
+
   // Check to see if it would be profitable to unswitch current loop.
   unsigned Cost = getLoopUnswitchCost(LoopCond);
 
@@ -445,7 +452,6 @@
   }
 
   // FIXME: Reconstruct dom info, because it is not preserved properly.
-  Function *F = loopHeader->getParent();
   if (DT)
     DT->runOnFunction(*F);
   if (DF)





More information about the llvm-commits mailing list