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/SimpleLoopUnswitch.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/SimpleLoopUnswitch.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp index cb78240..82e98ec 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); } |