aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopVersioning.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2021-10-18 17:55:48 +0100
committerFlorian Hahn <flo@fhahn.com>2021-10-18 18:03:09 +0100
commite844f05397b72cbfe20170c445a7dae875df2017 (patch)
treef5614cd868c590d6618507efd63578e405761103 /llvm/lib/Transforms/Utils/LoopVersioning.cpp
parent62bf850910e66cef223fb36c6cedb7a90f6aee3c (diff)
downloadllvm-e844f05397b72cbfe20170c445a7dae875df2017.zip
llvm-e844f05397b72cbfe20170c445a7dae875df2017.tar.gz
llvm-e844f05397b72cbfe20170c445a7dae875df2017.tar.bz2
[LoopUtils] Simplify addRuntimeCheck to return a single value.
This simplifies the return value of addRuntimeCheck from a pair of instructions to a single `Value *`. The existing users of addRuntimeChecks were ignoring the first element of the pair, hence there is not reason to track FirstInst and return it. Additionally all users of addRuntimeChecks use the second returned `Instruction *` just as `Value *`, so there is no need to return an `Instruction *`. Therefore there is no need to create a redundant dummy `and X, true` instruction any longer. Effectively this change should not impact the generated code because the redundant AND will be folded by later optimizations. But it is easy to avoid creating it in the first place and it allows more accurately estimating the cost of the runtime checks.
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopVersioning.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopVersioning.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopVersioning.cpp b/llvm/lib/Transforms/Utils/LoopVersioning.cpp
index 3498f29..771b7d2 100644
--- a/llvm/lib/Transforms/Utils/LoopVersioning.cpp
+++ b/llvm/lib/Transforms/Utils/LoopVersioning.cpp
@@ -52,8 +52,7 @@ void LoopVersioning::versionLoop(
assert(VersionedLoop->isLoopSimplifyForm() &&
"Loop is not in loop-simplify form");
- Instruction *FirstCheckInst;
- Instruction *MemRuntimeCheck;
+ Value *MemRuntimeCheck;
Value *SCEVRuntimeCheck;
Value *RuntimeCheck = nullptr;
@@ -64,8 +63,8 @@ void LoopVersioning::versionLoop(
SCEVExpander Exp2(*RtPtrChecking.getSE(),
VersionedLoop->getHeader()->getModule()->getDataLayout(),
"induction");
- std::tie(FirstCheckInst, MemRuntimeCheck) = addRuntimeChecks(
- RuntimeCheckBB->getTerminator(), VersionedLoop, AliasChecks, Exp2);
+ MemRuntimeCheck = addRuntimeChecks(RuntimeCheckBB->getTerminator(),
+ VersionedLoop, AliasChecks, Exp2);
SCEVExpander Exp(*SE, RuntimeCheckBB->getModule()->getDataLayout(),
"scev.check");