diff options
author | Philip Reames <listmail@philipreames.com> | 2019-07-06 03:46:18 +0000 |
---|---|---|
committer | Philip Reames <listmail@philipreames.com> | 2019-07-06 03:46:18 +0000 |
commit | 9e62c864087b220da67dc1bf5db197454cedd7e2 (patch) | |
tree | cb2f1f0c71d4f57bcb8c515c29363c8759e086a1 /llvm/lib/Transforms/Scalar/LoopPredication.cpp | |
parent | adeb5ac2d6431f348b510e1eca5b91ac6a9aa86f (diff) | |
download | llvm-9e62c864087b220da67dc1bf5db197454cedd7e2.zip llvm-9e62c864087b220da67dc1bf5db197454cedd7e2.tar.gz llvm-9e62c864087b220da67dc1bf5db197454cedd7e2.tar.bz2 |
[IRBuilder] Introduce helpers for and/or of multiple values at once
We had versions of this code scattered around, so consolidate into one location.
Not strictly NFC since the order of intermediate results may change in some places, but since these operations are associatives, should not change results.
llvm-svn: 365259
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopPredication.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopPredication.cpp | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopPredication.cpp b/llvm/lib/Transforms/Scalar/LoopPredication.cpp index ed715d3..d3cec75 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); |