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 | 967b84c681156a5697ba8e058c3763602572cbe3 (patch) | |
| tree | 42016ec147d7fd4c7375d98a09e6a2384c9312d0 /llvm | |
| parent | 77f0a1553c89728e6ab00fa8f8d2860dabe509db (diff) | |
| download | bcm5719-llvm-967b84c681156a5697ba8e058c3763602572cbe3.tar.gz bcm5719-llvm-967b84c681156a5697ba8e058c3763602572cbe3.zip | |
Do not unswitch loop on same value again and again.
llvm-svn: 34638
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopUnswitch.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp index 8a4ac01fbe4..cd8d82bcde8 100644 --- a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/llvm/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; |

