Changes in directory llvm/lib/Transforms/Scalar:
LoopUnswitch.cpp updated: 1.69 -> 1.70 --- Log message: Avoid non-trivial loop unswitching while optimizing for size. --- Diffs of the changes: (+12 -3) LoopUnswitch.cpp | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) Index: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp diff -u llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.69 llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.70 --- llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.69 Wed May 9 03:24:12 2007 +++ llvm/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Jun 5 19:21:03 2007 @@ -67,10 +67,12 @@ // after RewriteLoopBodyWithConditionConstant rewrites first loop. std::vector<Loop*> LoopProcessWorklist; SmallPtrSet<Value *,8> UnswitchedVals; - + + bool OptimizeForSize; public: static char ID; // Pass ID, replacement for typeid - LoopUnswitch() : LoopPass((intptr_t)&ID) {} + LoopUnswitch(bool Os = false) : + LoopPass((intptr_t)&ID), OptimizeForSize(Os) {} bool runOnLoop(Loop *L, LPPassManager &LPM); @@ -116,7 +118,9 @@ RegisterPass<LoopUnswitch> X("loop-unswitch", "Unswitch loops"); } -LoopPass *llvm::createLoopUnswitchPass() { return new LoopUnswitch(); } +LoopPass *llvm::createLoopUnswitchPass(bool Os) { + return new LoopUnswitch(Os); +} /// FindLIVLoopCondition - Cond is a condition that occurs in L. If it is /// invariant in the loop, or has an invariant piece, return the invariant. @@ -359,6 +363,11 @@ bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val,Loop *L){ // Check to see if it would be profitable to unswitch this loop. unsigned Cost = getLoopUnswitchCost(L, LoopCond); + + // Do not do non-trivial unswitch while optimizing for size. + if (Cost && OptimizeForSize) + return false; + if (Cost > Threshold) { // FIXME: this should estimate growth by the amount of code shared by the // resultant unswitched loops. _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits