diff options
author | Dan Gohman <gohman@apple.com> | 2009-10-13 20:12:23 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-10-13 20:12:23 +0000 |
commit | 2dc6f8de03af70291b716a4665b9f6a38c061245 (patch) | |
tree | abbd30f20ee520ead0ce838825a5dcac78900fdf /llvm/lib/Transforms/Scalar/LoopUnswitch.cpp | |
parent | abb728d3f40e628cf7c0e9e7f620ddb7c7fad4f7 (diff) | |
download | bcm5719-llvm-2dc6f8de03af70291b716a4665b9f6a38c061245.tar.gz bcm5719-llvm-2dc6f8de03af70291b716a4665b9f6a38c061245.zip |
Use the new CodeMetrics class to compute code size instead of
manually counting instructions.
llvm-svn: 84016
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopUnswitch.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopUnswitch.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp index f116d5314e9..624f2400fb1 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -34,6 +34,7 @@ #include "llvm/Instructions.h" #include "llvm/LLVMContext.h" #include "llvm/Analysis/ConstantFolding.h" +#include "llvm/Analysis/InlineCost.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/Dominators.h" @@ -408,15 +409,14 @@ unsigned LoopUnswitch::getLoopUnswitchCost(Value *LIC) { if (IsTrivialUnswitchCondition(LIC)) return 0; - // FIXME: This is really overly conservative and brain dead. - unsigned Cost = 0; + // FIXME: This is overly conservative because it does not take into + // consideration code simplification opportunities. + CodeMetrics Metrics; for (Loop::block_iterator I = currentLoop->block_begin(), E = currentLoop->block_end(); I != E; ++I) - // Count instructions. - Cost += (*I)->size(); - - return Cost; + Metrics.analyzeBasicBlock(*I); + return Metrics.NumInsts; } /// UnswitchIfProfitable - We have found that we can unswitch currentLoop when |