aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/LoopUnswitch.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-02-09 20:15:48 +0000
committerChris Lattner <sabre@nondot.org>2006-02-09 20:15:48 +0000
commite487abbfbf9fdef21e5216379b2e74436ef99c7b (patch)
treea5f7e8d6f072b53fce1f414e42077c00a6fabcb4 /lib/Transforms/Scalar/LoopUnswitch.cpp
parentf26276661984b6ea77acf1105a4a18cb128d329d (diff)
Make the threshold a parameter
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26093 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopUnswitch.cpp')
-rw-r--r--lib/Transforms/Scalar/LoopUnswitch.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp
index 3cdfd47381..850be78f80 100644
--- a/lib/Transforms/Scalar/LoopUnswitch.cpp
+++ b/lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -34,8 +34,9 @@
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/Local.h"
-#include "llvm/Support/Debug.h"
#include "llvm/ADT/Statistic.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/CommandLine.h"
#include <algorithm>
#include <iostream>
#include <set>
@@ -43,7 +44,10 @@ using namespace llvm;
namespace {
Statistic<> NumUnswitched("loop-unswitch", "Number of loops unswitched");
-
+ cl::opt<unsigned>
+ Threshold("loop-unswitch-threshold", cl::desc("Max loop size to unswitch"),
+ cl::init(10), cl::Hidden);
+
class LoopUnswitch : public FunctionPass {
LoopInfo *LI; // Loop information
public:
@@ -145,7 +149,7 @@ bool LoopUnswitch::visitLoop(Loop *L) {
continue;
// Check to see if it would be profitable to unswitch this loop.
- if (L->getBlocks().size() > 10) {
+ if (L->getBlocks().size() > Threshold) {
// FIXME: this should estimate growth by the amount of code shared by the
// resultant unswitched loops. This should have no code growth:
// for () { if (iv) {...} }