aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopUtils.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2024-06-04 20:37:45 +0100
committerFlorian Hahn <flo@fhahn.com>2024-06-04 20:37:46 +0100
commite775efcec476b3ec4eacfb14dc5bc7e86d9aa8fd (patch)
treef4a2059939615289f88adf9fd47a02b1f2f79a9f /llvm/lib/Transforms/Utils/LoopUtils.cpp
parentfbaec0f46b5853cbdbdfe77fb87e1321a1967956 (diff)
downloadllvm-e775efcec476b3ec4eacfb14dc5bc7e86d9aa8fd.zip
llvm-e775efcec476b3ec4eacfb14dc5bc7e86d9aa8fd.tar.gz
llvm-e775efcec476b3ec4eacfb14dc5bc7e86d9aa8fd.tar.bz2
[LV] Apply loop guards when checking recur during hoisting RT checks.
Apply loop guards when checking if the recurrence is non-negative in cases where runtime checks are hoisted out of an inner loop.
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUtils.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUtils.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index de3eb4a..922d4b6 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -1760,7 +1760,8 @@ static PointerBounds expandBounds(const RuntimeCheckingPtrGroup *CG,
Low = cast<SCEVAddRecExpr>(Low)->getStart();
// If there is a possibility that the stride is negative then we have
// to generate extra checks to ensure the stride is positive.
- if (!SE.isKnownNonNegative(Recur)) {
+ if (!SE.isKnownNonNegative(
+ SE.applyLoopGuards(Recur, HighAR->getLoop()))) {
Stride = Recur;
LLVM_DEBUG(dbgs() << "LAA: ... but need to check stride is "
"positive: "