aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/LoopUnswitch.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-07-14 01:37:59 +0000
committerDan Gohman <gohman@apple.com>2009-07-14 01:37:59 +0000
commit0df6e09d43d6d733555a10d22572ddb0006e7d23 (patch)
tree4f3d6d05529e7ec08a8a52ce1174bda6cad1f98a /lib/Transforms/Scalar/LoopUnswitch.cpp
parent6084326c3c39e65f1ce42099296571334d653c88 (diff)
Update LoopSimplify and LoopUnswitch to use the new makeLoopInvariant
function. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75584 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopUnswitch.cpp')
-rw-r--r--lib/Transforms/Scalar/LoopUnswitch.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp
index 0a3659c71d..f5061b57ae 100644
--- a/lib/Transforms/Scalar/LoopUnswitch.cpp
+++ b/lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -168,9 +168,14 @@ static Value *FindLIVLoopCondition(Value *Cond, Loop *L, bool &Changed) {
if (isa<Constant>(Cond)) return 0;
// TODO: Handle: br (VARIANT|INVARIANT).
- // TODO: Hoist simple expressions out of loops.
if (L->isLoopInvariant(Cond)) return Cond;
+ // Hoist simple values out.
+ if (L->makeLoopInvariant(Cond)) {
+ Changed = true;
+ return Cond;
+ }
+
if (BinaryOperator *BO = dyn_cast<BinaryOperator>(Cond))
if (BO->getOpcode() == Instruction::And ||
BO->getOpcode() == Instruction::Or) {