[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
Devang Patel
dpatel at apple.com
Mon Feb 26 11:32:18 PST 2007
Changes in directory llvm/lib/Transforms/Scalar:
LoopUnswitch.cpp updated: 1.61 -> 1.62
---
Log message:
Do not unswitch loop on same value again and again.
---
Diffs of the changes: (+7 -0)
LoopUnswitch.cpp | 7 +++++++
1 files changed, 7 insertions(+)
Index: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
diff -u llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.61 llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.62
--- llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.61 Mon Feb 5 17:32:05 2007
+++ llvm/lib/Transforms/Scalar/LoopUnswitch.cpp Mon Feb 26 13:31:58 2007
@@ -62,6 +62,8 @@
// 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 @@
// 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;
More information about the llvm-commits
mailing list