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
diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp
index 0a3659c..f5061b5 100644
--- a/lib/Transforms/Scalar/LoopUnswitch.cpp
+++ b/lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -168,9 +168,14 @@
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) {