diff options
Diffstat (limited to 'lib/Transforms/Scalar/LoopUnswitch.cpp')
-rw-r--r-- | lib/Transforms/Scalar/LoopUnswitch.cpp | 7 |
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) { |