summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopPredication.cpp18
-rw-r--r--llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp11
2 files changed, 7 insertions, 22 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopPredication.cpp b/llvm/lib/Transforms/Scalar/LoopPredication.cpp
index ed715d36984..d3cec7568b6 100644
--- a/llvm/lib/Transforms/Scalar/LoopPredication.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopPredication.cpp
@@ -793,14 +793,9 @@ bool LoopPredication::widenGuardConditions(IntrinsicInst *Guard,
// Emit the new guard condition
IRBuilder<> Builder(findInsertPt(Guard, Checks));
- Value *LastCheck = nullptr;
- for (auto *Check : Checks)
- if (!LastCheck)
- LastCheck = Check;
- else
- LastCheck = Builder.CreateAnd(LastCheck, Check);
+ Value *AllChecks = Builder.CreateAnd(Checks);
auto *OldCond = Guard->getOperand(0);
- Guard->setOperand(0, LastCheck);
+ Guard->setOperand(0, AllChecks);
RecursivelyDeleteTriviallyDeadInstructions(OldCond);
LLVM_DEBUG(dbgs() << "Widened checks = " << NumWidened << "\n");
@@ -824,14 +819,9 @@ bool LoopPredication::widenWidenableBranchGuardConditions(
// Emit the new guard condition
IRBuilder<> Builder(findInsertPt(BI, Checks));
- Value *LastCheck = nullptr;
- for (auto *Check : Checks)
- if (!LastCheck)
- LastCheck = Check;
- else
- LastCheck = Builder.CreateAnd(LastCheck, Check);
+ Value *AllChecks = Builder.CreateAnd(Checks);
auto *OldCond = BI->getCondition();
- BI->setCondition(LastCheck);
+ BI->setCondition(AllChecks);
assert(isGuardAsWidenableBranch(BI) &&
"Stopped being a guard after transform?");
RecursivelyDeleteTriviallyDeadInstructions(OldCond);
diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index cb782409a73..82e98ec1877 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -180,14 +180,9 @@ static void buildPartialUnswitchConditionalBranch(BasicBlock &BB,
BasicBlock &UnswitchedSucc,
BasicBlock &NormalSucc) {
IRBuilder<> IRB(&BB);
- Value *Cond = Invariants.front();
- for (Value *Invariant :
- make_range(std::next(Invariants.begin()), Invariants.end()))
- if (Direction)
- Cond = IRB.CreateOr(Cond, Invariant);
- else
- Cond = IRB.CreateAnd(Cond, Invariant);
-
+
+ Value *Cond = Direction ? IRB.CreateOr(Invariants) :
+ IRB.CreateAnd(Invariants);
IRB.CreateCondBr(Cond, Direction ? &UnswitchedSucc : &NormalSucc,
Direction ? &NormalSucc : &UnswitchedSucc);
}
OpenPOWER on IntegriCloud