[llvm-commits] [llvm] r84016 - /llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
Dan Gohman
gohman at apple.com
Tue Oct 13 13:12:23 PDT 2009
Author: djg
Date: Tue Oct 13 15:12:23 2009
New Revision: 84016
URL: http://llvm.org/viewvc/llvm-project?rev=84016&view=rev
Log:
Use the new CodeMetrics class to compute code size instead of
manually counting instructions.
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=84016&r1=84015&r2=84016&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Oct 13 15:12:23 2009
@@ -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 @@
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
More information about the llvm-commits
mailing list