aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/LoopUnswitch.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2007-02-26 20:22:50 +0000
committerDevang Patel <dpatel@apple.com>2007-02-26 20:22:50 +0000
commitfb688d4d1c353d58c9c5f44c6a0681245c693ace (patch)
treeeb92be586c2eaacc087725b5a98c2f22f663450c /lib/Transforms/Scalar/LoopUnswitch.cpp
parentcaddd44be776e0dc97baf40ca8afdd405cb705a1 (diff)
Use efficient container SmallPtrSet
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34640 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopUnswitch.cpp')
-rw-r--r--lib/Transforms/Scalar/LoopUnswitch.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp
index cd8d82bcde..861e97ce58 100644
--- a/lib/Transforms/Scalar/LoopUnswitch.cpp
+++ b/lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -38,6 +38,7 @@
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/ADT/Statistic.h"
+#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
@@ -62,7 +63,7 @@ namespace {
// LoopProcessWorklist - List of loops we need to process.
std::vector<Loop*> LoopProcessWorklist;
- std::set<Value *> UnswitchedVals;
+ SmallPtrSet<Value *,8> UnswitchedVals;
public:
virtual bool runOnFunction(Function &F);
@@ -129,6 +130,7 @@ bool LoopUnswitch::runOnFunction(Function &F) {
Changed |= visitLoop(L);
}
+ UnswitchedVals.clear();
return Changed;
}
@@ -189,9 +191,8 @@ bool LoopUnswitch::visitLoop(Loop *L) {
// FIXME: this should chose the most expensive case!
Constant *UnswitchVal = SI->getCaseValue(1);
// Do not process same value again and again.
- if (UnswitchedVals.count(UnswitchVal) != 0)
+ if (!UnswitchedVals.insert(UnswitchVal))
continue;
- UnswitchedVals.insert(UnswitchVal);
if (UnswitchIfProfitable(LoopCond, UnswitchVal, L)) {
++NumSwitches;