diff options
author | Devang Patel <dpatel@apple.com> | 2007-02-26 19:31:58 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2007-02-26 19:31:58 +0000 |
commit | 5295692061b48f94d73d2016ff22f0504ccdd494 (patch) | |
tree | 09d130c7def61bba57a1e79656e6b61b3eabcf98 /lib/Transforms/Scalar/LoopUnswitch.cpp | |
parent | bffc1b3c4e15e497cf431b224c3f7889bccb1933 (diff) |
Do not unswitch loop on same value again and again.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34638 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopUnswitch.cpp')
-rw-r--r-- | lib/Transforms/Scalar/LoopUnswitch.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp index 8a4ac01fbe..cd8d82bcde 100644 --- a/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -62,6 +62,8 @@ namespace { // LoopProcessWorklist - List of loops we need to process. std::vector<Loop*> LoopProcessWorklist; + std::set<Value *> UnswitchedVals; + public: virtual bool runOnFunction(Function &F); bool visitLoop(Loop *L); @@ -186,6 +188,11 @@ bool LoopUnswitch::visitLoop(Loop *L) { // Find a value to unswitch on: // 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) + continue; + UnswitchedVals.insert(UnswitchVal); + if (UnswitchIfProfitable(LoopCond, UnswitchVal, L)) { ++NumSwitches; return true; |