diff options
author | Devang Patel <dpatel@apple.com> | 2009-02-03 22:04:27 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2009-02-03 22:04:27 +0000 |
commit | 43a1161379f7b91b68a249aed23425518aa4b68d (patch) | |
tree | a58cfdc23bced7c6bbfc5d6ddf2e95cd0df4c54c /llvm/lib/Transforms/Scalar/LoopUnswitch.cpp | |
parent | 25bd0320841785cf4e0cf563f7dc56169197b9e0 (diff) | |
download | bcm5719-llvm-43a1161379f7b91b68a249aed23425518aa4b68d.tar.gz bcm5719-llvm-43a1161379f7b91b68a249aed23425518aa4b68d.zip |
If "optimize for size" attribute is set then block non-trivial loop unswitches but allow trivial loop unswitches.
llvm-svn: 63670
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopUnswitch.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopUnswitch.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp index a563c7a9ee9..436e6a5786c 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -430,9 +430,6 @@ bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val){ initLoopData(); Function *F = loopHeader->getParent(); - // Do not unswitch if the function is optimized for size. - if (!F->isDeclaration() && F->hasFnAttr(Attribute::OptimizeForSize)) - return false; // Check to see if it would be profitable to unswitch current loop. unsigned Cost = getLoopUnswitchCost(LoopCond); @@ -440,6 +437,8 @@ bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val){ // Do not do non-trivial unswitch while optimizing for size. if (Cost && OptimizeForSize) return false; + if (Cost && !F->isDeclaration() && F->hasFnAttr(Attribute::OptimizeForSize)) + return false; if (Cost > Threshold) { // FIXME: this should estimate growth by the amount of code shared by the |